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)
18 IPT
=/usr
/sbin
/iptables
20 NDS_CONF
=/etc
/nodogsplash
/nodogsplash.conf
21 # -s -d 5 runs in background, with level 5 (not so verbose) messages to syslog
22 # -f -d 7 runs in foreground, with level 7 (verbose) debug messages to terminal
28 procd_set_param
command /usr
/bin
/nodogsplash
$OPTIONS
29 procd_set_param respawn
32 logger
-s -t nodogsplash
-p daemon.error
"nodogsplash is missing some kernel modules"
37 # nodogsplash doesn't exit fast enought, when procd terminates it.
38 # otherwise procd will restart nodogsplash twice. first time starting nodogsplash fails, second time it succeeds
48 ### Test ipt_mark with iptables
50 ($IPT -A FORWARD
-m mark
--mark 2 -j ACCEPT
2>&1) > /dev
/null
52 if [ "$IPTABLES_OK" -eq 0 ]; then
53 ($IPT -D FORWARD
-m mark
--mark 2 -j ACCEPT
2>&1) > /dev
/null
59 ### Test ipt_mac with iptables
61 ($IPT -A INPUT
-m mac
--mac-source 00:00:00:00:00:00 -j ACCEPT
2>&1) > /dev
/null
63 if [ "$IPTABLES_OK" -eq 0 ]; then
64 ($IPT -D INPUT
-m mac
--mac-source 00:00:00:00:00:00 -j ACCEPT
2>&1) > /dev
/null
71 ### Test ipt_IMQ with iptables
73 ($IPT -t mangle
-A PREROUTING
-j IMQ
--todev 0 2>&1) > /dev
/null
75 if [ "$IPTABLES_OK" -eq 0 ]; then
76 ($IPT -t mangle
-D PREROUTING
-j IMQ
--todev 0 2>&1) > /dev
/null
85 (ip link
set imq0 up
2>&1) > /dev
/null
87 (ip link
set imq1 up
2>&1) > /dev
/null
89 if [ "$IMQ0_OK" -eq 0 -a "$IMQ1_OK" -eq 0 ]; then
90 (ip link
set imq0 down
2>&1) > /dev
/null
91 (ip link
set imq1 down
2>&1) > /dev
/null
98 ### Test sch_htb with tc; requires imq0
100 (tc qdisc del dev imq0 root
2>&1) > /dev
/null
101 (tc qdisc add dev imq0 root htb
2>&1) > /dev
/null
103 if [ "$TC_OK" -eq 0 ]; then
104 (tc qdisc del dev imq0 root
2>&1) > /dev
/null
112 ### Find a module on disk
114 EXIST
=$
(find /lib
/modules
/`uname -r` -name $1.
*o
2> /dev
/null
)
115 if [ -n "$EXIST" ]; then
122 ### Test if a module is in memory
123 module_in_memory
() {
124 MODULE
=$
(lsmod |
grep $1 |
awk '{print $1}')
125 if [ "$MODULE" = "$1" ]; then
132 ### Test functionality of a module; load if necessary
134 echo " Testing module $1 $2"
136 if [ $?
-ne 0 ]; then
137 echo " Module $1 $2 needed"
138 echo " Scanning disk for $1 module"
140 if [ $?
-ne 0 ]; then
141 echo " $1 module missing: please install it"
144 echo " $1 exists, trying to load"
145 insmod
$1 $2 > /dev
/null
146 if [ $?
-ne 0 ]; then
147 echo " Error: insmod $1 $2 failed"
150 echo " $1 $2 loaded successfully"
154 echo " $1 is working"
159 echo " Testing required modules"
161 do_module_tests
"ipt_mac"
162 do_module_tests
"ipt_mark"
164 # test for imq modules, only if TrafficControl is enabled in conf
165 if ( grep -q -E '^[[:space:]]*TrafficControl[[:space:]]+(yes|true|1)' "$NDS_CONF" ) ; then
166 do_module_tests
"imq" "numdevs=2"
167 do_module_tests
"ipt_IMQ"
168 do_module_tests
"sch_htb"