~fkooman/vpn-maint-scripts

ref: fa76be690f6ea0c86e4707d97c9c4c3779ee8426 vpn-maint-scripts/bin/vpn-maint-update-system-multi -rwxr-xr-x 1.4 KiB
fa76be69François Kooman use variable for server.list 10 months ago
                                                                                
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
#!/bin/sh

SERVER_LIST_FILE=server.list
REBOOT_TIME_CONTROLLER=180

if [ ! -f "${SERVER_LIST_FILE}" ]; then
    echo "\"${SERVER_LIST_FILE}\" not found!"
    exit 1
fi

# import the "server.list" file
. ./${SERVER_LIST_FILE}

if [ -z "${CONTROLLER}" ]; then
    echo "\"CONTROLLER\" not set in \"${SERVER_LIST_FILE}\""
    exit 1
fi

if [ -z "${NODES}" ]; then
    echo "\"NODES\" not set in \"${SERVER_LIST_FILE}\""
    exit 1
fi

# stop all nodes
for NODE in ${NODES}
do
    echo "Stopping NODE ${NODE}..."
    ssh -t "${NODE}" "/usr/bin/tmux new '/usr/bin/sudo /usr/sbin/vpn-maint-stop-node'"
done

# update controller
echo "Updating CONTROLLER ${CONTROLLER}..."

ssh -t "${CONTROLLER}" "/usr/bin/tmux new '/usr/bin/sudo /usr/sbin/vpn-maint-update-controller -y'"
if [ "--reboot" = "${1}" ]; then
echo "Rebooting CONTROLLER ${CONTROLLER}..."
    ssh "${CONTROLLER}" "/usr/bin/sudo /sbin/reboot"
    echo "Waiting ${REBOOT_TIME_CONTROLLER}s for CONTROLLER ${CONTROLLER} to come back..."
    sleep ${REBOOT_TIME_CONTROLLER}
fi

# update nodes
for NODE in ${NODES}
do
    echo "Updating NODE ${NODE}..."
    ssh -t "${NODE}" "/usr/bin/tmux new '/usr/bin/sudo /usr/sbin/vpn-maint-update-node'"
    if [ "--reboot" = "${1}" ]; then
        echo "Rebooting NODE ${NODE}..."
        ssh "${NODE}" "/usr/bin/sudo /sbin/reboot"
    else
        echo "Starting NODE ${NODE}..."
        ssh -t "${NODE}" "/usr/bin/tmux new '/usr/bin/sudo /usr/sbin/vpn-maint-start-node'"
    fi
done