diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2010-08-02 06:16:46 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2010-08-02 06:18:01 +0000 |
commit | 81bb6f7ad5f16cf1d7361b81edcf5f04e8b89868 (patch) | |
tree | 8da796f745a632f096e86943e25cc96f0a7e0dc1 /main/smokeping/smokeping.initd | |
parent | 54fb9a296894632b4597dd7724d0a64e81d71cb2 (diff) | |
download | aports-81bb6f7ad5f16cf1d7361b81edcf5f04e8b89868.tar.bz2 aports-81bb6f7ad5f16cf1d7361b81edcf5f04e8b89868.tar.xz |
main/smokeping: moved from testing
fixes #348
Diffstat (limited to 'main/smokeping/smokeping.initd')
-rw-r--r-- | main/smokeping/smokeping.initd | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/main/smokeping/smokeping.initd b/main/smokeping/smokeping.initd new file mode 100644 index 0000000000..068f33ff25 --- /dev/null +++ b/main/smokeping/smokeping.initd @@ -0,0 +1,77 @@ +#!/sbin/runscript +# Copyright 1999-2008 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +opts="${opts} dump reload restore" + +depend() { + need net + use dns +} + +checkconfig() { + if [ ! -f "/etc/smokeping/config" ] ; then + eerror "You need /etc/smokeping/config to run smokeping!" + return 1 + fi +} + +start() { + checkconfig || return 1 + + if [ ! -d /var/run/smokeping/ ]; then + mkdir /var/run/smokeping/ + fi + chown 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 \ + --chuid smokeping:smokeping + eend $? +} + +stop() { + ebegin "Stopping smokeping" + start-stop-daemon --stop \ + --pidfile /var/run/smokeping/smokeping.pid + eend $? +} + +reload() { + ebegin "Reloading smokeping" + /usr/bin/smokeping --reload 1>/dev/null 2>&1 + eend $? +} + +dump() { + ebegin "Dumping smokeping rrd files to XML for backup or upgrade use" + if service_started "${myservice}" ; then + eerror "You need to stop smokeping before dumping files!" + return 1 + fi + 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" + if service_started "${myservice}" ; then + eerror "You need to stop smokeping before restoring files!" + return 1 + fi + 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 $? +} |