aboutsummaryrefslogtreecommitdiff
path: root/security/p5-openxpki/files/openxpki.in
blob: e4c03c5f85ab16be4c02358907e70971cf6e6eb3 (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
#!/bin/sh
# $FreeBSD$
#
# PROVIDE: openxpki
# REQUIRE: LOGIN
# REQUIRE: postgresql
# REQUIRE: mysql
# KEYWORD: shutdown
#
# Define this variable in file /etc/rc.conf:
# openxpki_enable="YES"
# to ensure that openxpki starts at boot time.
# Define and edit this variable in file /etc/rc.conf:
# openxpki_conf="%%PREFIX%%/etc/openxpki/config.git"
# if your configuration is in different place.
#
# DO NOT CHANGE THESE DEFAULT VALUES HERE
# SET THEM IN THE /etc/rc.conf FILE
#

. /etc/rc.subr

name=openxpki
desc="OpenXPKI daemon"
rcvar=openxpki_enable
load_rc_config ${name}
: ${openxpki_enable:=no}
: ${openxpki_conf=%%ETCDIR%%/config.d}
command=%%PREFIX%%/bin/openxpkictl
start_precmd="${name}_prestart"
restart_precmd="${name}_prestart"
reload_precmd="${name}_prestart"
procname=openxpkid
openxpki_user=${name}
pidfile=/var/openxpki/openxpkid.pid

extra_commands=reload
start_cmd=control
stop_cmd=control
restart_cmd=control
status_cmd=control
reload_cmd=control

openxpki_prestart()
{
	chown -R ${openxpki_user}:${openxpki_user} %%ETCDIR%%
	chmod -R 754 %%ETCDIR%%
	mkdir -p -m 751 /var/log/${name}
	chown -R ${openxpki_user}:${openxpki_user} /var/log/${name}
	mkdir -p -m 750 /var/${name}
	mkdir -p -m 750 /var/${name}/session
	chown -R ${openxpki_user}:${openxpki_user} /var/${name}
	echo "Service dirs recreated..."
}

control()
{
	echo "Executing: USER=${openxpki_user} ${command} --config ${openxpki_conf} ${rc_arg}"
	USER=${openxpki_user} ${command} --config ${openxpki_conf} ${rc_arg}
}

run_rc_command "$1"