forked from svlsResearch/ha-mikrotik
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate
More file actions
executable file
·28 lines (28 loc) · 1.16 KB
/
Copy pathgenerate
File metadata and controls
executable file
·28 lines (28 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
set -e -u
version="$(cat VERSION)"
code_checksum="$(cat scripts/*.script | openssl sha1 | awk '{print $2}')"
ha_version="$version - $code_checksum"
ha_password="$(egrep 'haMacA|haMacB' scripts/ha_config.script | awk '{print $3}' | cut -d '"' -f2 | openssl sha1 | awk '{print $2}')"
(
echo ":do {"
cd scripts
echo "/system script"
for i in *.script; do
script=$(echo "$i" | cut -d '.' -f1)
echo "remove [find name=${script}_new]"
echo -e -n "add name=${script}_new owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive source=\""
cat "$i" | perl -p -e 's/\\/\\\\/g,s/\$/\\\$/g,s/\n/\\\n\t\\n/g,s/"/\\"/g'
echo '"'
done
for i in *.script; do
script=$(echo "$i" | cut -d '.' -f1)
echo "remove [find name=${script}_old]"
echo "remove [find name=${script}]"
echo "set name=${script} [find name=${script}_new]"
done
echo "/system script run [find name=ha_functions]"
echo "}"
) | sed "s/%%%HA_VERSION%%%/$ha_version/gi" | sed "s/%%%HA_PASSWORD%%%/$ha_password/gi" > HA_init.rsc
echo "Please upload HA_init.rsc to the master and run /import HA_init.rsc"
echo 'You can then do $HAInstall'