aboutsummaryrefslogtreecommitdiffstats
path: root/main/smokeping/smokeping.initd
blob: a497c7d132a938109202d89eacb04158e5ab6afd (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
57
58
59
60
61
62
63
64
65
66
67
68
#!/sbin/openrc-run
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

extra_started_commands="reload"
extra_stopped_commands="dump restore"

depend() {
	need net
	use dns
	after firewall
}

checkconfig() {
	if [ ! -f "/etc/smokeping/config" ] ; then
		eerror "You need /etc/smokeping/config to run smokeping!"
		return 1
	fi
}

start() {
	checkconfig || return 1
	checkpath --directory --owner smokeping:smokeping /var/run/smokeping

	ebegin "Starting smokeping"
	LC_ALL=C \
	start-stop-daemon --start --name smokeping \
		--pidfile /var/run/smokeping/smokeping.pid \
		--exec /usr/bin/smokeping \
		--user smokeping:smokeping \
		-- --config=/etc/smokeping/config
	eend $?
}

stop() {
	ebegin "Stopping smokeping"
	start-stop-daemon --stop \
		--pidfile /var/run/smokeping/smokeping.pid
	eend $?
}

reload() {
	ebegin "Reloading smokeping"
	/usr/bin/smokeping --config=/etc/smokeping/config --reload 1>/dev/null 2>&1
	eend $?
}

dump() {
	ebegin "Dumping smokeping rrd files to XML for backup or upgrade use"
	for f in `find /var/lib/smokeping -name '*.rrd' -print` ; do
		f_xml=`dirname $f`/`basename $f .rrd`.xml
		rrdtool dump "$f" > "${f_xml}"
		chown root:0 "${f_xml}"
	done
	eend $?
}

restore() {
	ebegin "Restoring smokeping rrd files from XML dump files"
	for f in `find /var/lib/smokeping -name '*.xml' -print` ; do
		f_rrd=`dirname $f`/`basename $f .xml`.rrd
		mv -f "${f_rrd}" "${f_rrd}.bak"
		chown root:0 "${f_rrd}.bak"
		rrdtool restore "$f" "${f_rrd}"
		chown smokeping:smokeping "${f_rrd}"
	done
	eend $?
}