-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·32 lines (25 loc) · 966 Bytes
/
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
#!/usr/bin/env bash
# This script requires sshpass and parallel
#
passwd="bwcon"
export SSHPASS="${passwd}"
export SERVICE="bam_agent"
export BINARY="${SERVICE}-linux-arm"
export INSTALL_DIR="/usr/bin"
if [ -e "./workers.txt" ] ; then
WORKERS=`cat ./workers.txt`
fi
if [ -z "${WORKERS}" ] ; then
echo "Need some workers to install to!"
exit 1
fi
dowork() {
ipaddr=$1
echo "----------- ${ipaddr} start"
sshpass -e scp -o StrictHostKeychecking=no ${BINARY}.gz root@$ipaddr:${INSTALL_DIR}
sshpass -e scp -o StrictHostKeychecking=no bam_agent.service root@$ipaddr:/etc/systemd/system
sshpass -e ssh -o StrictHostKeychecking=no root@$ipaddr "systemctl daemon-reload; systemctl stop ${SERVICE}; rm -f ${INSTALL_DIR}/${BINARY}; gunzip ${INSTALL_DIR}/${BINARY}.gz; chmod ugo+x ${INSTALL_DIR}/${BINARY}; systemctl enable ${SERVICE}; systemctl start ${SERVICE}"
echo "----------- ${ipaddr} finish"
}
export -f dowork
parallel --no-notice dowork ::: ${WORKERS}