]> git.pld-linux.org Git - packages/ipset.git/blob - ipset.init
- initial revision.
[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 -R $IPSET_CONFIG && ok || fail
22                 touch /var/lock/subsys/ipset
23         fi
24 }
25
26 stop() {
27         show "Resetting ipset rules"
28         /usr/sbin/ipset -X && ok || fail
29         rm -f /var/lock/subsys/ipset
30 }
31
32 case "$1" in
33   start)
34         start
35         ;;
36   stop)
37         stop
38         ;;
39   restart|force-reload)
40         start
41         ;;
42   status)
43         /usr/sbin/ipset -L --sorted --numeric
44         ;;
45   save)
46         show "Saving current rules to %s" $IPSET_CONFIG
47         touch $IPSET_CONFIG
48         chmod 600 $IPSET_CONFIG
49         /usr/sbin/ipset -S > $IPSET_CONFIG  2>/dev/null && ok || fail
50         ;;
51   *)
52         msg_usage "$0 {start|stop|restart|force-reload|status|save}"
53         exit 3
54 esac
55
56 exit 0
This page took 0.133186 seconds and 4 git commands to generate.