summaryrefslogtreecommitdiff
blob: 683e52c4c4e585e60cc22b24b60efe9f9786c887 (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
#!/sbin/runscript

extra_commands="${extra_commands} reload checkconfig"

depend() {
	need net
	use dns logger firewall
	after mysql postgresql ido2db
}

checkconfig() {
	# Silent Check
	/usr/sbin/icinga -v /etc/icinga/icinga.cfg &>/dev/null && return 0
	# Now we know there's problem - run again and display errors
	/usr/sbin/icinga -v /etc/icinga/icinga.cfg
	eend $? "Configuration Error. Please fix your configfile"
}

reload()
{
	checkconfig || return 1
	ebegin "Reloading configuration"
	kill -HUP `cat /var/run/icinga/icinga.lock` &>/dev/null
	eend $?
}

start() {
	ebegin "Starting icinga"
	checkpath -d -o icinga:icinga /tmp/icinga /var/run/icinga /var/log/icinga /var/lib/icinga
	checkpath -f -o icinga:icinga /var/log/icinga/icinga.log
	rm -f /var/lib/icinga/rw/icinga.cmd
	start-stop-daemon --start --exec /usr/sbin/icinga -e HOME="/var/lib/icinga/home" --pidfile /var/run/icinga/icinga.lock -- -d /etc/icinga/icinga.cfg
	eend $?
}

stop() {
	ebegin "Stopping icinga"
	start-stop-daemon --stop --pidfile /var/run/icinga/icinga.lock
	rm -f /var/lib/icinga/status.log /var/run/icinga/icinga.lock /var/lib/icinga/rw/icinga.cmd
	rm -r /tmp/icinga
	eend $?
}

svc_restart() {
	checkconfig || return 1
	ebegin "Restarting icinga"
	svc_stop
	svc_start
	eend $?
}