blob: dd9a7b69e8e89084a72488fffd2bec2f59c0228b (
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: nslcd
# REQUIRE: NETWORKING slapd ldconfig resolv kstart
# BEFORE: syslogd
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf to enable the nslcd daemon:
#
# nslcd_enable="YES"
#
. /etc/rc.subr
name=nslcd
rcvar=nslcd_enable
load_rc_config ${name}
: ${nslcd_enable:=NO}
: ${nslcd_supervisor=NO}
command="/usr/sbin/daemon";
pidfile="%%NSLCD_PIDFILE%%"
start_precmd=nslcd_prestart
start_cmd=nslcd_start
status_cmd=nslcd_status
stop_cmd=nslcd_stop
nslcd_prestart()
{
if checkyesno nslcd_supervisor ; then
notsupported=$(${command} -r 3>&1 1>&2 2>&3 | grep -c illegal)
if [ ${notsupported} -eq 0 ]; then
command_args="-f -r %%PREFIX%%/sbin/nslcd -n"
else
echo "Your FreeBSD version's daemon(8) does not support supervision.";
echo "${name} was not started.";
exit 1
fi
else
command_args="-f %%PREFIX%%/sbin/nslcd"
fi
}
nslcd_start()
{
nslcd_findpid
if [ ! ${mypid} = '' ]; then
echo "${name} is running with PID ${mypid}.";
else
echo "Starting ${name}."
${command} ${command_args}
fi
}
nslcd_status()
{
nslcd_findpid
if [ ! ${mypid} = '' ]; then
echo "${name} is running with PID ${mypid}.";
else
echo "${name} not running?";
return 1
fi
}
nslcd_stop()
{
nslcd_findpid
if [ ! ${mypid} = '' ]; then
echo "Stopping ${name}.";
kill -TERM ${mypid};
wait_for_pids ${mypid};
else
echo "${name} not running?";
fi
}
nslcd_findpid()
{
if %%PREFIX%%/sbin/nslcd -c && pgrep -q -F %%NSLCD_PIDFILE%%; then
mypid=$(cat %%NSLCD_PIDFILE%%)
if checkyesno nslcd_supervisor; then
mypid=$(pgrep -f "daemon: %%PREFIX%%/sbin/nslcd\[${mypid}\]")
fi
fi
}
run_rc_command "$1"
|