updated on Mon Jan 23 12:00:23 UTC 2012
[aur-mirror.git] / vuurmuur / rc.vuurmuur
blob91eeba7d5eb4ebbc666439d44b3950468f8a8083
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
6 case $1 in
7 start)
8 # initialize
9 stat_busy "Starting Vuurmuur Firewall"
10 STATUS="ok"
12 # check if vuurmuur is configured
13 IFNUM=`/usr/bin/vuurmuur_script --list --interface any | wc -l`
14 if [ $IFNUM = 0 ]; then
15 stat_busy "Please configure Vuurmuur first by defining at least one interface."
16 stat_fail
17 exit 1
20 # load modules
21 . /etc/vuurmuur/modules.conf
22 for MODULE in `echo $MODULES_TO_LOAD`; do
23 /sbin/modprobe $MODULE &>/dev/null
24 if [ $? != 0 ]; then
25 stat_busy "Error when loading module $MODULE. Check log files."
26 stat_fail
27 exit 1
29 done
31 # start vuurmuur daemon
32 if [ ! -f /var/run/vuurmuur.pid ]; then
33 /usr/bin/vuurmuur -l
34 if [ $? != 0 ]; then
35 stat_busy "Error when starting Vuurmuur daemon. Check log files."
36 STATUS="failed"
38 else
39 PID=`cat /var/run/vuurmuur.pid | cut -d " " -f 1`
40 stat_busy "Error when starting Vuurmuur daemon. Already running at pid $PID."
41 STATUS="failed"
44 # start vuurmuur log parsing daemon
45 if [ ! -f /var/run/vuurmuur_log.pid ]; then
46 /usr/bin/vuurmuur_log
47 if [ $? != 0 ]; then
48 stat_busy "Error when starting Vuurmuur log parsing daemon. Check log files."
49 STATUS="failed"
51 else
52 PID=`cat /var/run/vuurmuur_log.pid | cut -d " " -f 1`
53 stat_busy "Error when starting Vuurmuur log parsing daemon. Already running at pid $PID."
54 STATUS="failed"
57 # finalize
58 if [ $STATUS = "ok" ]; then
59 add_daemon vuurmuur
60 stat_done
61 else
62 stat_fail
63 exit 1
67 stop)
68 # initialize
69 stat_busy "Stopping Vuurmuur Firewall"
70 STATUS="ok"
72 # stop vuurmuur log parsing daemon
73 PID=`cat /var/run/vuurmuur_log.pid | cut -d " " -f 1`
74 if [[ ! -z $PID ]] && kill "$PID" &>/dev/null; then
75 rm -f /var/run/vuurmuur_log.pid
76 else
77 stat_busy "Error when stopping Vuurmuur log parsing daemon. Check log files."
78 STATUS="failed"
81 # stop vuurmuur daemon
82 PID=`cat /var/run/vuurmuur.pid | cut -d " " -f 1`
83 if [[ ! -z $PID ]] && kill "$PID" &>/dev/null; then
84 rm -f /var/run/vuurmuur.pid
85 else
86 stat_busy "Error when stopping Vuurmuur daemon. Check log files."
87 STATUS="failed"
90 # finalize
91 if [ $STATUS = "ok" ]; then
92 rm_daemon vuurmuur
93 stat_done
94 else
95 stat_fail
96 exit 1
100 restart)
101 $0 stop
102 $0 start
106 echo "Usage: $0 {start|stop|restart}" >&2
107 exit 1
109 esac
110 exit 0