-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·51 lines (46 loc) · 1.21 KB
/
install.sh
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# 1 - CONNECT to device after upload
CONNECT=${CONNECT:-0}
BACKUP=${BACKUP:-0}
FORCE=0
if [ "$1" = "FORCE" ]
then
shift
FORCE=1
fi
while [ "$1" != "" ]
do
# Some older 6.x versions use system as package, newer have system and routeros
# 7.x have only routeros
MK_VERSION=$(/usr/bin/ssh "$1" ":put [/system package get routeros version]" | grep -E -o "^[0-9]+")
if [ "$MK_VERSION" = "" ]
then
MK_VERSION=$(/usr/bin/ssh "$1" ":put [/system package get system version]" | grep -E -o "^[0-9]+")
fi
if [ "$MK_VERSION" = "" ]
then
echo "Unable to detect version for $1"
exit
fi
export MK_VERSION
if [ $FORCE -eq 1 ]
then
rm -f deploy/install_V${MK_VERSION}.rsc
fi
if [ ! -f deploy/install_V${MK_VERSION}.rsc ]
then
mkdir -p deploy
bash ./prepare.sh -all -fn deploy/IFMMkFunctions_V${MK_VERSION} > deploy/install_V${MK_VERSION}.rsc
fi
ssh $1 < deploy/install_V${MK_VERSION}.rsc
if [ "$BACKUP" = "1" ]
then
echo "Executing backup"
ssh $1 "/system script run IFMMkBackup; /file print"
fi
if [ "$CONNECT" = "1" ]
then
ssh $1
fi
shift
done