diff options
author | Kenneth Chan <kenneth.t.chan@gmail.com> | 2017-05-21 08:30:21 +0700 |
---|---|---|
committer | Willy Sudiarto Raharjo <willysr@slackbuilds.org> | 2017-05-27 07:29:24 +0700 |
commit | ee6bade01d49e64d9b08fea2010ad19e4229820a (patch) | |
tree | 7698fdf2cb419f34a69d9b6c208914c10f6afdb9 /system/sleepd/rc.sleepd | |
parent | d983f44f67a6763bb6c19abc2168e3adb12762d0 (diff) |
system/sleepd: Added (power management daemon).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'system/sleepd/rc.sleepd')
-rw-r--r-- | system/sleepd/rc.sleepd | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/system/sleepd/rc.sleepd b/system/sleepd/rc.sleepd new file mode 100644 index 0000000000000..bbfa1b0f15fbc --- /dev/null +++ b/system/sleepd/rc.sleepd @@ -0,0 +1,68 @@ +#!/bin/sh + +# /etc/rc.d/rc.sleepd +# Start/stop/restart the Wicd daemon + +PIDFILE="/var/run/sleepd.pid" +DAEMON="/usr/sbin/sleepd" + +# Define start and stop functions + +sleepd_start() { + if [ -e $PIDFILE ]; then + echo "sleepd appears to already be running." + echo "If this is not the case, then remove " + echo "$PIDFILE and try again..." + exit 1 + else + echo "Starting sleepd: $DAEMON &" + sleepd 2>/dev/null 1>&2 & + fi +} + +sleepd_force_stop() { + echo "Force stopping sleepd..." + if [ -e $PIDFILE ]; then + kill $(cat $PIDFILE) 2>/dev/null + rm -f $PIDFILE 2>/dev/null + else + killall -9 sleepd 2>/dev/null + fi +} + +sleepd_stop() { + echo "Stopping sleepd..." + if [ -e $PIDFILE ]; then + kill $(cat $PIDFILE) 2>/dev/null + rm -f $PIDFILE 2>/dev/null + fi +} + +sleepd_status() { + sleepctl status +} + +# See how we were called and take appropriate action + +case $1 in + start) + sleepd_start + ;; + stop) + sleepd_stop + ;; + force_stop) + sleepd_force_stop + ;; + restart) + sleepd_force_stop + sleepd_start + ;; + status) + sleepd_status + ;; + *) + echo "Usage: $0 {start|stop|restart|status}" + exit 1 + ;; +esac |