Gentoo Archives: gentoo-commits

From: "Peter Volkov (pva)" <pva@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in net-firewall/ipset/files: ipset.initd
Date: Sun, 02 Oct 2011 13:08:05
Message-Id: 20111002130753.7EC8A2004B@flycatcher.gentoo.org
1 pva 11/10/02 13:07:53
2
3 Added: ipset.initd
4 Log:
5 Drop confusing message about netlink.patch, bug #382221 by John Brendler. Add init script by Andrew Savchenko, bug #181045 by Caleb Cushing.
6
7 (Portage version: 2.1.10.20/cvs/Linux x86_64)
8
9 Revision Changes Path
10 1.1 net-firewall/ipset/files/ipset.initd
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-firewall/ipset/files/ipset.initd?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-firewall/ipset/files/ipset.initd?rev=1.1&content-type=text/plain
14
15 Index: ipset.initd
16 ===================================================================
17 #!/sbin/runscript
18 # Copyright 1999-2011 Gentoo Foundation
19 # Distributed under the terms of the GNU General Public License v2
20 # $Header: /var/cvsroot/gentoo-x86/net-firewall/ipset/files/ipset.initd,v 1.1 2011/10/02 13:07:53 pva Exp $
21
22 opts="save"
23
24 depend() {
25 before iptables ip6tables
26 use logger
27 }
28
29 checkconfig() {
30 if [ ! -f "${IPSET_SAVE}" ] ; then
31 eerror "Not starting ${SVCNAME}. First create some rules then run:"
32 eerror "/etc/init.d/${SVCNAME} save"
33 return 1
34 fi
35 return 0
36 }
37
38 start() {
39 checkconfig || return 1
40 ebegin "Loading ipset session"
41 ipset restore < "${IPSET_SAVE}"
42 eend $?
43 }
44
45 stop() {
46 # check if there are any references to current sets
47 if ! ipset list | gawk '($1 == "References:" && $2 > 0) { exit 1 }'; then
48 eerror "ipset is in use, can't stop"
49 return 1
50 fi
51
52 if [ "${SAVE_ON_STOP}" = "yes" ] ; then
53 save || return 1
54 fi
55
56 ebegin "Removing kernel IP sets"
57 ipset destroy
58 eend $?
59 }
60
61 save() {
62 ebegin "Saving ipset session"
63 touch "${IPSET_SAVE}"
64 chmod 0600 "${IPSET_SAVE}"
65 ipset save > "${IPSET_SAVE}"
66 eend $?
67 }