summaryrefslogtreecommitdiff
path: root/chat/silc-server/files/silcd.sh
blob: 60c255c95b99741bc110f2526fc3de6009dcc6f3 (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
#!/bin/sh
#
# $NetBSD: silcd.sh,v 1.4 2002/05/03 22:02:49 hubertf Exp $
#
# PROVIDE: silcd
# REQUIRE: DAEMON
#
# To start silcd at startup, copy this script to /etc/rc.d and set
# silcd=YES in /etc/rc.conf.

. /etc/rc.subr

name="silcd"
rcvar=$name
confdir="@PKG_SYSCONFDIR@"
required_files="$confdir/silcd.conf"
required_dirs="/var/log/silcd"
pidfile="/var/log/silcd/${name}.pid"
command="@PREFIX@/sbin/silcd"
start_precmd="silcd_precmd"
stop_cmd="silcd_stop"

silcd_precmd()
{
	if [ ! -f $confdir/silcd.prv ]; then
		$command -C $confdir
	fi
}

silcd_stop()
{
	if [ -z "$_pid" ]; then
		if [ -n "$pidfile" ]; then
			echo "${name} not running? (check $pidfile)."
		else
			echo "${name} not running?"
		fi
		exit 1
	fi

	echo "Stopping ${name}."
	_doit=\
"${_user:+su -m $_user -c '}kill -${sig_stop:-TERM} $_pid${_user:+'}"
	eval $_doit

	eval $_pidcmd
	if [ ! $_pid ]; then
		rm -f $pidfile
	fi
}

load_rc_config $name
run_rc_command "$1"