aboutsummaryrefslogtreecommitdiff
path: root/system/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
parent24cdd6a3fe58a21a5a6eb3ecfc444712b0e8b398 (diff)
system/sleepd: Fix bug.
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'system/sleepd')
-rw-r--r--system/sleepd/fix_acpica_version.patch12
-rw-r--r--system/sleepd/rc.sleepd25
-rw-r--r--system/sleepd/sleepd.SlackBuild5
3 files changed, 34 insertions, 8 deletions
diff --git a/system/sleepd/fix_acpica_version.patch b/system/sleepd/fix_acpica_version.patch
new file mode 100644
index 0000000000000..02422ed0be755
--- /dev/null
+++ b/system/sleepd/fix_acpica_version.patch
@@ -0,0 +1,12 @@
+diff -uNr sleepd-2.05.orig/acpi.c sleepd-2.05/acpi.c
+--- sleepd-2.05.orig/acpi.c 2014-05-28 04:06:50.000000000 +0800
++++ sleepd-2.05/acpi.c 2020-07-17 22:51:39.340113991 +0800
+@@ -67,7 +67,7 @@
+ fd = open(file, O_RDONLY);
+ if (fd == -1) return NULL;
+ end = read(fd, buf, sizeof(buf));
+- buf[end-1] = '\0';
++ ((buf[end-1]) == '\n') && (buf[end-1] = '\0');
+ close(fd);
+ return buf;
+ }
diff --git a/system/sleepd/rc.sleepd b/system/sleepd/rc.sleepd
index bbfa1b0f15fbc..66587a2f8c7c8 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
diff --git a/system/sleepd/sleepd.SlackBuild b/system/sleepd/sleepd.SlackBuild
index 2d16819b8cd1e..d4847ffee4b7c 100644
--- a/system/sleepd/sleepd.SlackBuild
+++ b/system/sleepd/sleepd.SlackBuild
@@ -23,7 +23,7 @@
PRGNAM="sleepd"
VERSION=${VERSION:-2.05}
-BUILD=${BUILD:-1}
+BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}
if [ -z "$ARCH" ]; then
@@ -70,6 +70,8 @@ find -L . \
sed -i "s|share/man|man|"g Makefile
+patch -p1 < $CWD/fix_acpica_version.patch
+
make
make install PREFIX=$PKG
@@ -78,6 +80,7 @@ find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | gr
mkdir -p $PKG/etc/rc.d
cat $CWD/rc.sleepd > $PKG/etc/rc.d/rc.sleepd.new
+cp -a debian/default $PKG/etc/sleepd.conf
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a GPL INSTALL TODO $PKG/usr/doc/$PRGNAM-$VERSION