Gentoo Archives: gentoo-commits

From: "Tobias Klausmann (klausman)" <klausman@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in net-analyzer/smokeping/files: smokeping.init.3
Date: Wed, 29 Aug 2012 13:34:56
Message-Id: 20120829133431.16D6320B4B@flycatcher.gentoo.org
1 klausman 12/08/29 13:34:31
2
3 Added: smokeping.init.3
4 Log:
5 Add missing init script. Also, CVS is dumb and should be hated.
6
7 (Portage version: 2.1.11.12/cvs/Linux x86_64)
8
9 Revision Changes Path
10 1.1 net-analyzer/smokeping/files/smokeping.init.3
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-analyzer/smokeping/files/smokeping.init.3?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-analyzer/smokeping/files/smokeping.init.3?rev=1.1&content-type=text/plain
14
15 Index: smokeping.init.3
16 ===================================================================
17 #!/sbin/runscript
18 # Copyright 1999-2012 Gentoo Foundation
19 # Distributed under the terms of the GNU General Public License v2
20
21 extra_commands="${opts} dump reload restore"
22
23 depend() {
24 need net
25 use dns
26 }
27
28 checkconfig() {
29 if [ ! -f "/etc/smokeping/config" ] ; then
30 eerror "You need /etc/smokeping/config to run smokeping!"
31 return 1
32 fi
33 }
34
35 start() {
36 checkconfig || return 1
37
38 if [ ! -d /var/run/smokeping/ ]; then
39 mkdir /var/run/smokeping/
40 fi
41 chown smokeping:smokeping /var/run/smokeping/
42
43 ebegin "Starting smokeping"
44 LC_ALL=C \
45 start-stop-daemon --start --name smokeping \
46 --pidfile /var/run/smokeping/smokeping.pid \
47 --exec /usr/bin/smokeping \
48 --user smokeping:smokeping
49 eend $?
50 }
51
52 stop() {
53 ebegin "Stopping smokeping"
54 start-stop-daemon --stop \
55 --pidfile /var/run/smokeping/smokeping.pid
56 eend $?
57 }
58
59 reload() {
60 ebegin "Reloading smokeping"
61 /usr/bin/smokeping --reload 1>/dev/null 2>&1
62 eend $?
63 }
64
65 dump() {
66 ebegin "Dumping smokeping rrd files to XML for backup or upgrade use"
67 if service_started "${myservice}" ; then
68 eerror "You need to stop smokeping before dumping files!"
69 return 1
70 fi
71 for f in `find /var/lib/smokeping -name '*.rrd' -print` ; do
72 f_xml=`dirname $f`/`basename $f .rrd`.xml
73 rrdtool dump "$f" > "${f_xml}"
74 chown root:0 "${f_xml}"
75 done
76 eend $?
77 }
78
79 restore() {
80 ebegin "Restoring smokeping rrd files from XML dump files"
81 if service_started "${myservice}" ; then
82 eerror "You need to stop smokeping before restoring files!"
83 return 1
84 fi
85 for f in `find /var/lib/smokeping -name '*.xml' -print` ; do
86 f_rrd=`dirname $f`/`basename $f .xml`.rrd
87 mv -f "${f_rrd}" "${f_rrd}.bak"
88 chown root:0 "${f_rrd}.bak"
89 rrdtool restore "$f" "${f_rrd}"
90 chown smokeping:smokeping "${f_rrd}"
91 done
92 eend $?
93 }