hal: Branch 'master'
Richard Hughes
hughsient at kemper.freedesktop.org
Wed Jul 14 00:50:35 PDT 2010
hald/haldaemon.in | 110 +++++++++++++++++++++++++++++++++---------------------
1 file changed, 69 insertions(+), 41 deletions(-)
New commits:
commit 18a43206d2f3c1664d853566b2a264dc756ada7e
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Jul 14 08:50:16 2010 +0100
Make the haldaemon initscript LSB compliant
This is something I had to do in RHEL6, and so it made sense
to share with upstream, even though another HAL release might
not be likely.
diff --git a/hald/haldaemon.in b/hald/haldaemon.in
index 33ee31a..34114c6 100755
--- a/hald/haldaemon.in
+++ b/hald/haldaemon.in
@@ -11,9 +11,6 @@
# pidfile: @HALD_PID_FILE@
#
-# Sanity checks.
-[ -x @sbindir@/hald ] || exit 1
-
# Source function library.
. @sysconfdir@/rc.d/init.d/functions
@@ -23,52 +20,83 @@ servicename=haldaemon
RETVAL=0
+#
+# See how we were called.
+#
+
+check() {
+ # Check that we're a privileged user
+ [ `id -u` = 0 ] || exit 4
+
+ # Check if hald is executable
+ test -x @sbindir@/hald || exit 5
+}
+
start() {
- echo -n $"Starting HAL daemon: "
- daemon --check $servicename $processname
- RETVAL=$?
- echo
- [ $RETVAL -eq 0 ] && touch @localstatedir@/lock/subsys/$servicename
+
+ check
+
+ # Check if it is already running
+ if [ ! -f @localstatedir@/lock/subsys/$servicename ]; then
+ echo -n $"Starting HAL daemon: "
+ daemon --check $servicename $processname
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && touch @localstatedir@/lock/subsys/$servicename
+ echo
+ fi
+ return $RETVAL
}
stop() {
- echo -n $"Stopping HAL daemon: "
- killproc $servicename -TERM
- RETVAL=$?
- echo
- if [ $RETVAL -eq 0 ]; then
- rm -f @localstatedir@/lock/subsys/$servicename
- rm -f @HALD_PID_FILE@
- fi
+ check
+
+ echo -n $"Stopping HAL daemon: "
+ killproc $servicename -TERM
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && rm -f @localstatedir@/lock/subsys/$servicename
+ echo
+ if [ $RETVAL -eq 0 ]; then
+ rm -f @localstatedir@/lock/subsys/$servicename
+ rm -f @HALD_PID_FILE@
+ fi
+ return $RETVAL
}
-# See how we were called.
case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- status)
- status $processname
- RETVAL=$?
- ;;
- restart)
- stop
+start)
+ start
+ ;;
+stop)
+ stop
+ ;;
+reload)
+ echo "$0: Unimplemented feature (hald does this automatically)."
+ RETVAL=3
+ ;;
+force-reload)
+ echo "$0: Unimplemented feature."
+ RETVAL=3
+ ;;
+status)
+ status -p @HALD_PID_FILE@ -l haldaemon $processname
+ RETVAL=$?
+ ;;
+restart)
+ stop
sleep 3
- start
- ;;
- condrestart)
- if [ -f @localstatedir@/lock/subsys/$servicename ]; then
- stop
- sleep 3
- start
- fi
- ;;
- *)
- echo $"Usage: $0 {start|stop|status|restart|condrestart}"
- ;;
+ start
+ ;;
+try-restart|condrestart)
+ if [ -f @localstatedir@/lock/subsys/$servicename ]; then
+ stop
+ sleep 3
+ start
+ fi
+ ;;
+*)
+ echo $"Usage: $0 {start|stop|status|restart|condrestart}"
+ RETVAL=2
esac
+
exit $RETVAL
More information about the hal-commit
mailing list