aboutsummaryrefslogtreecommitdiff
path: root/net/guacamole-server/files/guacd.in
blob: d97dec146a7039869c2aa8a04932930b256dd07d (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
#!/bin/sh

# $FreeBSD$
#
# PROVIDE: guacd
# REQUIRE: LOGIN
#
# Add these lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# guacd_enable (bool):		Set to "NO" by default.
#				Set it to "YES" to enable guacd.
# guacd_home (str):		Home directory for guacd to use
#				Default to "%%GUACD_HOME%%" created by the port
# guacd_user (str):		User to run guacd as
#				Default to "%%GUACD_USER%%" created by the port
# guacd_group (str):		Group to run guacd as
#				Default to "%%GUACD_GROUP%%" created by the port
# guacd_pidfile (str):		Set to "" by default will use the path

. /etc/rc.subr

name=guacd
rcvar=${name}_enable

load_rc_config ${name}

: ${guacd_enable:="NO"}
: ${guacd_home:="%%GUACD_HOME%%"}
: ${guacd_user:="%%GUACD_USER%%"}
: ${guacd_group:="%%GUACD_GROUP%%"}
: ${guacd_pidfile:="/var/run/${name}/${name}.pid"}

guacd_env="$guacd_env HOME=$guacd_home"

command=%%PREFIX%%/sbin/guacd
pidfile=${guacd_pidfile}

command_args="-p ${pidfile}"

start_precmd="guacd_prestart"
guacd_prestart() {
        if [ -f ${pidfile} ]; then
                rm -f ${pidfile}
                echo "Removing stale pidfile."
        elif [ ! -d ${pidfile%/*} ]; then
                install -d -o ${guacd_user} -g ${guacd_group} ${pidfile%/*}
        fi
}


run_rc_command "$1"