blob: 079dd477f8adbee82fda7253ae7728832ae5223e (
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
|
# $OpenBSD: rc.subr,v 1.8 2010/10/28 21:36:45 robert Exp $
[ -z "${local_rcconf}" ] && . /etc/rc.conf
rc_err() {
echo $1
exit 1
}
rc_start() {
type rc_pre >/dev/null && rc_pre
${daemon} ${daemon_flags} >/dev/null
}
rc_check() {
pgrep -f "^${pexp}" >/dev/null
}
rc_reload() {
pkill -HUP -f "^${pexp}"
}
rc_stop() {
pkill -f "^${pexp}"
type rc_post >/dev/null && rc_post || return 0
}
rc_cmd() {
_name=`basename $0`
eval _rcflags=\${${_name}_flags}
[ `id -u` -eq 0 -o X"$1" = "Xcheck" ] || \
rc_err "$0: need root privileges"
[ -n "${daemon}" ] || rc_err "$0: daemon is not set"
[ -n "${_rcflags}" ] && daemon_flags=${_rcflags}
[ -n "${pexp}" ] || pexp="${daemon}${daemon_flags:+ ${daemon_flags}}"
case "$1" in
check)
rc_check
;;
start)
rc_check || rc_start
;;
stop)
rc_stop
;;
reload)
rc_check && rc_reload
;;
restart)
rc_stop
while rc_check; do
sleep 1
done
rc_start
;;
*)
rc_err "usage: $0 {start|check|reload|restart|stop}"
esac
}
|