updated on Wed Jan 11 12:00:27 UTC 2012
[aur-mirror.git] / ipset-init / ipset
blobbe1b9fbbd17a1c50b38b70f4ae92eea063750d6d
1 #!/bin/bash
3 # source application-specific settings
4 [ -f /etc/conf.d/ipset ] && . /etc/conf.d/ipset
6 # Set defaults if settings are missing
7 [ -z "$IPSET_CONF" ] && IPSET_CONF=/etc/ipset/ipset.rules
9 . /etc/rc.conf
10 . /etc/rc.d/functions
12 case "$1" in
13 start)
14 if [ ! -f "$IPSET_CONF" ]; then
15 echo "Cannot load ipset rules: $IPSET_CONF is missing!" >&2
16 exit 1
18 stat_busy "Starting IP Sets"
19 if ck_daemon ipset; then
20 /usr/sbin/ipset restore < $IPSET_CONF
21 if [ $? -gt 0 ]; then
22 stat_fail
23 else
24 add_daemon ipset
25 stat_done
27 else
28 stat_fail
31 stop)
32 stat_busy "Stopping IP Sets"
33 if ! ck_daemon ipset; then
34 /usr/sbin/ipset destroy
35 if [ $? -gt 0 ]; then
36 stat_fail
37 else
38 rm_daemon ipset
39 stat_done
41 else
42 stat_fail
45 restart)
46 $0 stop
47 $0 start
49 save)
50 stat_busy "Saving IP Sets"
51 /usr/sbin/ipset save > $IPSET_CONF
52 if [ $? -gt 0 ]; then
53 stat_fail
54 else
55 stat_done
59 echo "usage: $0 {start|stop|restart|save}"
60 esac
61 exit 0