summaryrefslogtreecommitdiff
path: root/security/pks/files/pksd.sh
blob: 21d9334d45f2b32d56e52aa3a5ccac3311471c70 (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
73
74
75
76
77
78
#!@RCD_SCRIPTS_SHELL@
#
# $NetBSD: pksd.sh,v 1.7 2002/09/20 02:02:00 grant Exp $
#
# PROVIDE: pksd
# REQUIRE: DAEMON

if [ -f /etc/rc.subr ]
then
	. /etc/rc.subr
fi

name="pksd"
rcvar=${name}

command="@PREFIX@/bin/pksd"
run_command="@PREFIX@/bin/pks-queue-run.sh"
ctl_command="@PREFIX@/bin/pksdctl"
client_command="@PREFIX@/bin/pksclient"

conf_file="@PKG_SYSCONFDIR@/${name}.conf"
required_files="${conf_file}"
extra_commands="dbinit"

pksd_dbinit()
{
	(
	umask 022
	if [ -r ${conf_file} ]
	then
		dbdir=`@AWK@ '/db_dir/ { print $2 }' < ${conf_file}`
		if [ ! -f ${dbdir}/keydb000 -a -x ${client_command} ]
		then
			${client_command} ${dbdir} create
		fi
	fi
	)
}

pksd_start()
{
	if [ -r ${conf_file} -a -x ${command} -a -x ${run_command} ]
	then
		@ECHO@ "Starting ${name} (local)."
		@ECHO@ "${command} ${conf_file}"
		${command} ${conf_file} &
		sleep 5
		${run_command} ${conf_file}
	fi
}

pksd_stop()
{
	if [ -r ${conf_file} -a -x ${ctl_command} ]
	then
		socket=`@AWK@ '/socket_name/ { print $2 }' < ${conf_file}`
		if [ -S ${socket} ]
		then
			@ECHO@ "Stopping ${name} (local)."
			${ctl_command} ${socket} shutdown
		fi
	fi
} 

dbinit_cmd=pksd_dbinit
start_precmd=pksd_dbinit
start_cmd=pksd_start
stop_cmd=pksd_stop

if [ -f /etc/rc.subr ]
then
	load_rc_config $name
	run_rc_command "$1"
else
	@ECHO@ -n " ${name}"
	pksd_dbinit
	pksd_start
fi