-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_StorX_OSonly_and_reboot_auto.sh
72 lines (59 loc) · 2.8 KB
/
update_StorX_OSonly_and_reboot_auto.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# Set filename to obtain IP address list for StorX Node VPS's to Update
FILE="ip_addresses"
# Set Colour Vars
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color
echo
echo
echo -e "${GREEN} #################################################### ${NC}"
echo -e "${GREEN} # # ${NC}"
echo -e "${GREEN} # AUTOMATIC OS-ONLY UPDATER # ${NC}"
echo -e "${GREEN} # FOR MULTIPLE STORX NODES # ${NC}"
echo -e "${GREEN} # # ${NC}"
echo -e "${GREEN} # Created by s4njk4n - https://github.com/s4njk4n/ # ${NC}"
echo -e "${GREEN} # # ${NC}"
echo -e "${GREEN} #################################################### ${NC}"
echo
echo
echo
# Set time (in seconds) to wait for your VPS to reboot. You'll have to manually test this. Recommend rounding UP by a minute or 2
echo -e "${RED}How long (in seconds) should be allowed for each VPS to reboot? (Must be LONGER ${NC}"
echo -e "${RED}than the boot time of your SLOWEST booting node). If unsure, set it to ${NC}"
echo -e "${RED}something long like 300(seconds). Setting a longer time isn't harmful, it will ${NC}"
echo -e "${RED}just take longer to finish all the nodes. If the time selected isn't long ${NC}"
echo -e "${RED}enough however, then the update will not succeed. ${NC}"
read WAITTOREBOOT
while IFS= read line
do
# This section below was neccessary to separate into individual one-line commands and to run TWICE
# in order for certain VPS providers to work properly
echo
echo -e "${GREEN}Updating VPS OS & Packages - $line ${NC}"
ssh -n -p 22 root@$line 'apt update -y'
ssh -n -p 22 root@$line 'apt upgrade -y'
ssh -n -p 22 root@$line 'apt autoremove -y'
ssh -n -p 22 root@$line 'apt clean -y'
ssh -n -p 22 root@$line 'apt update -y'
ssh -n -p 22 root@$line 'apt upgrade -y'
ssh -n -p 22 root@$line 'apt autoremove -y'
ssh -n -p 22 root@$line 'apt clean -y'
echo
echo -e "${GREEN}Rebooting VPS - $line ${NC}"
ssh -n -p 22 root@$line 'reboot' > /dev/null 2>&1
sleep $WAITTOREBOOT
echo
echo -e "${GREEN}Allowing time for daemon to connect - $line ${NC}"
sleep 60s # Wait 60sec to allow daemon to connect (before querying status of StorX Node)
echo
echo -e "${GREEN}Getting Status of Node After Updating OS and Rebooting - $line ${NC}"
ssh -n -p 22 root@$line 'sudo docker exec storx-node_storxnetwork_1 xcore status'
echo
echo -e "${GREEN}Congratulations! Your StorX VPS OS at $line has now been updated ${NC}"
echo
echo -e "${GREEN}--------------------------------------------------------------- ${NC}"
echo
done < "$FILE"
echo -e "${RED}ALL STORX VPS OS UPDATES COMPLETED ${NC}"
echo