-
Notifications
You must be signed in to change notification settings - Fork 2
/
update.sh
executable file
·31 lines (23 loc) · 772 Bytes
/
update.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
#!/usr/bin/env bash
# This script requires sshpass and parallel
# OSX: https://gist.github.com/arunoda/7790979
passwd="bwcon"
export SSHPASS="${passwd}"
export SERVICE="bw_exporter"
if [ -e "./workers.txt" ] ; then
WORKERS=`cat ./workers.txt`
fi
if [ -z "${WORKERS}" ] ; then
echo "Need some workers to update!"
exit 1
fi
dowork() {
ipaddr=$1
echo "----------- ${ipaddr} start"
sshpass -e ssh -o StrictHostKeychecking=no root@$ipaddr "systemctl stop ${SERVICE}"
sshpass -e scp -o StrictHostKeychecking=no ${SERVICE} root@$ipaddr:/usr/bin
sshpass -e ssh -o StrictHostKeychecking=no root@$ipaddr "chmod ugo+x /usr/bin/${SERVICE}; systemctl start ${SERVICE};"
echo "----------- ${ipaddr} finish"
}
export -f dowork
parallel --no-notice dowork ::: ${WORKERS}