This repository has been archived by the owner on Jan 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
access.sh
75 lines (70 loc) · 1.77 KB
/
access.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
68
69
70
71
72
73
74
75
#!/bin/sh
#
#exec >/tmp/access.log 2>&1
#set -x
killaccessdaemons() {
if [ -f /var/run/telnetd.pid ]; then
kill `cat /var/run/telnetd.pid`
rm /var/run/telnetd.pid
fi
if [ -f /var/run/ftpd.pid ]; then
kill `cat /var/run/ftpd.pid`
rm /var/run/ftpd.pid
fi
}
# start telnet & ftp daemons
startaccessdaemons() {
if [ ! -f /var/run/telnetd.pid ] || [ ! -d /proc/`cat /var/run/telnetd.pid` ]; then
telnetd -F -l /bin/bash &
echo $! >/var/run/telnetd.pid
fi
if [ ! -f /var/run/ftpd.pid ] || [ ! -d /proc/`cat /var/run/ftpd.pid` ]; then
tcpsvd -vE 0.0.0.0 21 ftpd /mnt/sd/DCIM/ &
echo $! >/var/run/ftpd.pid
fi
}
# kill the autoupload process
killautoupload() {
if [ -f /var/run/autoupload.pid ]; then
kill `cat /var/run/autoupload.pid`
rm /var/run/autoupload.pid
fi
}
# start autoupload
startautoupload() {
if [ ! -f /var/run/autoupload.pid ] || [ ! -d /proc/`cat /var/run/autoupload.pid` ]; then
:
$autoup $CONFIG_INI /var/run/autoupload.pid >/tmp/autoupload.log 2>&1 &
# $autoup $CONFIG_INI /var/run/autoupload.pid &
fi
}
apssid=$(iwconfig $interface \
| $bbext grep ESSID: \
| $bbext sed 's/^.*ESSID:"\([^"]\+\)".*$/\1/')
# Identify current router
ping -c 1 $router >/dev/null 2>&1
routerMAC=$($bbext arp -n $router | $bbext awk '{print $4}')
#
# Handle DHCP event
#
case "$1" in
deconfig)
killaccessdaemons
killautoupload
;;
bound)
echo "$apssid:$router:$routerMAC" >> /tmp/netid.log
if [ x"$apssid:$router:$routerMAC" = x"$cfg_ssid:$cfg_router:$cfg_router_mac" ] ; then
# Trusted network - run open access
startaccessdaemons
startautoupload
else
# Non trusted networks
killaccessdaemons
killautoupload
fi
;;
renew)
# Do nothing, no change
;;
esac