summaryrefslogtreecommitdiff
path: root/www/lighttpd/files/lighttpd.sh.in
blob: f87920716dee49f9ce8641152d2af636450a922e (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: lighttpd
# REQUIRE: %%REQUIRE%%
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable lighttpd:
#
# lighttpd_enable (bool):	Set it to "YES" to enable lighttpd
#				Default is "NO".
# lighttpd_conf (path):		Set full path to config file.
#				Default is "%%PREFIX%%/etc/lighttpd/lighttpd.conf".
# lighttpd_pidfile (path):	Set full path to pid file.
#				Default is "/var/run/lighttpd.pid".
#

. /etc/rc.subr

name="lighttpd"
rcvar=`set_rcvar`

load_rc_config $name

: ${lighttpd_enable="NO"}
: ${lighttpd_conf=""}
: ${lighttpd_pidfile="/var/run/${name}.pid"}

# Compatibility for old configuration file location
deprecated_conf=
if [ -z "${lighttpd_conf}" ]; then
	if [ -f "%%PREFIX%%/etc/lighttpd.conf" ]; then
		deprecated_conf=1
		lighttpd_conf="%%PREFIX%%/etc/lighttpd.conf"
	else
		lighttpd_conf="%%PREFIX%%/etc/lighttpd/lighttpd.conf"
	fi
fi

command=%%PREFIX%%/sbin/lighttpd
command_args="-f ${lighttpd_conf}"
pidfile=${lighttpd_pidfile}
required_files=${lighttpd_conf}
start_precmd="check_deprecated"
stop_postcmd=stop_postcmd
restart_precmd="checkconfig"
reload_precmd=reload_precmd
reload_postcmd=reload_postcmd
sig_reload="INT"
check_cmd="checkconfig"
extra_commands="reload check"

check_deprecated()
{
	if [ -n "${deprecated_conf}" ]; then
		echo ""
		echo "*** NOTICE: ***"
		echo "The default location of %%PREFIX%%/etc/lighttpd.conf is deprecated"
		echo "Please consider moving to %%PREFIX%%/etc/lighttpd/lighttpd.conf"
		echo ""
	fi
}

checkconfig()
{
	echo "Performing sanity check on ${name} configuration:"
	eval "${command} ${command_args} -t"
}

stop_postcmd()
{
	rm -f ${pidfile}
}

reload_precmd()
{
	if checkconfig; then
		echo "Performing a graceful restart"
	else
		return 1
	fi
}

reload_postcmd()
{
	rm -f ${pidfile}
	run_rc_command start
}

run_rc_command "$1"