1 contributor
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
set -e
test -n "$1"
nc=/bin/nc
wakeonlan=/usr/bin/wakeonlan
ssh=/usr/bin/ssh
conf=$HOME/.config/upgrade_hosts.conf
test -r $conf
eval $(/usr/local/bin/readconf --conf=$conf --array=user --array=identity -s $1)
test -n "$ip"
test -n "$port"
test -n "${identity[1]}"
if test -n "$lock"; then
test -f $lock && exit
fi
alive=0
if $nc -zw2 $ip $port; then alive=1; fi
if ! $alive; then
$wakeonlan -i $ip $mac
sleep 10
$nc -zw2 $ip $port
fi
$ssh -i ${identity[1]} ${user[1]:-root}@$ip
sleep 60
if ! $alive && test -n "${identity[2]}"; then
$ssh -i ${identity[2]} ${user[2]:-root}@$ip
fi