]> git.pld-linux.org Git - packages/xtables-addons.git/blob - ipset.init
- geoip-dbpath.patch added; R: iptables >= 1.4.1; works
[packages/xtables-addons.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
23                 RETVAL=$?
24                 if [ $RETVAL = 0 ]; then
25                         ok
26                 else
27                         fail
28                 fi
29                 touch /var/lock/subsys/ipset
30         fi
31 }
32
33 stop() {
34         show "Resetting ipset rules"
35         /usr/sbin/ipset -X && ok || fail
36         rm -f /var/lock/subsys/ipset
37 }
38
39 RETVAL=0
40 case "$1" in
41   start)
42         start
43         ;;
44   stop)
45         stop
46         ;;
47   restart|force-reload)
48         start
49         ;;
50   status)
51         /usr/sbin/ipset -L --sorted --numeric
52         exit $?
53         ;;
54   save)
55         show "Saving current rules to %s" $IPSET_CONFIG
56         touch $IPSET_CONFIG
57         chmod 600 $IPSET_CONFIG
58         /usr/sbin/ipset -S > $IPSET_CONFIG
59         RETVAL=$?
60         if [ $RETVAL = 0 ]; then
61                 ok
62         else
63                 fail
64         fi
65         ;;
66   *)
67         msg_usage "$0 {start|stop|restart|force-reload|status|save}"
68         exit 3
69 esac
70
71 exit $RETVAL
This page took 0.046232 seconds and 3 git commands to generate.