2
# ex: set tabstop=4 expandtab shiftwidth=4:
4
# Copyright (c) Centeris Corporation 2006
5
# Author: Gerald Carter <jerry@centeris.com>
7
# /etc/init.d/likewise-open
9
#LWI_STARTUP_TYPE_REDHAT###
10
#LWI_STARTUP_TYPE_REDHAT# chkconfig: 35 90 10
11
#LWI_STARTUP_TYPE_REDHAT# description: Start and Stop the Centeris Likewise Identity Auth Daemon
12
#LWI_STARTUP_TYPE_REDHAT###
13
#LWI_STARTUP_TYPE_SUSE#
14
#LWI_STARTUP_TYPE_SUSE### BEGIN INIT INFO
15
#LWI_STARTUP_TYPE_SUSE# Provides: likewise-open
16
#LWI_STARTUP_TYPE_SUSE# Required-Start: $network $remote_fs
17
#LWI_STARTUP_TYPE_SUSE# Required-Stop: $network $remote_fs centeris.com-gpagentd
18
#LWI_STARTUP_TYPE_SUSE# Default-Start: 3 5
19
#LWI_STARTUP_TYPE_SUSE# Default-Stop: 0 1 2 6
20
#LWI_STARTUP_TYPE_SUSE# Description: Start the Centeris Likewise Identity Auth Daemon
21
#LWI_STARTUP_TYPE_SUSE### END INIT INFO
23
CONF=/etc/samba/lwiauthd.conf
25
AUTHD_BIN=${CENTERIS_PREFIX}/sbin/likewise-winbindd
26
PIDFILE=/var/run/likewise-winbindd.pid
27
SCRIPTNAME="likewise-open"
29
## Have to set the path for HP-UX boot process
30
PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
33
if [ ! -f ${CONF} ]; then
34
echo "Missing ${CONF}"
38
PROG_BIN="${AUTHD_BIN}"
40
if [ ! -x ${AUTHD_BIN} ]; then
41
echo "Missing ${AUTHD_BIN}"
46
## Determine what platform we are on
49
if [ -f /etc/init.d/functions ]; then
50
. /etc/init.d/functions
52
elif [ -f /etc/rc.status ]; then
55
elif [ -f /etc/debian_version ]; then
56
. /lib/lsb/init-functions
58
elif [ `uname -s` = 'AIX' ]; then
60
elif [ `uname -s` = 'HP-UX' ]; then
66
if [ $PLATFORM = "HP-UX" ]; then
67
LOCKFILE="/var/run/${SCRIPTNAME}.lock"
69
LOCKFILE="/var/lock/subsys/${SCRIPTNAME}"
72
if ! type printf 1>/dev/null 2>/dev/null; then
73
# Usually printf is a shell built in, but on HPUX it is a program located
74
# at /bin/printf. During system startup and shutdown the path is only
75
# /sbin, so we need to manually find printf
76
if [ -x /bin/printf ]; then
77
alias printf=/bin/printf
79
echo "WARNING: unable to find printf program"
83
# echo_replacement emulates echo for all platforms using printf. printf is a
84
# shell builtin that exists on all platforms.
87
if [ "$1" = "-n" ]; then
95
# 'echo -n' works with bash, but not with sh on Solaris, HPUX, and AIX.
96
if [ "`echo -n`" = "-n" ]; then
97
alias echo=echo_replacement
106
echo too few arguments
3
# Provides: likewise-open
4
# Required-Start: $network $local_fs $remote_fs
5
# Required-Stop: $network $local_fs $remote_fs
6
# Default-Start: 2 3 4 5
7
# Default-Stop: S 0 1 6
8
# Short-Description: Start likewise-open
9
# Description: Start and Stop the Likewise Identity Auth Daemon
12
# Author: Rick Clark <rick.clark@ubuntu.com>
15
# PATH should only include /usr/* if it runs after the mountnfs.sh script
16
PATH=/usr/sbin:/usr/bin:/sbin:/bin
18
DESC="Start and Stop the Likewise Identity Auth Daemon"
19
NAME=likewise-winbindd
20
DAEMON=/usr/sbin/$NAME
21
PIDFILE=/var/run/$NAME.pid
24
# Exit if the package is not installed
25
[ -x "$DAEMON" ] || exit 0
27
# Read configuration variable file if it is present
28
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
30
# Load the VERBOSE setting and other rcS variables
31
[ -f /etc/default/rcS ] && . /etc/default/rcS
35
# Define LSB log_* functions.
36
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
37
. /lib/lsb/init-functions
42
log_daemon_msg "Starting the Likewise-open auth daemon"
43
start-stop-daemon --start --quiet --oknodo --exec $DAEMON
48
log_daemon_msg "Stopping the Likewise-open auth daemon"
49
start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
53
pidofproc -p $PIDFILE $DAEMON >/dev/null
55
if [ $status -eq 0 ]; then
56
log_success_msg "$NAME is running"
58
log_failure_msg "$NAME is not running"
64
$0 stop && sleep 2 && $0 start
122
echo too many arguments
127
while [ $i -le $LAST ]; do
129
let "i = i + $INCREMENT"
134
# seq doesn't exist on HPUX
135
if ! type seq 2>/dev/null 1>/dev/null; then
136
alias seq=seq_replacement
140
## small wrapper functions around distro specific calls
144
case "${PLATFORM}" in
155
AIX | HP-UX | UNKNOWN)
163
case "${PLATFORM}" in
174
AIX | HP-UX | UNKNOWN)
183
if [ $status = 0 ]; then
186
status_failed $status
192
#Uses return codes specified in
193
# http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
194
if [ -f "$PIDFILE" ]; then
195
local pid="`cat "${PIDFILE}"`";
198
#Does the program with that pid match our program name?
199
#HP-UX needs UNIX95 set to support the -o option
200
local pid_comm="`UNIX95=1 ps -p $pid -o args= | awk '{print $1}'`"
201
if [ "$pid_comm" = "<defunct>" ]; then
202
#It is a zombie process
205
if [ "$pid_comm" = "${PROG_BIN}" ]; then
206
#If the system keeps cmdline files, check it
207
if [ -e /proc/${pid}/cmdline ]; then
208
#We can't check the exe file because we may be looking
209
#at a version of the program that has been overwritten
210
grep -q ${PROG_BIN} /proc/${pid}/cmdline && return 0
216
#Program is dead, but lock file exists
217
[ -f "${LOCKFILE}" ] && return 2
219
#Program is dead, but pid file exists
223
#Program is not running
228
case "${PLATFORM}" in
230
echo -n $"Starting `basename ${AUTHD_BIN}`: "
235
echo -n "Starting Centeris Authentication Services"
236
startproc ${AUTHD_BIN}
240
log_daemon_msg "Starting Likewise Open Authentication Services" "likewise-open"
241
start-stop-daemon --start --exec ${AUTHD_BIN}
247
echo -n "Starting Centeris Authentication Services"
248
if (lssrc -s dhcpcd | grep active >/dev/null); then
249
# Wait up to 30 seconds for an ip address
250
for i in `seq 30`; do
251
ifconfig -a | grep inet | grep -v 127.0.0 | grep -v 0.0.0.0 | grep -v ::1/0 >/dev/null && break
257
if [ $status -eq 0 ]; then
260
#Did the program start?
263
[ $status -eq 0 ] && break
267
if [ $status -eq 0 ]; then
268
#This command will wait for likewise-winbindd to initialize before
270
#Ignore the exit code incase we aren't joined to a domain
271
$CENTERIS_PREFIX/bin/lwiinfo -D `$CENTERIS_PREFIX/bin/lwiinfo --own-domain` 1>/dev/null 2>/dev/null
275
echo -n "Starting Centeris Authentication Services"
278
if [ $status -eq 0 ]; then
281
#Did the program start?
284
[ $status -eq 0 ] && break
295
[ $status = 0 ] && [ ${PLATFORM} != "DEBIAN" ] && touch ${LOCKFILE}
300
case "${PLATFORM}" in
302
echo -n $"Stopping `basename ${AUTHD_BIN}`: "
303
killproc `basename ${AUTHD_BIN}`
307
echo -n "Stopping Centeris Authentication Services"
308
killproc -TERM ${AUTHD_BIN}
312
log_daemon_msg "Stopping Likewise Open Authentication Services"
314
#only try to stop the daemon if it is running
315
if generic_status; then
316
kill -TERM "`cat "${PIDFILE}"`"
318
#Wait up to 5 seconds for the program to end
320
#Did the program end?
322
[ $? -ne 0 -a $? -ne 4 ] && status=0 && break
323
# use the following line instead after bug 3634 is fixed
324
#[ $? -eq 3 -o $? -eq 2 ] && status=0 && break
331
echo -n "Stopping Centeris Authentication Services"
333
#only try to stop the daemon if it is running
334
if generic_status; then
335
pid="`cat "${PIDFILE}"`"
338
#Wait up to 5 seconds for the program to end
340
#Did the program end?
342
[ $? -ne 0 -a $? -ne 4 ] && status=0 && break
343
# use the following line instead after bug 3634 is fixed
344
#[ $? -eq 3 -o $? -eq 2 ] && status=0 && break
350
killall -TERM `basename ${AUTHD_BIN}`
355
[ $status = 0 ] && rm -f ${LOCKFILE}
360
case "${PLATFORM}" in
365
checkproc ${AUTHD_BIN}
369
#After the AIX functions are found safe, we should use them here
371
if [ -e ${PIDFILE} ]; then
373
if [ -e /proc/${pid}/cmdline ]; then
374
grep -q ${AUTHD_BIN} /proc/${pid}/cmdline
380
if [ $status = 0 ]; then
396
#Use the bellow line instead after bug 3634 is fixed
397
#echo "died leaving pid file";
400
echo "died leaving lock file";
409
echo "Not implemented."
414
#Sends the signal specified by the first parameter to all instances
418
#This gets the list of all current running instances of PROG_BIN,
419
#but it can't tell which directory the program was run from. If
420
#cmdline is available in the proc pseudo-filesystem, we'll verify
422
local unverified_pids=`UNIX95=1 ps -e -o pid,args= | grep "${PROG_BIN}" | awk '{print $1}'`
424
for pid in $unverified_pids; do
425
#If the system keeps cmdline files, check them
426
if [ -e /proc/${pid}/cmdline ]; then
427
#We can't check the exe file because we may be looking
428
#at a version of the program that has been overwritten
429
grep -q ${AUTHD_BIN} /proc/${pid}/cmdline && pids="$pids $pid"
436
[ ! -z "`UNIX95=1 ps -p $pid -o pid=`" ] && kill "$1" $pid
439
#The manpage of killall says it returns 0 if at least one process is
440
#killed. I can't get it to return anything other than 0. Even if no
441
#processes die with SIGTERM. We'll just return 0 here too
445
####################################################################
446
## Main init script code
464
echo "Stopping Centeris Authentication Services"
470
echo "Starting Centeris Authentication Services"
478
# Start can't follow a stop too closely on Debian...
479
if [ ${PLATFORM} = "DEBIAN" ]; then
495
# Start can't follow a stop too closely on Debian...
496
if [ ${PLATFORM} = "DEBIAN" ]; then
505
echo -n "Reloading Centeris Authentication configuration file"
506
if [ ${PLATFORM} = "AIX" ] || [ ${PLATFORM} = "HP-UX" ]; then
507
#killall on AIX cannot search for a program name. We have to use
511
killall -HUP `basename ${AUTHD_BIN}`
518
echo "Usage: $0 {start|stop|restart|status|reload|force-reload}"
68
echo "Usage: $0 {start|stop|status|restart|force-reload}"
525
####################################################################