summaryrefslogtreecommitdiff
path: root/hald/haldaemon.in
blob: 34114c61963ae2d467e82b3bf8694b490d7cfa01 (plain)
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
99
100
101
102
#!/bin/sh
#
# haldaemon:   HAL daemon
#
# chkconfig: 345 98 02
# description:  This is a daemon for collecting and maintaing information \
#               about hardware from several sources. \
#               See http://www.freedesktop.org/Software/hal
#
# processname: hald
# pidfile: @HALD_PID_FILE@
#

# Source function library.
. @sysconfdir@/rc.d/init.d/functions

# so we can rearrange this easily
processname=hald
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() {

	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() {

	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
}

case "$1" in
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
	;;
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