aboutsummaryrefslogtreecommitdiff
path: root/security/shibboleth-sp/files/shibboleth-sp.in
blob: 73c0059498dd343829ac68dad2ebafe838a10379 (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
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: shibboleth_sp
# REQUIRE: DAEMON
#

. /etc/rc.subr

name="shibboleth_sp"
rcvar=shibboleth_sp_enable

: ${shibboleth_sp_enable:='NO'}
: ${shibboleth_sp_flags:=''}

command=${shibboleth_sp_program:-%%PREFIX%%/sbin/shibd}
pidfile="${shibboleth_sp_pidfile:-/var/run/shibboleth/${name}.pid}"
start_precmd="shibboleth_sp_configtest"
restart_precmd="shibboleth_sp_configtest"
configtest_cmd="shibboleth_sp_configtest"
keygen_cmd="shibboleth_sp_keygen"

shibboleth_sp_usr=%%SHIBD_USER%%
shibboleth_sp_group=%%SHIBD_GROUP%%
www_group=%%WWWGRP%%

load_rc_config $name

command_args="-f -p ${pidfile} -u ${shibboleth_sp_usr} -g ${shibboleth_sp_group}"
confdir=${SHIBSP_CFGDIR:-%%PREFIX%%/etc}/shibboleth
cert=sp-cert.pem
key=sp-key.pem

shibboleth_sp_configtest() {
	if [ ! -s ${confdir}/${key} -o ! -s ${confdir}/${cert} ]; then
		run_rc_command keygen
	else
		# update from 2.4.x, chown %%SHIBD_USER%% the key and cert
	       	chown ${shibboleth_sp_usr}:${shibboleth_sp_group} ${confdir}/${key} ${confdir}/${cert}
		chmod 400 ${confdir}/${key}
		chmod 444 ${confdir}/${cert}
	fi
	# In FreeBSD 10 (r258664), /var/cache mode is corrected to 755. make sure we have that mode.
	chmod 755 /var/cache
	install -d -o ${shibboleth_sp_usr} -g ${shibboleth_sp_group} /var/log/shibboleth
	install -d -o ${shibboleth_sp_usr} -g ${shibboleth_sp_group} /var/cache/shibboleth
	install -d -o ${shibboleth_sp_usr} -g ${www_group} -m 750 /var/run/shibboleth
	${command} ${shibboleth_sp_flags} -u ${shibboleth_sp_usr} -g ${shibboleth_sp_group} -t
}

shibboleth_sp_keygen() {
	%%SH%% ${confdir}/keygen.sh -o ${confdir} -u ${shibboleth_sp_usr} -g ${shibboleth_sp_group}
}

extra_commands="configtest keygen"

run_rc_command "$1"