-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestart_my_wifi.sh
executable file
·67 lines (54 loc) · 1.4 KB
/
restart_my_wifi.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env sh
testbed=$1
rate=$2
channel=$3
power=$4
prince_conf=$5
nodes=$6
start_time=$7
opkg_path=`which opkg`
if [ -z "$opkg_path" ]; then
host_name=`hostname | cut -d'.' -f 1`
else
host_name=`uci get system.@system[0].hostname`
echo "WARNING: Wi-Fi restart on OpenWRT not implemented yet"
exit 1
fi
ip_addr=`cat /etc/hosts | grep "pop-$host_name\$" | cut -d' ' -f 1`
restart_cmd1="$(pwd)/setup-interfaces.sh ${rate} ${channel} ${power}"
restart_cmd2="$(pwd)/start-olsr.sh ${testbed}"
restart_cmd3=""
if [ "${prince_conf}" = "none" ]; then
restart_cmd3="$(pwd)/start-prince.sh ${prince_conf}"
fi
for i in $(echo $nodes | sed -e "s/,/ /g")
do
node=`echo $i | cut -d'@' -f 1`
time=`echo $i | cut -d'@' -f 2`
secs1=`echo $time | cut -d'.' -f 1`
ms1=`echo $time | cut -d'.' -f 2`
unix_time1=$(($start_time + $secs1))
if [ $ms -lt 997 ]; then
secs2=$secs1
ms2=$(($ms1 + 2))
else
secs2=$(($secs1 + 1))
ms2=000
fi
unix_time2=$(($start_time + $secs2))
if [ $ms2 -lt 997 ]; then
secs3=$secs2
ms3=$(($ms2 + 2))
else
secs3=$(($secs2 + 1))
ms3=000
fi
unix_time3=$(($start_time + $secs3))
if [ "$host_name" = "$node" ]; then
echo "runat $unix_time1 $ms1 '$restart_cmd1'" | at now &> /dev/null
echo "runat $unix_time2 $ms2 '$restart_cmd2'" | at now &> /dev/null
if [ ! -z "${restart_cmd3}" ]; then
echo "runat $unix_time3 $ms3 '$restart_cmd3'" | at now &> /dev/null
fi
fi
done