-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathtenshi.openrc-init
55 lines (47 loc) · 1.37 KB
/
tenshi.openrc-init
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
#!/sbin/openrc-run
# This is a custom variable.
TENSHI_CFG="/etc/tenshi/tenshi.conf"
# And these all belong to OpenRC.
command="/usr/sbin/tenshi"
extra_commands="checkconfig"
extra_started_commands="reload flush"
pidfile="/run/tenshi.pid"
command_args="-c ${TENSHI_CFG} -P ${pidfile}"
description="tenshi log monitoring daemon"
depend() {
use logger
}
checkconfig() {
$command $command_args -C
return $?
}
start_pre() {
# If this isn't a restart, make sure that the user's config isn't
# busted before we try to start the daemon (this will produce
# better error messages than if we just try to start it blindly).
#
# If, on the other hand, this *is* a restart, then the stop_pre
# action will have ensured that the config is usable and we don't
# need to do that again.
if [ "${RC_CMD}" != "restart" ] ; then
checkconfig || return $?
fi
}
stop_pre() {
# If this is a restart, check to make sure the user's config
# isn't busted before we stop the running daemon.
if [ "${RC_CMD}" = "restart" ] ; then
checkconfig || return $?
fi
}
reload() {
checkconfig || return $?
ebegin "Reloading ${description}"
start-stop-daemon --signal HUP --pidfile "${pidfile}"
eend $?
}
flush() {
ebegin "Flushing all ${description} queues"
start-stop-daemon --signal USR2 --pidfile "${pidfile}"
eend $?
}