1 #!/bin/sh /etc/rc.common
3 # description: Startup/shutdown script for nodogsplash captive portal
7 # (Based on wifidog startup script
10 # Comment by that author: Could be better, but it's working as expected)
14 IPT=/usr/sbin/iptables
19 # -s -d 5 runs in background, with level 5 (not so verbose) messages to syslog
20 # -f -d 7 runs in foreground, with level 7 (verbose) debug messages to terminal
21 # N.B.: -f will fail if starting at boot from rcS
25 echo "Starting nodogsplash ... "
26 if $WD_DIR/ndsctl status 2> /dev/null; then
27 echo "FAILED: nodogsplash already running"
29 if test_module && $WD_DIR/nodogsplash $OPTIONS; then
30 echo "OK: nodogsplash started"
32 echo "FAILED: nodogsplash exited with non 0 status"
38 echo "Stopping nodogsplash ... "
39 if $WD_DIR/ndsctl status 2> /dev/null; then
40 if $WD_DIR/ndsctl stop; then
41 echo "OK: nodogsplash stopped"
43 echo "FAILED: ndsctl stop exited with non 0 status"
46 echo "FAILED: nodogsplash was not running"
56 ### Test ipt_mark with iptables
58 ($IPT -A FORWARD -m mark --mark 2 -j ACCEPT 2>&1) > /dev/null
60 if [ "$IPTABLES_OK" -eq 0 ]; then
61 ($IPT -D FORWARD -m mark --mark 2 -j ACCEPT 2>&1) > /dev/null
67 ### Test ipt_mac with iptables
69 ($IPT -A INPUT -m mac --mac-source 00:00:00:00:00:00 -j ACCEPT 2>&1) > /dev/null
71 if [ "$IPTABLES_OK" -eq 0 ]; then
72 ($IPT -D INPUT -m mac --mac-source 00:00:00:00:00:00 -j ACCEPT 2>&1) > /dev/null
79 ### Test ipt_IMQ with iptables
81 ($IPT -t mangle -A PREROUTING -j IMQ --todev 0 2>&1) > /dev/null
83 if [ "$IPTABLES_OK" -eq 0 ]; then
84 ($IPT -t mangle -D PREROUTING -j IMQ --todev 0 2>&1) > /dev/null
93 (ip link set imq0 up 2>&1) > /dev/null
95 (ip link set imq1 up 2>&1) > /dev/null
97 if [ "$IMQ0_OK" -eq 0 -a "$IMQ1_OK" -eq 0 ]; then
98 (ip link set imq0 down 2>&1) > /dev/null
99 (ip link set imq1 down 2>&1) > /dev/null
106 ### Test sch_htb with tc; requires imq0
108 (tc qdisc del dev imq0 root 2>&1) > /dev/null
109 (tc qdisc add dev imq0 root htb 2>&1) > /dev/null
111 if [ "$TC_OK" -eq 0 ]; then
112 (tc qdisc del dev imq0 root 2>&1) > /dev/null
120 ### Find a module on disk
122 EXIST=$(find /lib/modules/`uname -r` -name $1.*o 2> /dev/null)
123 if [ -n "$EXIST" ]; then
130 ### Test if a module is in memory
131 module_in_memory () {
132 MODULE=$(lsmod | grep $1 | awk '{print $1}')
133 if [ "$MODULE" = "$1" ]; then
140 ### Test functionality of a module; load if necessary
142 echo " Testing module $1 $2"
144 if [ $? -ne 0 ]; then
145 echo " Module $1 $2 needed"
146 echo " Scanning disk for $1 module"
148 if [ $? -ne 0 ]; then
149 echo " $1 module missing: please install it"
152 echo " $1 exists, trying to load"
153 insmod $1 $2 > /dev/null
154 if [ $? -ne 0 ]; then
155 echo " Error: insmod $1 $2 failed"
158 echo " $1 $2 loaded successfully"
162 echo " $1 is working"
167 echo " Testing required modules"
169 do_module_tests "ipt_mac"
170 do_module_tests "ipt_mark"
171 # if not using traffic control,
172 # you can comment out the following 3 lines:
173 do_module_tests "imq" "numdevs=2"
174 do_module_tests "ipt_IMQ"
175 do_module_tests "sch_htb"