]> git.pld-linux.org Git - packages/ipset.git/blob - ipset.init
- fix typos, exit codes, restart flow.
[packages/ipset.git] / ipset.init
1 #!/bin/sh
2
3 # chkconfig: 2345 07 93
4 # description: Automates administration of IP sets.
5 # config: /etc/sysconfig/ipset
6
7 IPSET_CONFIG=/etc/sysconfig/ipset
8 if [ ! -f $IPSET_CONFIG ]; then
9         case "$1" in
10         start|restart|force-reload)
11                 exit 0
12         ;;
13         esac
14 fi
15
16 . /etc/rc.d/init.d/functions
17
18 start() {
19         if [ -f $IPSET_CONFIG ]; then
20                 show "Applying ipset rules"
21                 /usr/sbin/ipset -X
22                 /usr/sbin/ipset -R < $IPSET_CONFIG && ok || fail
23                 touch /var/lock/subsys/ipset
24         fi
25 }
26
27 stop() {
28         show "Resetting ipset rules"
29         /usr/sbin/ipset -X && ok || fail
30         rm -f /var/lock/subsys/ipset
31 }
32
33 case "$1" in
34   start)
35         start
36         exit $?
37         ;;
38   stop)
39         stop
40         exit $?
41         ;;
42   restart|force-reload)
43         start
44         exit $?
45         ;;
46   status)
47         /usr/sbin/ipset -L --sorted --numeric
48         exit $?
49         ;;
50   save)
51         show "Saving current rules to %s" $IPSET_CONFIG
52         touch $IPSET_CONFIG
53         chmod 600 $IPSET_CONFIG
54         /usr/sbin/ipset -S > $IPSET_CONFIG && ok || fail
55         exit $?
56         ;;
57   *)
58         msg_usage "$0 {start|stop|restart|force-reload|status|save}"
59         exit 3
60 esac
This page took 0.091173 seconds and 4 git commands to generate.