summaryrefslogtreecommitdiff
blob: 4670db55aa5fb5f8b736fca290314b73604a6fb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/sbin/runscript
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header$

opts="save reload"

ipset_bin="/sbin/ipset"
ipset_save=${IPSET_SAVE}
depend() {
	before iptables net
#	use logger
}

checkconfig() {
	if [ ! -f ${ipset_save} ] ; then
		eerror "Not starting ipset.  First create some rules then run:"
		eerror "/etc/init.d/ipset save"
		return 1
	fi
	return 0
}

start() {
	checkconfig || return 1
	ebegin "Loading ipset state"
	${ipset_bin} --restore ${SAVE_RESTORE_OPTIONS} < "${ipset_save}"
	eend $?
}

stop() {
	if [ "${SAVE_ON_STOP}" = "yes" ] ; then
		save || return 1
	fi
	ebegin "Stopping ipset (cleaning all ipsets)"
	${ipset_bin} -F
	${ipset_bin} -X
	eend $?
}

reload() {
	ebegin "Flushing ipsets"
	${ipset_bin} -F
	${ipset_bin} -X
	eend $?

	start
}

save() {
	ebegin "Saving ipsets state"
	touch "${ipset_save}"
	chmod 0600 "${ipset_save}"
	${ipset_bin} --save > "${ipset_save}"
	eend $?
}