aboutsummaryrefslogtreecommitdiffstats
path: root/testing/nut/upsd.initd
blob: 0f891bce5db324b0d952d65bb90b1ea8502737a2 (plain) (blame)
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
#!/sbin/openrc-run

name="UPS Server"
pidfile=/run/nut/upsd.pid
command=/usr/sbin/upsd
required_files="/etc/nut/nut.conf /etc/nut/upsd.conf"
extra_started_commands="reload"
start_stop_daemon_args="--quiet"

depend() {
	use net dns
}

start_pre() {
	. /etc/nut/nut.conf
	case $MODE in
	standalone|netserver)
		checkpath -d --owner nut:nut --mode 750 ${pidfile%/*} || return 1
		/usr/sbin/upsdrvctl start > /dev/null
		;;
	none)
		eerror "$name disabled, please adjust the configuration to your needs"
		eerror "Then set MODE to a suitable value in /etc/nut/nut.conf to enable it"
		return 1
		;;
	*)
		return 1
		;;
	esac
}

stop_post() {
	/usr/sbin/upsdrvctl stop > /dev/null
}

reload() {
	ebegin "Reloading $name"
	start-stop-daemon --signal HUP --pidfile $pidfile
	eend $?
}