summaryrefslogtreecommitdiff
path: root/www/unit/files/unitd.in
blob: 1104ed906cfd874d82a30281204cd838806a2185 (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

# PROVIDE: unitd
# REQUIRE: LOGIN cleanvar
# KEYWORD: shutdown

#
# Add the following lines to /etc/rc.conf to enable nginx:
# unitd_enable (bool):          Set to "NO" by default.
#                               Set it to "YES" to enable unit
# unitd_sockfile (str):         Set to "" by default.
#                               Set it to "127.0.0.1:8443" to enable the unit control
#                               socket on the network address

. /etc/rc.subr

name="unitd"
rcvar=unitd_enable

command="%%PREFIX%%/sbin/unitd"
start_precmd=start_precmd
_tmpprefix="%%UNIT_TMPDIR%%"

unitd_checktmpdir()
{
    if [ ! -d ${_tmpprefix} ] ; then
        install -d -o %%WWWOWN%% -g %%WWWGRP%% -m 755 ${_tmpprefix}
    else
        chown -R %%WWWOWN%%:%%WWWGRP%% ${_tmpprefix}
    fi
}

start_precmd()
{
    unitd_checktmpdir
    rm -f %%UNIT_SOCK%%
}

load_rc_config $name

# Default value
: ${unitd_sockfile=""}

pidfile=${unit_pidfile:-"%%UNIT_PIDFILE%%"}
unitd_enable=${unitd_enable:-"NO"}
sockfile=${unitd_sockfile}

if [ x${sockfile} != "x" ]
then
    command_args="--control ${sockfile}"
fi

run_rc_command "$1"