aboutsummaryrefslogtreecommitdiff
path: root/comms/qpage/files/qpage.in
blob: 9d9800d70fa3381763b632b002ab13cfc9e5ec5e (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh

# PROVIDE: qpage
# REQUIRE: NETWORKING
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable/configure this service:
#
# qpage_enable (bool):         Set to NO by default.
#                              Set it to YES to enable qpage.
# qpage_queue_interval (int):  Set to 10 (seconds) by default.
# qpage_cfg_file (path):       Set it to an alternate configuration file path
#                              if desired.
# qpage_flags (str):           Set it to a list of additional command-line
#                              parameters if desired.
#

. %%RC_SUBR%%

name="qpage"
rcvar=${name}_enable

command=%%PREFIX%%/bin/${name}

load_rc_config $name

: ${qpage_enable="NO"}
: ${qpage_queue_interval="10"}
: ${qpage_cfg_file=""}
: ${qpage_flags=""}

stop_cmd=${name}_stop
extra_commands="reload"
reload_cmd=${name}_reload

command_args="-q ${qpage_queue_interval} ${qpage_flags}"
if [ -n "${qpage_cfg_file}" ]; then
	command_args="${command_args} -C ${qpage_cfg_file}"
fi

qpage_stop() {
	/usr/bin/killall qpage
}

qpage_reload() {
	# awk pattern matches master daemon process only (PPID 1 in 3rd column)
	pid=`/bin/ps alcxww | /usr/bin/awk "/^ *[0-9]+ +[0-9]+ +1 .* ${name}\$/{print \\\$2}"`

	if [ -n "$pid" ]; then
		kill -HUP $pid
	else
		echo "$0: no qpage daemon found" >& 2
	fi
}

run_rc_command "$1"