summaryrefslogtreecommitdiff
path: root/system/sleepd/rc.sleepd
diff options
context:
space:
mode:
authorKenneth Chan <kenneth.t.chan@gmail.com>2020-09-04 00:43:53 +0700
committerWilly Sudiarto Raharjo <willysr@slackbuilds.org>2020-09-04 00:43:53 +0700
commitfa72d5a17504e50b80eface976f7956405eb4cba (patch)
tree4a8028eb4be8e3d1a9d2986452af28fc2153113f /system/sleepd/rc.sleepd
parent24cdd6a3fe58a21a5a6eb3ecfc444712b0e8b398 (diff)
downloadslackbuilds-fa72d5a17504e50b80eface976f7956405eb4cba.tar.gz
system/sleepd: Fix bug.
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'system/sleepd/rc.sleepd')
-rw-r--r--system/sleepd/rc.sleepd25
1 files changed, 18 insertions, 7 deletions
diff --git a/system/sleepd/rc.sleepd b/system/sleepd/rc.sleepd
index bbfa1b0f15..66587a2f8c 100644
--- a/system/sleepd/rc.sleepd
+++ b/system/sleepd/rc.sleepd
@@ -1,26 +1,36 @@
#!/bin/sh
# /etc/rc.d/rc.sleepd
-# Start/stop/restart the Wicd daemon
+# Start/stop/restart the sleepd daemon
PIDFILE="/var/run/sleepd.pid"
DAEMON="/usr/sbin/sleepd"
+. /etc/sleepd.conf
+
# Define start and stop functions
sleepd_start() {
+ [ $UID -eq 0 ] || exit 4
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..."
+ echo "sleepd appears to already be running. If this is not the case,"
+ echo "remove $PIDFILE and try again."
exit 1
else
- echo "Starting sleepd: $DAEMON &"
- sleepd 2>/dev/null 1>&2 &
+ echo "Starting sleepd: $DAEMON"
+ sleepd $PARAMS > /dev/null 2>&1
+ ps -p `cat $PIDFILE` > /dev/null 2>&1
+ if [ "$?" == 1 ]; then
+ rm -f $PIDFILE
+ echo "ERROR: $DAEMON failed to start."
+ echo "ERROR: For more verbosity, run \"$DAEMON -n -v\" manually."
+ echo "ERROR: Exiting..."
+ fi
fi
}
sleepd_force_stop() {
+ [ $UID -eq 0 ] || exit 4
echo "Force stopping sleepd..."
if [ -e $PIDFILE ]; then
kill $(cat $PIDFILE) 2>/dev/null
@@ -31,6 +41,7 @@ sleepd_force_stop() {
}
sleepd_stop() {
+ [ $UID -eq 0 ] || exit 4
echo "Stopping sleepd..."
if [ -e $PIDFILE ]; then
kill $(cat $PIDFILE) 2>/dev/null
@@ -62,7 +73,7 @@ case $1 in
sleepd_status
;;
*)
- echo "Usage: $0 {start|stop|restart|status}"
+ echo "Usage: $0 {start|stop|force_stop|restart|status}"
exit 1
;;
esac