1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
#! /bin/sh
### BEGIN INIT INFO
# Provides: hal
# Required-Start: $remote_fs dbus
# Required-Stop: $remote_fs dbus
# Should-Start: $syslog acpid
# Should-Stop: $syslog acpid
# Default-Start: 2 3 4 5
# Default-Stop: 1
# Short-Description: Hardware abstraction layer
# Description: The HAL daemon collects and maintains information about
# your hardware.
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/hald
PIDDIR=/var/run/hald
PIDFILE=$PIDDIR/hald.pid
NAME=hald
DAEMONUSER=haldaemon
DESC="Hardware abstraction layer"
test -x $DAEMON || exit 0
. /lib/lsb/init-functions
# Include hal defaults if available
if [ -f /etc/default/hal ] ; then
. /etc/default/hal
fi
set -e
do_start() {
if [ ! -d $PIDDIR ]; then
mkdir -p $PIDDIR
chown $DAEMONUSER:$DAEMONUSER $PIDDIR
fi
start-stop-daemon --start --oknodo --pidfile $PIDFILE \
--exec $DAEMON -- $DAEMON_OPTS
}
do_stop() {
start-stop-daemon --stop --retry 5 --oknodo --quiet --pidfile $PIDFILE \
--exec $DAEMON
}
check_prerequisites() {
UNAME=`uname`
if [ ! -d /proc/sys/fs/inotify ] && [ $UNAME = "Linux" ]; then
log_failure_msg "Can't start $DESC - enable inotify support in your kernel"
exit 0
fi
if [ ! -e /var/run/dbus/system_bus_socket ]; then
log_failure_msg "Can't start $DESC - please ensure dbus is running"
exit 0
fi
if [ ! -d /sys/devices ] && [ $UNAME = "Linux" ]; then
log_failure_msg "Can't start $DESC - sysfs not mounted on /sys"
exit 0
fi
if [ "$(stat -c %d/%i /)" != "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ] && [ $UNAME != "GNU" ]; then
log_failure_msg "Can't start $DESC - detected chrooted session"
exit 0
fi
}
case "$1" in
start)
check_prerequisites
log_daemon_msg "Starting $DESC" "$NAME"
do_start
log_end_msg $?
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
log_end_msg $?
;;
restart|force-reload)
check_prerequisites
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
do_start
log_end_msg $?
;;
status)
status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
;;
*)
log_success_msg "Usage: $0 {start|stop|restart|force-reload|status}" >&2
exit 1
;;
esac
exit 0
|