-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-all-machines
executable file
·47 lines (41 loc) · 1.17 KB
/
update-all-machines
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
#!/bin/bash
# tmux new -d -s "update-all"
MACHINES="europa.local io.local ganymede.local callisto.local titan.local phobos.local pi-hole.local"
DEAD=0
# all machines alive?
echo "check whether all systems are alive"
for node in $MACHINES
do
if ping -W 1 -c 1 $node > /dev/null
then
echo "$node is alive"
else
DEAD=1
fi
done
if [ "$DEAD" == "1" ]
then
read -p "Do you want to continue anyway? (y/n)" yn
case $yn in
[Yy]* ) echo "Let's go then"
break;;
[Nn]* ) echo "Go fix your stuff and try again"
exit;;
esac
fi
for node in $MACHINES
do
echo -ne "\033]0;updating $node\007"
echo '************************************'
echo " $node"
echo '************************************'
echo connecting ...
ssh $node "uname -a ; sudo apt-get update ; sudo apt-get -y upgrade ; sudo apt-get -y dist-upgrade ; sudo apt-get -y autoremove"
echo '************************************'
echo " $node done"
echo '************************************'
done
echo '************************************'
echo " pihole -up"
echo '************************************'
ssh [email protected] "sudo pihole -up"