summaryrefslogtreecommitdiff
path: root/security/dirmngr/files/dirmngr.sh
blob: 94ed7f75d1acc0804535dd0fad35173ceb92c630 (plain)
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
#!@RCD_SCRIPTS_SHELL@
#
# $NetBSD: dirmngr.sh,v 1.2 2007/11/07 12:43:22 shannonjr Exp $
#
# PROVIDE: dirmngr
# REQUIRE: DAEMON
#

if [ -f @PKG_SYSCONFDIR@/rc.subr ]; then
	. @PKG_SYSCONFDIR@/rc.subr
fi

name="dirmngr"
rcvar="${name}"
dirmngr_user="@DIRMNGR_USER@"
dirmngr_group="@DIRMNGR_GROUP@"
dirmngr_flags="--daemon"
dirmngr_command="@PREFIX@/sbin/runDirmngr"
start_precmd="dirmngr_precmd"
start_cmd="dirmngr_start"
start_postcmd="dirmngr_postcmd"
stop_cmd="dirmngr_stop"
required_dirs="@PKG_SYSCONFDIR@/dirmngr"
required_files="@PKG_SYSCONFDIR@/dirmngr/ldapservers.conf"

dirmngr_precmd()
{
	mkdir -p @VARBASE@/run/dirmngr
	chgrp @DIRMNGR_GROUP@ @VARBASE@/run/dirmngr
	chmod 775 @VARBASE@/run/dirmngr
	mkdir -p /tmp/dirmngr
	chgrp @DIRMNGR_GROUP@ /tmp/dirmngr
	chmod 755 /tmp/dirmngr
}

dirmngr_start()
{
       for _f in $required_dirs; do
		if [ ! -d "${_f}/." ]; then
			warn "${_f} is not a directory."
			if [ -z $rc_force ]; then
				return 1
			fi
		fi
	done
	for _f in $required_files; do
		if [ ! -r "${_f}" ]; then
			warn "${_f} is not readable."
			if [ -z $rc_force ]; then
				return 1
			fi
		fi
	done
	eval `${dirmngr_command} ${rc_flags}`
}

dirmngr_postcmd()
{
	echo ${DIRMNGR_INFO} >/tmp/dirmngr/dirmngr.info
	chmod 644 /tmp/dirmngr/dirmngr.info
	dirmngr_pid=`cut -f 2 -d ':' /tmp/dirmngr/dirmngr.info`
}

dirmngr_stop()
{
	if [ -f /tmp/dirmngr/dirmngr.info ] ; then
		kill `cut -f 2 -d ':' /tmp/dirmngr/dirmngr.info`
	fi
}

load_rc_config $name
run_rc_command "$1"