summaryrefslogtreecommitdiff
path: root/chat/silc-server/files/silcd.sh
blob: 774b79fb0156c893902db1b6b664b4269e4d0ee0 (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
#!/bin/sh
#
# $NetBSD: silcd.sh,v 1.5 2002/05/24 22:15:36 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/run/${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()
{
	# Backward compat with NetBSD <1.6:
	[ -z "$rc_pid" ] && rc_pid=$_pid
	[ -z "$rc_pidcmd" ] && rc_pidcmd=$_pidcmd

	if [ -z "$rc_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} $rc_pid${_user:+'}"
	eval $_doit

	eval $rc_pidcmd
	if [ ! $rc_pid ]; then
		rm -f $pidfile
	fi
}

load_rc_config $name
run_rc_command "$1"