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
16 NDS_CONF
=/etc
/nodogsplash
/nodogsplash.conf
20 # -s -d 5 runs in background, with level 5 (not so verbose) messages to syslog
21 # -f -d 7 runs in foreground, with level 7 (verbose) debug messages to terminal
22 # N.B.: -f will fail if starting at boot from rcS
26 echo "Starting nodogsplash ... "
27 if $WD_DIR/ndsctl status
2> /dev
/null
; then
28 echo "FAILED: nodogsplash already running"
30 if test_module
&& $WD_DIR/nodogsplash
$OPTIONS; then
31 echo "OK: nodogsplash started"
33 echo "FAILED: nodogsplash exited with non 0 status"
39 echo "Stopping nodogsplash ... "
40 if $WD_DIR/ndsctl status
2> /dev
/null
; then
41 if $WD_DIR/ndsctl stop
; then
42 echo "OK: nodogsplash stopped"
44 echo "FAILED: ndsctl stop exited with non 0 status"
47 echo "FAILED: nodogsplash was not running"
57 ### Test ipt_mark with iptables
59 ($IPT -A FORWARD
-m mark
--mark 2 -j ACCEPT
2>&1) > /dev
/null
61 if [ "$IPTABLES_OK" -eq 0 ]; then
62 ($IPT -D FORWARD
-m mark
--mark 2 -j ACCEPT
2>&1) > /dev
/null
68 ### Test ipt_mac with iptables
70 ($IPT -A INPUT
-m mac
--mac-source 00:00:00:00:00:00 -j ACCEPT
2>&1) > /dev
/null
72 if [ "$IPTABLES_OK" -eq 0 ]; then
73 ($IPT -D INPUT
-m mac
--mac-source 00:00:00:00:00:00 -j ACCEPT
2>&1) > /dev
/null
80 ### Test ipt_IMQ with iptables
82 ($IPT -t mangle
-A PREROUTING
-j IMQ
--todev 0 2>&1) > /dev
/null
84 if [ "$IPTABLES_OK" -eq 0 ]; then
85 ($IPT -t mangle
-D PREROUTING
-j IMQ
--todev 0 2>&1) > /dev
/null
94 (ip link
set imq0 up
2>&1) > /dev
/null
96 (ip link
set imq1 up
2>&1) > /dev
/null
98 if [ "$IMQ0_OK" -eq 0 -a "$IMQ1_OK" -eq 0 ]; then
99 (ip link
set imq0 down
2>&1) > /dev
/null
100 (ip link
set imq1 down
2>&1) > /dev
/null
107 ### Test sch_htb with tc; requires imq0
109 (tc qdisc del dev imq0 root
2>&1) > /dev
/null
110 (tc qdisc add dev imq0 root htb
2>&1) > /dev
/null
112 if [ "$TC_OK" -eq 0 ]; then
113 (tc qdisc del dev imq0 root
2>&1) > /dev
/null
121 ### Find a module on disk
123 EXIST
=$
(find /lib
/modules
/`uname -r` -name $1.
*o
2> /dev
/null
)
124 if [ -n "$EXIST" ]; then
131 ### Test if a module is in memory
132 module_in_memory
() {
133 MODULE
=$
(lsmod |
grep $1 |
awk '{print $1}')
134 if [ "$MODULE" = "$1" ]; then
141 ### Test functionality of a module; load if necessary
143 echo " Testing module $1 $2"
145 if [ $?
-ne 0 ]; then
146 echo " Module $1 $2 needed"
147 echo " Scanning disk for $1 module"
149 if [ $?
-ne 0 ]; then
150 echo " $1 module missing: please install it"
153 echo " $1 exists, trying to load"
154 insmod
$1 $2 > /dev
/null
155 if [ $?
-ne 0 ]; then
156 echo " Error: insmod $1 $2 failed"
159 echo " $1 $2 loaded successfully"
163 echo " $1 is working"
168 echo " Testing required modules"
170 do_module_tests
"ipt_mac"
171 do_module_tests
"ipt_mark"
173 # test for imq modules, only if TrafficControl is enabled in conf
174 if ( grep -q '^[[:space:]]*TrafficControl[[:space:]]\+yes' "$NDS_CONF" ) ; then
175 do_module_tests
"imq" "numdevs=2"
176 do_module_tests
"ipt_IMQ"
177 do_module_tests
"sch_htb"