blob: f34dc0af6e8c13b620dc8f19c7f513204d24b96e (
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
#!/bin/sh
# PROVIDE: pksd
# REQUIRE: DAEMON
# KEYWORD: SHUTDOWN
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# pksd_enable (bool): Set to NO by default.
# Set it to YES to enable pksd.
#
# pksd_config (path): Set to %%PREFIX%%/etc/pksd.conf
# by default.
#
# pksd_mailq_enable (bool): Set to NO by default. Process incoming
# mail queue of commands and key requests
# (you will need to configure your mail
# infrastructure to enable this. See:
# %%PREFIX%%/share/doc/pks/README and
# %%PREFIX%%/share/doc/pks/EMAIL for details.
#
# pksd_queue_delay (int): Periodically process incoming mail.
# Set to 60 seconds by default.
. /etc/rc.subr
name="pksd"
rcvar=pksd_enable
load_rc_config $name
: ${pksd_enable:="NO"}
: ${pksd_mailq_enable:="NO"}
: ${pksd_config="%%PREFIX%%/etc/pksd.conf"}
: ${pksd_queue_delay="60"}
command="%%PREFIX%%/sbin/${name}"
command_args="%%PREFIX%%/etc/${name}.conf"
required_files="${pksd_config}"
start_precmd="${name}_precmd"
start_cmd="${name}_start"
#start_postcmd="${name}_runqueue"
stop_command="${name}_clean_stop"
pidfile="/var/run/${name}.pid"
pksd_precmd()
{
if [ ! -f %%PREFIX%%/etc/${name}.conf ]
then
exit 0
else
dbdir=`awk '/db_dir/ { print $2 }' < %%PREFIX%%/etc/${name}.conf`
fi
if [ ! -f ${dbdir}/keydb000 -a -x %%PREFIX%%/bin/pksclient ]
then
%%PREFIX%%/bin/pksclient ${dbdir} create
fi
}
pksd_start()
{
echo "Starting pksd"
/usr/sbin/daemon -f -p ${pidfile} ${command} ${command_args}
}
pksd_runqueue()
{
if [ -x %%PREFIX%%/bin/${name}ctl -a -x %%PREFIX%%/bin/pks-queue-run.sh ] && checkyesno pksd_mailq_enable
then
echo "Doing queue run for ${name} every ${pksd_queue_delay} seconds."
sleep 2
%%PREFIX%%/bin/pks-queue-run.sh %%PREFIX%%/etc/${name}.conf ${pksd_queue_delay}
fi
}
pksd_clean_stop()
{
if [ ! -f %%PREFIX%%/etc/${name}.conf ]
then
exit 0
else
socket=`awk '/socket_name/ { print $2 }' < %%PREFIX%%/etc/${name}.conf`
fi
if [ -x %%PREFIX%%/bin/${name}ctl -a -S ${socket} ]
then
echo "Shutting down ${name} socket connections using pksdctl."
%%PREFIX%%/bin/${name}ctl ${socket} shutdown
else
echo "couldn't stop ${name}."
fi
}
load_rc_config $name
run_rc_command "$1"
|