forked from opnsense/ports
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quasselcore.in
75 lines (62 loc) · 1.99 KB
/
quasselcore.in
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
#!/bin/sh
# $FreeBSD$
#
# PROVIDE: quasselcore
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable quasselcore:
#
# quasselcore_enable="YES"
# # optional
# quasselcore_data="/var/db/quasselcore"
# quasselcore_log="/var/log/quasselcore.log"
# quasselcore_listen="0.0.0.0,::"
# quasselcore_args="--configdir=${quasselcore_data} --logfile=${quasselcore_log} --listen=${quasselcore_listen}"
# quasselcore_user="quasselcore"
# quasselcore_group="quasselcore"
. /etc/rc.subr
name=quasselcore
rcvar=quasselcore_enable
load_rc_config ${name}
: ${quasselcore_enable:="NO"}
: ${quasselcore_data="/var/db/quasselcore"}
: ${quasselcore_log="/var/log/quasselcore.log"}
: ${quasselcore_listen="0.0.0.0,::"}
: ${quasselcore_args="--configdir=${quasselcore_data} --logfile=${quasselcore_log} --listen=${quasselcore_listen}"}
: ${quasselcore_user="quasselcore"}
: ${quasselcore_group="${quasselcore_user}"}
procname="%%PREFIX%%/bin/quasselcore"
pidfile="/var/run/${name}.pid"
command="/usr/sbin/daemon"
command_args="-p ${pidfile} ${procname} ${quasselcore_args}"
start_precmd="${name}_prestart"
stop_postcmd="${name}_poststop"
keygen_cmd="${name}_keygen"
extra_commands="keygen"
quasselcore_keygen()
{
openssl req -x509 -nodes -days 365 -newkey rsa:4096 \
-keyout "${quasselcore_data}/quasselCert.pem" \
-out "${quasselcore_data}/quasselCert.pem"
chown ${quasselcore_user}:${quasselcore_group} "${quasselcore_data}/quasselCert.pem"
chmod 400 "${quasselcore_data}/quasselCert.pem"
}
quasselcore_prestart()
{
install -d -o ${quasselcore_user} -g ${quasselcore_group} ${quasselcore_data}
if [ ! -f "${quasselcore_log}" ]; then
install -o ${quasselcore_user} -g ${quasselcore_group} /dev/null ${quasselcore_log}
fi
if [ ! -f "${pidfile}" ]; then
install -o ${quasselcore_user} -g ${quasselcore_group} /dev/null ${pidfile}
fi
if [ ! -f "${quasselcore_data}/quasselCert.pem" ]; then
quasselcore_keygen
fi
}
quasselcore_poststop()
{
rm -f "${pidfile}"
}
run_rc_command "$1"