summaryrefslogtreecommitdiff
path: root/www/shellinabox/files/shellinaboxd.in
blob: 8ccdea164da8c2b8b015816246912521555394f5 (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
#!/bin/sh

# Shell in a Box Daemon startup script
#
# PROVIDE: shellinaboxd
# REQUIRE: LOGIN
# KEYWORD: shutdown

#
# Add the following to /etc/rc.conf[.local] to enable this service
#
# shellinaboxd_enable="YES"
#
# You can fine tune others variables too:
# shellinaboxd_pidfile="/var/run/shellinabox.pid"
# shellinaboxd_user="%%USERS%%"
# shellinaboxd_group="%%GROUPS%%"
# shellinaboxd_port="4200"
# shellinaboxd_certdir="%%ETCDIR%%"
# shellinaboxd_certfile=
# 	Example: shellinaboxd_certfile="/your/cert.pem"
# shellinaboxd_flags=

shellinaboxd_precmd() {
	if command -v check_namevarlist > /dev/null 2>&1; then
		check_namevarlist fib && return 0
	fi

	${SYSCTL} net.fibs >/dev/null 2>&1 || return 0

	shellinaboxd_fib=${shellinaboxd_fib:-"NONE"}
	case "$shellinaboxd_fib" in
	[Nn][Oo][Nn][Ee])
		;;
	*)
		command="setfib -F ${shellinaboxd_fib} ${command}"
		;;
	esac
} 

. /etc/rc.subr

name="shellinaboxd"
rcvar=shellinaboxd_enable

command="%%PREFIX%%/bin/${name}"
start_precmd="shellinaboxd_precmd"

load_rc_config $name

shellinaboxd_enable=${shellinaboxd_enable:-"NO"}
shellinaboxd_user=${shellinaboxd_user:-"%%USERS%%"}
shellinaboxd_group=${shellinaboxd_group:-"%%GROUPS%%"}
shellinaboxd_port=${shellinaboxd_port:-"4200"}
shellinaboxd_certdir=${shellinaboxd_certdir:-"%%ETCDIR%%"}

pidfile=${shellinaboxd_pidfile:-"/var/run/shellinaboxd.pid"}

command_args="--user=${shellinaboxd_user} --group=${shellinaboxd_group} --port=${shellinaboxd_port} --background=${pidfile}"

if [ "${shellinaboxd_certfile}" = "" ]; then
	required_dirs="${shellinaboxd_certdir}"
	command_args="$command_args --cert=${shellinaboxd_certdir}"
else
	command_args="$command_args --cert-fd=3 3< ${shellinaboxd_certfile}"
fi

# avoid unnecessary su(1) initiated by rc.subr
unset shellinaboxd_user shellinaboxd_group

run_rc_command "$1"