diff options
author | Kozak Ivan <kozak-iv@yandex.ru> | 2014-03-02 17:19:40 +0400 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2014-03-05 08:46:31 +0000 |
commit | fe700e6fdc9e67500ea013d4399313e016a6339e (patch) | |
tree | cfa257f79e71c795ec7f28cfc8d73181d4e5e108 /testing/nut/nut-upsd.initd | |
parent | bbbc4046f1f6d0370fc63ced842cdd67adbe093f (diff) | |
download | aports-fe700e6fdc9e67500ea013d4399313e016a6339e.tar.bz2 aports-fe700e6fdc9e67500ea013d4399313e016a6339e.tar.xz |
testing/nut: new aport
Diffstat (limited to 'testing/nut/nut-upsd.initd')
-rw-r--r-- | testing/nut/nut-upsd.initd | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/testing/nut/nut-upsd.initd b/testing/nut/nut-upsd.initd new file mode 100644 index 000000000..dcc3b595b --- /dev/null +++ b/testing/nut/nut-upsd.initd @@ -0,0 +1,53 @@ +#!/sbin/runscript + +extra_started_commands="reload" + +pid_dir=/var/run/nut +pidfile=/var/run/nut/upsd.pid +upsd=/usr/sbin/upsd +upsdrvctl=/usr/libexec/nut/upsdrvctl +NAME=nut-server + +depend() { + use net + before nut-upsmon +} + +start_pre() +{ + # Ensure that our dirs are correct + checkpath -d --owner root:nut --mode 0770 $pid_dir +} + +start() { + ebegin "Starting upsd" + + # Include NUT nut.conf + [ -r $CONFIG ] && . $CONFIG + + # Explicitly require the configuration to be done in /etc/nut/nut.conf + # redundant with nut-client + if [ "x$MODE" = "xnone" -o -z "$MODE" ] ; then + eerror "$NAME disabled, please adjust the configuration to your needs" + eerror "Then set MODE to a suitable value in $CONFIG to enable it" + # exit success to avoid breaking the install process! + return 1 + fi + + ${upsdrvctl} -u nut start &>/dev/null + start-stop-daemon --start --pidfile ${pidfile} --exec ${upsd} -- ${ARGS} + eend $? +} + +stop() { + ebegin "Stopping upsd" + start-stop-daemon --stop --pidfile ${pidfile} + ${upsdrvctl} -u nut stop &>/dev/null + eend $? +} + +reload() { + ebegin "Reloading upsd" + start-stop-daemon --stop --signal HUP --pidfile ${pidfile} + eend $? +} |