Ok - I think this will load the iptables rules on boot
[invirt/packages/invirt-web.git] / debian / sipb-xen-iptables.init
1 #! /bin/sh
2 ### BEGIN INIT INFO
3 # Provides:          sipb-xen-iptables
4 # Required-Start:    $local_fs $remote_fs
5 # Required-Stop:     $local_fs $remote_fs
6 # Default-Start:     2 3 4 5
7 # Default-Stop:      0 1 6
8 # Short-Description: sipb-xen iptables rules
9 # Description:       
10 ### END INIT INFO
11
12 # Author: SIPB Xen Project <sipb-xen@mit.edu>
13
14 # Do NOT "set -e"
15
16 # PATH should only include /usr/* if it runs after the mountnfs.sh script
17 PATH=/sbin:/usr/sbin:/bin:/usr/bin
18 DESC="Load the sipb-xen iptables rules"
19 NAME=sipb-xen-iptables
20 RULES=/usr/local/share/sipb-xen-iptables/iptables.rules
21
22 # Read configuration variable file if it is present
23 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
24
25 # Load the VERBOSE setting and other rcS variables
26 . /lib/init/vars.sh
27
28 # Define LSB log_* functions.
29 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
30 . /lib/lsb/init-functions
31
32 #
33 # Function that starts the daemon/service
34 #
35 do_start()
36 {
37         # Return
38         #   0 if daemon has been started
39         #   1 if daemon was already running
40         #   2 if daemon could not be started
41         /sbin/iptables-restore < $RULES
42 }
43
44 #
45 # Function that stops the daemon/service
46 #
47 do_stop()
48 {
49         # Return
50         #   0 if daemon has been stopped
51         #   1 if daemon was already stopped
52         #   2 if daemon could not be stopped
53         #   other if a failure occurred
54         return 0
55 }
56
57 case "$1" in
58   start)
59         [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
60         do_start
61         case "$?" in
62                 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
63                 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
64         esac
65         ;;
66   stop)
67         [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
68         do_stop
69         case "$?" in
70                 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
71                 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
72         esac
73         ;;
74   #reload|force-reload)
75         #
76         # If do_reload() is not implemented then leave this commented out
77         # and leave 'force-reload' as an alias for 'restart'.
78         #
79         #log_daemon_msg "Reloading $DESC" "$NAME"
80         #do_reload
81         #log_end_msg $?
82         #;;
83   restart|force-reload)
84         #
85         # If the "reload" option is implemented then remove the
86         # 'force-reload' alias
87         #
88         log_daemon_msg "Restarting $DESC" "$NAME"
89         do_stop
90         case "$?" in
91           0|1)
92                 do_start
93                 case "$?" in
94                         0) log_end_msg 0 ;;
95                         1) log_end_msg 1 ;; # Old process is still running
96                         *) log_end_msg 1 ;; # Failed to start
97                 esac
98                 ;;
99           *)
100                 # Failed to stop
101                 log_end_msg 1
102                 ;;
103         esac
104         ;;
105   *)
106         #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
107         echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
108         exit 3
109         ;;
110 esac
111
112 :