aboutsummaryrefslogtreecommitdiff
path: root/irc/atheme-services/files/atheme-services.in
blob: be0c8de370bc3c4dbb43d047b05e4ba7c6447cf3 (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
57
58
59
60
#!/bin/sh

# $FreeBSD$
#
# PROVIDE: atheme_services
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# atheme_services_enable (bool):	Set to NO by default.
#					Set it to YES to enable atheme_services.
# atheme_services_config (path):	Set to %%PREFIX%%/etc/atheme/atheme.conf
#					by default.
# atheme_services_datadir (path):	Set to /var/lib/atheme by default.
# atheme_services_logfile (path):	Set to /var/log/atheme/atheme.log
#					by default.
# atheme_services_user (login):		Set to ircservices by default.

. /etc/rc.subr

name=atheme_services
rcvar=atheme_services_enable

load_rc_config $name

: ${atheme_services_enable:="NO"}
: ${atheme_services_config="%%PREFIX%%/etc/atheme/atheme.conf"}
: ${atheme_services_datadir="/var/lib/atheme"}
: ${atheme_services_logfile="/var/log/atheme/atheme.log"}
: ${atheme_services_user="ircservices"}

command=%%PREFIX%%/bin/atheme-services
pidfile=/var/run/atheme/atheme-services.pid

command_args="-p ${pidfile} -c ${atheme_services_config} -l ${atheme_services_logfile} -D ${atheme_services_datadir} >/dev/null 2>&1"

required_files="${atheme_services_config}"

start_precmd="atheme_services_precmd"

extra_commands="reload"

atheme_services_precmd()
{
	if [ ! -d ${atheme_services_datadir} ]; then
		install -d -o ${atheme_services_user} -m 700 \
			${atheme_services_datadir}
	fi
	if [ ! -d ${atheme_services_logfile%/*} ]; then
		install -d -o ${atheme_services_user} -m 700 \
			${atheme_services_logfile%/*}
	fi
	if [ ! -d /var/run/atheme ]; then
		install -d -o ${atheme_services_user} /var/run/atheme
	fi
}

run_rc_command "$1"