summaryrefslogtreecommitdiff
path: root/chat/ircd-hybrid/files/ircd-hybrid.sh
blob: 49f3dbeb0f977aa0db550aca683f00d9ebcdf5b0 (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
#!@RCD_SCRIPTS_SHELL@
#
# $NetBSD: ircd-hybrid.sh,v 1.2 2003/08/23 10:52:50 seb Exp $
#
# PROVIDE: ircdhybrid
# REQUIRE: DAEMON

name="ircdhybrid"
rcvar=$name
pidfile="@PPATH@"
command="@SPATH@"
conffile="@DPATH@/ircd.conf"
required_files="$conffile"
start_precmd=set_pid_file

set_pid_file () {
	@TOUCH@ $pidfile && @CHOWN@ @USER@ $pidfile && @CHMOD@ 600 $pidfile
}

if [ -d /etc/rc.d ]; then :; else
	command=${1:-start}

	case ${command} in
	start)
	if [ -x @SPATH@ -a -f  "$conffile" ]
	then
		echo "Starting ${name}."
		set_pid_file || exit 1
		exec @SPATH@
	fi
	;;
	stop)
	if [ -f ${pidfile} ]; then
		pid=`head -1 ${pidfile}`
		echo "Stopping ${name}."
		kill -TERM ${pid}
	else
		echo "${name} not running?"
	fi
	;;
	restart)
	( $0 stop )
	sleep 1
	$0 start
	;;
	status)
	if [ -f ${pidfile} ]; then
		pid=`head -1 ${pidfile}`
		echo "${name} is running as pid ${pid}."
	else
		echo "${name} is not running."
	fi
	;;
	esac
	exit 0
fi

. /etc/rc.subr

load_rc_config $name
run_rc_command "$1"