4 IPT
='/usr/sbin/iptables'
5 WIFIDOG
='/usr/bin/wifidog'
12 pidof
-o %PPID
$daemon_name
17 stat_busy
"Starting $daemon_name daemon"
20 if [ -z "$PID" ]; then
21 [ -f /var
/run
/$daemon_name.pid
] && rm -f /var
/run
/$daemon_name.pid
22 # Test the ipt modules
23 $0 test-module
> /dev
/null
35 echo $
(get_pid
) > /var
/run
/$daemon_name.pid
36 add_daemon
$daemon_name
46 stat_busy
"Stopping $daemon_name daemon"
48 # Ask the process to stop
54 rm -f /var
/run
/$daemon_name.pid
&> /dev
/null
55 rm_daemon
$daemon_name
71 ### Test ipt_mark with iptables
73 IPTABLES_OK
=$
($IPT -A FORWARD
-m mark
--mark 2 -j ACCEPT
2>&1 |
grep "No chain.target.match")
74 if [ -z "$IPTABLES_OK" ]; then
75 $IPT -D FORWARD
-m mark
--mark 2 -j ACCEPT
2>&1
82 ### Test ipt_mac with iptables
84 IPTABLES_OK
=$
($IPT -A INPUT
-m mac
--mac-source 00:00:00:00:00:00 -j ACCEPT
2>&1 |
grep "No chain.target.match")
85 if [ -z "$IPTABLES_OK" ]; then
86 $IPT -D INPUT
-m mac
--mac-source 00:00:00:00:00:00 -j ACCEPT
2>&1
93 ### Find a module on disk
95 echo " Looking for a module on disk"
96 EXIST
=$
(find /lib
/modules
/`uname -r` -name $1.
*o
2>/dev
/null
)
97 if [ -n "$EXIST" ]; then
104 ### Test if a module is in memory
105 module_in_memory
() {
106 MODULE
=$
(lsmod |
grep $1 |
awk '{print $1}')
107 if [ "$MODULE" = "$1" ]; then
114 echo "Testing for iptables modules"
116 echo " Testing ipt_mac"
117 TEST_IPT_MAC
=$
(test_ipt_mac
)
118 if [ "$TEST_IPT_MAC" = "0" ]; then
119 echo " iptables is not working with ipt_mac"
120 echo " Scanning disk for ipt_mac module"
121 TEST_IPT_MAC_MODULE_EXISTS
=$
(module_exists
"ipt_mac")
122 if [ "$TEST_IPT_MAC_MODULE_EXISTS" = "0" ]; then
123 echo " ipt_mac module is missing, please install it (kernel or module)"
126 echo " ipt_mac module exists, trying to load"
127 insmod ipt_mac
> /dev
/null
128 TEST_IPT_MAC_MODULE_MEMORY
=$
(module_in_memory
"ipt_mac")
129 if [ "$TEST_IPT_MAC_MODULE_MEMORY" = "0" ]; then
130 echo " Error: ipt_mac not loaded"
133 echo " ipt_mac loaded sucessfully"
137 echo " ipt_mac module is working"
140 echo " Testing ipt_mark"
141 TEST_IPT_MARK
=$
(test_ipt_mark
)
142 if [ "$TEST_IPT_MARK" = "0" ]; then
143 echo " iptables is not working with ipt_mark"
144 echo " Scanning disk for ipt_mark module"
145 TEST_IPT_MARK_MODULE_EXISTS
=$
(module_exists
"ipt_mark")
146 if [ "$TEST_IPT_MARK_MODULE_EXISTS" = "0" ]; then
147 echo " iptables ipt_mark module missing, please install it (kernel or module)"
150 echo " ipt_mark module exists, trying to load"
152 TEST_IPT_MARK_MODULE_MEMORY
=$
(module_in_memory
"ipt_mark")
153 if [ "$TEST_IPT_MARK_MODULE_MEMORY" = "0" ]; then
154 echo " Error: ipt_mark not loaded"
157 echo " ipt_mark loaded sucessfully"
161 echo " ipt_mark module is working"
166 echo "usage: $0 {start|stop|restart|status|debug|test-module}"
171 # vim:set ts=2 sw=2 et: