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 $0 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"
54 ### Test ipt_mark with iptables
56 ($IPT -A FORWARD
-m mark
--mark 2 -j ACCEPT
2>&1) > /dev
/null
58 if [ "$IPTABLES_OK" -eq 0 ]; then
59 ($IPT -D FORWARD
-m mark
--mark 2 -j ACCEPT
2>&1) > /dev
/null
65 ### Test ipt_mac with iptables
67 ($IPT -A INPUT
-m mac
--mac-source 00:00:00:00:00:00 -j ACCEPT
2>&1) > /dev
/null
69 if [ "$IPTABLES_OK" -eq 0 ]; then
70 ($IPT -D INPUT
-m mac
--mac-source 00:00:00:00:00:00 -j ACCEPT
2>&1) > /dev
/null
77 ### Test ipt_IMQ with iptables
79 ($IPT -t mangle
-A PREROUTING
-j IMQ
--todev 0 2>&1) > /dev
/null
81 if [ "$IPTABLES_OK" -eq 0 ]; then
82 ($IPT -t mangle
-D PREROUTING
-j IMQ
--todev 0 2>&1) > /dev
/null
91 (ip link
set imq0 up
2>&1) > /dev
/null
93 (ip link
set imq1 up
2>&1) > /dev
/null
95 if [ "$IMQ0_OK" -eq 0 -a "$IMQ1_OK" -eq 0 ]; then
96 (ip link
set imq0 down
2>&1) > /dev
/null
97 (ip link
set imq1 down
2>&1) > /dev
/null
104 ### Test sch_htb with tc; requires imq0
106 (tc qdisc del dev imq0 root
2>&1) > /dev
/null
107 (tc qdisc add dev imq0 root htb
2>&1) > /dev
/null
109 if [ "$TC_OK" -eq 0 ]; then
110 (tc qdisc del dev imq0 root
2>&1) > /dev
/null
118 ### Find a module on disk
120 EXIST
=$
(find /lib
/modules
/`uname -r` -name $1.
*o
2> /dev
/null
)
121 if [ -n "$EXIST" ]; then
128 ### Test if a module is in memory
129 module_in_memory
() {
130 MODULE
=$
(lsmod |
grep $1 |
awk '{print $1}')
131 if [ "$MODULE" = "$1" ]; then
138 ### Test functionality of a module; load if necessary
140 echo " Testing module $1 $2"
142 if [ $?
-ne 0 ]; then
143 echo " Module $1 $2 needed"
144 echo " Scanning disk for $1 module"
146 if [ $?
-ne 0 ]; then
147 echo " $1 module missing: please install it"
150 echo " $1 exists, trying to load"
151 insmod
$1 $2 > /dev
/null
152 if [ $?
-ne 0 ]; then
153 echo " Error: insmod $1 $2 failed"
156 echo " $1 $2 loaded successfully"
160 echo " $1 is working"
165 echo " Testing required modules"
167 do_module_tests
"ipt_mac"
168 do_module_tests
"ipt_mark"
169 # if not using traffic control,
170 # you can comment out the following 3 lines:
171 do_module_tests
"imq" "numdevs=2"
172 do_module_tests
"ipt_IMQ"
173 do_module_tests
"sch_htb"