-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathnewhaasnode
executable file
·33 lines (28 loc) · 1.03 KB
/
newhaasnode
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
#!/bin/sh
echo "Content-type: text/html"
echo ""
echo "NewHaasNode CGI Output"
echo ""
echo "<pre>"
#env
echo
extra=$(echo "$QUERY_STRING" | sed -n 's/^.*extra=\([^&]*\).*$/\1/p' | sed "s/%20/ /g")
echo "extra is $extra "
newhaasnodeip=$(echo "$QUERY_STRING" | sed -n 's/^.*newhaasnodeip=\([^&]*\).*$/\1/p' | sed "s/%20/ /g")
echo "newhaasnodeip is $newhaasnodeip "
echo
#make /www/allnodes.txt
myip=`/root/script/myip.sh`
newnode="${newhaasnodeip}"
#the db of nodes is only kept on the hub
if [ `echo $myip | cut -f 4 -d . ` -eq 1 ]; then
touch /www/allnodes.txt
#if it's not already in there, add the new node to allnodes.txt
grep -x $newnode /www/allnodes.txt >/dev/null
if [ $? -eq 1 ]; then echo $newnode >> /www/allnodes.txt; fi
cat /www/allnodes.txt
#flush the arp cache of 192.168.2.19, every 10 seconds, for 2 minutes, since 192.168.2.19 has now become some other IP, and we want to be able to add a new node at 192.168.2.19 and have it connect to us
/root/script/arpflush.sh > /www/arpflush.txt &
fi
echo "</pre>"
echo ""