summaryrefslogtreecommitdiff
path: root/powerd.init
blob: 38a58b0fee44303d0483ae474117706d16e1d68c (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
#!/bin/sh
#
# pwerdd	Start/Stop James Brents power daemon.
#
# chkconfig:	345 75 65
# description:	The power daemon provides a means of determining when the 
#		power is off, wether through a serial port connected on 
#		this machine, or a remote server, and allows the safe 
#		shutdown of the machine.
# processname:	powerd
# pidfile:	/var/run/powerd.pid
# config:	/etc/powerd.conf

# Source function library.
. /etc/init.d/functions

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
if is_yes "${NETWORKING}"; then
	if [ ! -f /var/lock/subsys/network ]; then
		msg_network_down powerd
		exit 1
	fi
else
	exit 0
fi

start() {
	msg_starting powerd
	daemon powerd
	# errorcode not set when failed
	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/powerd
	return $RETVAL
}

stop() {
	msg_stopping powerd
	killproc powerd
	RETVAL=$?
	rm -f /var/lock/subsys/powerd
	return $RETVAL
}

# See how we were called.
case "$1" in
  start)
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/powerd ]; then
		start
	else
		msg_already_running powerd
		exit 1
	fi
	;;
  stop)
	# Check if the service is already running?
	if [ -f /var/lock/subsys/powerd ]; then
		stop
	else
		msg_not_running powerd
		exit 1
	fi
	;;
  status)
	status powerd
	;;
  restart|reload)
	stop
	start
	;;
  condrestart)
	if [ -f /var/lock/subsys/powerd ]; then
		stop
		start
	fi
	;;
  *)
	msg_usage "$0 {start|stop|restart|reload|condrestart|status}"
	exit 1
esac

exit $RETVAL