#!/bin/sh
# Start/stop/restart the hal daemon:
# slackware script, modified for woof/puppy dec 2008, BK.

# i have named this script x_hal so it starts after 'messagebus' (dbus) script.

#PIDFILE=/var/run/hald/hald.pid
PIDFILE=/var/run/hald/pid

hal_start() {
    echo "Starting HAL daemon:  /usr/sbin/hald --daemon=yes"
    /usr/sbin/hald --daemon=yes
}

hal_stop() {
  if [ -e "$PIDFILE" ]; then
    kill $(cat $PIDFILE)
    rm -f $PIDFILE
  fi
  # Just in case:
  killall hald 1> /dev/null 2> /dev/null
}

# See how we were called.
case "$1" in
    start)
        hal_start
        ;;
    stop)
        hal_stop
        ;;
    restart)
        hal_stop
	sleep 1
        hal_start
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart}"
        ;;
esac
