]> git.pld-linux.org Git - packages/ipset.git/blame - ipset.init
- unify (from template-kernel-module.spec)
[packages/ipset.git] / ipset.init
CommitLineData
3a06e9e7
PS
1#!/bin/sh
2
3# chkconfig: 2345 07 93
4# description: Automates administration of IP sets.
5# config: /etc/sysconfig/ipset
6
7IPSET_CONFIG=/etc/sysconfig/ipset
8if [ ! -f $IPSET_CONFIG ]; then
9 case "$1" in
10 start|restart|force-reload)
11 exit 0
12 ;;
13 esac
14fi
15
16. /etc/rc.d/init.d/functions
17
18start() {
19 if [ -f $IPSET_CONFIG ]; then
20 show "Applying ipset rules"
b1b044b0 21 /usr/sbin/ipset -X
27b87d46
ER
22 /usr/sbin/ipset -R < $IPSET_CONFIG
23 RETVAL=$?
24 if [ $RETVAL = 0 ]; then
25 ok
26 else
27 fail
28 fi
3a06e9e7
PS
29 touch /var/lock/subsys/ipset
30 fi
31}
32
33stop() {
34 show "Resetting ipset rules"
35 /usr/sbin/ipset -X && ok || fail
36 rm -f /var/lock/subsys/ipset
37}
38
27b87d46 39RETVAL=0
3a06e9e7
PS
40case "$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
b1b044b0 52 exit $?
3a06e9e7
PS
53 ;;
54 save)
55 show "Saving current rules to %s" $IPSET_CONFIG
56 touch $IPSET_CONFIG
57 chmod 600 $IPSET_CONFIG
27b87d46
ER
58 /usr/sbin/ipset -S > $IPSET_CONFIG
59 RETVAL=$?
60 if [ $RETVAL = 0 ]; then
61 ok
62 else
63 fail
64 fi
3a06e9e7
PS
65 ;;
66 *)
67 msg_usage "$0 {start|stop|restart|force-reload|status|save}"
68 exit 3
69esac
27b87d46
ER
70
71exit $RETVAL
This page took 0.197476 seconds and 4 git commands to generate.