summaryrefslogtreecommitdiffstats
path: root/comms/conserver-com/files/conserver.in
blob: cb7e87dfece79ea9ac5b9bd30759dd59e7d321bd (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
#!/bin/sh
#
# $FreeBSD$
#

# PROVIDE: conserver
# REQUIRE: DAEMON
# KEYWORD: shutdown

. /etc/rc.subr

name="conserver"
rcvar=conserver_enable

command=%%PREFIX%%/sbin/${name}
pidfile=/var/run/${name}.pid
required_files=%%PREFIX%%/etc/${name}.cf
extra_commands="reload reconnect reinit"
reconnect_cmd="reconnect_cmd"
reinit_cmd="reinit_cmd"

load_rc_config $name
: ${conserver_enable="NO"}
: ${conserver_flags="-d"}

kill_cmd()
{
	_msg=$1
	_sig=$2

	if [ -z "$rc_pid" ]; then
		if [ -n "$pidfile" ]; then
			echo 1>&2 \
		    "${name} not running? (check $pidfile)."
		else
			echo 1>&2 "${name} not running?"
		fi
		return 1
	fi
	echo "$_msg"
	kill -${_sig:-HUP} $rc_pid
	_return=$?
	[ $_return -ne 0 ] && [ -z "$rc_force" ] && return 1
}

reconnect_cmd()
{
	kill_cmd "Try to reconnect all downed consoles." USR1
}

reinit_cmd()
{
	kill_cmd "Try to close and reopen all log files and downed connections." USR2
}

run_rc_command "$1"
OpenPOWER on IntegriCloud