app-i18n/ibus: keyworded 1.5.16 for sparc, bug #626804
[gentoo.git] / net-analyzer / icinga / files / icinga-init.d
1 #!/sbin/openrc-run
2 # Copyright 1999-2012 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 : ${ICINGACFG:=/etc/icinga/icinga.cfg}
6
7 extra_commands="checkconfig"
8 extra_started_commands="reload"
9
10 command=/usr/sbin/icinga
11 command_args="-d ${ICINGACFG}"
12
13 get_config() {
14     if [ -e "${ICINGACFG}" ]; then
15             sed -n -e 's:^[ \t]*'$1'=\([^#]\+\).*:\1:p' "${ICINGACFG}"
16         fi
17 }
18
19 pidfile=$(get_config lock_file)
20 start_stop_daemon_args="-e HOME=/var/lib/icinga"
21
22 depend() {
23         need net
24         use dns logger firewall mysql postgresql
25 }
26
27 checkconfig() {
28         # Silent Check
29         ${command} -v ${ICINGACFG} &>/dev/null && return 0
30         # Now we know there's problem - run again and display errors
31         ${command} -v ${ICINGACFG}
32         eend $? "Configuration Error. Please fix your configfile"
33 }
34
35 reload()
36 {
37         checkconfig || return 1
38         ebegin "Reloading configuration"
39         kill -HUP $(cat ${pidfile}) &>/dev/null
40         eend $?
41 }
42
43 start_pre() {
44         checkpath -d -o icinga:icinga $(get_config temp_path)  $(dirname $(get_config lock_file)) $(dirname $(get_config log_file)) $(dirname $(get_config status_file))
45         checkpath -f -o icinga:icinga $(get_config log_file)
46         rm -f $(get_config command_file)
47 }
48
49 stop_post() {
50         rm -f $(get_config command_file)
51         rm -r /tmp/icinga
52 }
53
54 svc_restart() {
55         checkconfig || return 1
56         ebegin "Restarting icinga"
57         svc_stop
58         svc_start
59         eend $?
60 }
61