aboutsummaryrefslogtreecommitdiff
path: root/security/kstart/files/kstart.in
blob: 76f9502f3f443f41a269afacaeda4bf6ef957459 (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
63
64
65
66
67
68
#!/bin/sh

# PROVIDE: kstart
# REQUIRE: DAEMON
# BEFORE: LOGIN
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable kstart:
# kstart_enable (bool):		Set to YES to enable kstart
# 				Default: NO
# kstart_flags (str):		Extra flags passed to kstart
#				Default: -LUFK 120
# kstart_keytab (str):		Default keytab file to use
#				Default: /etc/krb5.keytab
#
# To enable multi-instance support, use:
# kstart_instances="name1 name2"
# kstart_name1_keytab="/path/to/keytab"


. /etc/rc.subr

name="kstart"
rcvar=kstart_enable

command="%%PREFIX%%/bin/k5start"
pidfile="/var/run/kstart.pid"

load_rc_config $name

[ -z "$kstart_enable" ]			&& kstart_enable="NO"
[ -z "$kstart_keytab" ]			&& kstart_keytab="/etc/krb5.keytab"
[ -z "$kstart_flags" ]			&& kstart_flags="-LUFK 120"
[ -z "$kstart_instances" ]		&& kstart_instances="system"
[ -z "$kstart_local_instances" ]	&& kstart_local_instances=""
[ -z "$kstart_system_keytab" ]		&& kstart_system_keytab="$kstart_keytab"
[ -z "$kstart_system_flags" ]		&& kstart_system_flags="$kstart_flags"

if [ -n "$kstart_local_instances" ]; then
	kstart_instances="$kstart_instances $kstart_local_instances"
fi

if [ -n "$kstart_instances" ]; then
  _1=$1
  if [ $# -gt 1 ]; then shift; kstart_instances=$*; fi
  kstart_keytab=""
  kstart_flags=""
  rc=0
  for i in ${kstart_instances}; do
	eval _keytab=\$kstart_${i}_keytab
	if [ -z "$_keytab" ]; then
	    _keytab="/etc/krb5.keytab"
	fi
	eval _flags=\$kstart_${i}_flags
	if [ -z "$_flags" ]; then
	    _flags="-LUFK 120"
	fi
	eval pidfile="/var/run/kstart_${i}.pid"
	command_args="-bf $_keytab $_flags -p $pidfile"
        run_rc_command "$_1"
        if [ $? -ne 0 ]; then rc=1; fi
	unset _pidcmd _rc_restart_done
   done
   exit $rc
else
	command_args="-bf $kstart_keytab $kstart_flags -p $pidfile"
	run_rc_command "$1"
fi