/etc/init.d/dirsrv-admin is in 389-admin 1.1.35-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | #!/bin/sh
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4
### BEGIN INIT INFO
# Provides: dirsrv-admin
# Required-Start: $remote_fs dirsrv
# Required-Stop: $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop 389 Directory Admin Server
# Description: dirsrv is the Admin server for 389 LDAP Directory
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
test -f /etc/default/dirsrv-admin && . /etc/default/dirsrv-admin
. /lib/lsb/init-functions
DISTRO=$(lsb_release -is 2>/dev/null || echo Debian)
CONFIG_DIR="/etc/dirsrv"
BASEEXEC="start-ds-admin"
EXEC="/usr/sbin/$BASEEXEC"
PROG="ds-admin"
PIDDIR="/var/run/dirsrv-admin"
ADMCONF="$CONFIG_DIR/admin-serv/adm.conf"
check_network() {
if [ -z "$(/sbin/ifconfig)" ]; then
log_action_msg "No networks configured."
return 1
fi
return 0
}
# On Solaris /var/run is in tmpfs and gets wiped out upon reboot
# we have to recreate the /var/run/dirsrv-admin directory
# We also have to make sure that the directory is writable
# by the directory server process
# the argument to this function is the server instance directory,
# which must have a dse.ldif file in it
fix_pid_dir_ownership()
{
if [ -d $piddir ] ; then
owner=`grep \^sysuser "$ADMCONF" | awk '{print $2}'`
dirowner=`ls -ld $piddir | awk '{print $3}'`
dirgrp=`ls -ld $piddir | awk '{print $4}'`
if [ "$owner" != "$dirowner" ]; then
groups $owner | grep $dirgrp > /dev/null 2>&1
rc=$?
if [ $rc -eq 0 ]; then
chmod 770 $piddir
else
log_failure_msg "$piddir is not writable for $owner"
exit 1
fi
fi
else
mkdir -p $piddir
owner=`grep \^nsslapd-localuser $1/dse.ldif | awk '{print $2}'`
if [ -n "$owner" ] ; then
chown $owner $piddir
chmod 700 $piddir
fi
fi
}
start_script=/usr/sbin/start-ds-admin
restart_script=/usr/sbin/restart-ds-admin
stop_script=/usr/sbin/stop-ds-admin
exec=`grep "^HTTPD=" $start_script | awk -F= '{print $2}'`
prog="dirsrv-admin"
# PID directory
piddir="/var/run/dirsrv"
# PID file
pidfile=$piddir/admin-serv.pid
[ -f $exec ] || exit 0
if [ ! -f "$ADMCONF" ]; then
log_action_msg "No $ADMCONF file is present"
# Quit without failing since the server is not configured yet
exit 0
fi
umask 077
# since we use the start script to start admin, we source the
# init config file there, not here
# if we ever get rid of the start script, we'll have to uncomment
# the following line
#[ -f /etc/default/dirsrv-admin ] && . /etc/default/dirsrv-admin
start() {
if [ ! -f $start_script ]; then
log_failure_msg "*** Error: $start_script does not exist"
exit 1
fi
echo "Starting $prog: "
# the server creates pidfile and writes the pid to it when it is fully
# started and available to serve clients
server_running=0
if [ -f $pidfile ]; then
pid=`cat $pidfile`
if kill -0 $pid > /dev/null 2>&1 ; then
log_success_msg " already running"
server_running=1
else
log_warning_msg " not running, but pid file exists - attempt to start anyway..."
rm -f $pidfile
fi
fi
server_started=0
if [ $server_running -eq 0 ] ; then
rm -f $pidfile
fix_pid_dir_ownership
$start_script
if [ $? -eq 0 ]; then
server_started=1 # well, perhaps not running, but started ok
else
failure; echo
fi
fi
if [ $server_started -eq 1 ] ; then
loop_counter=1
# wait for 10 minutes (600 times 1 seconds)
max_count=600
while test $loop_counter -le $max_count ; do
loop_counter=`expr $loop_counter + 1`
if test ! -f $pidfile ; then
sleep 1
else
pid=`cat $pidfile`
break
fi
done
if kill -0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
log_success_msg " success"
else
log_failure_msg "*** Error: $prog failed to start"
fi
fi
}
stop() {
if [ ! -f $stop_script ]; then
log_failure_msg "$stop_script does not exist"
exit 1
fi
echo "Shutting down $prog: "
if [ -f $pidfile ]; then
pid=`cat $pidfile`
server_stopped=0
if kill -0 $pid > /dev/null 2>&1 ; then
kill $pid
if [ $? -eq 0 ]; then
server_stopped=1
else
failure; echo
fi
fi
if [ $server_stopped -eq 1 ] ; then
loop_counter=1
# wait for 10 minutes (600 times 1 second)
max_count=600
while test $loop_counter -le $max_count; do
loop_counter=`expr $loop_counter + 1`
if kill -0 $pid > /dev/null 2>&1 ; then
sleep 1
else
if test -f $pidfile ; then
rm -f $pidfile
fi
break
fi
done
if test -f $pidfile ; then
log_failure_msg "*** Error: $prog failed to stop"
else
log_success_msg " success"
rm -f $pidfile
fi
fi
fi
}
restart() {
stop
start
}
status() {
if [ -f $pidfile ]; then
pid=`cat $pidfile`
if kill -0 $pid > /dev/null 2>&1 ; then
log_daemon_msg "$prog (pid $pid) is running..." "dirsrv-admin"
else
log_daemon_msg "$prog dead but pid file exists" "dirsrv-admin"
fi
else
echo "$prog is stopped"
fi
}
case "$1" in
start|stop|restart|reload|status|force-reload)
$1
;;
condrestart)
[ ! -f $lockfile ] || restart
;;
*)
echo Unknown command $1
echo "Usage: $0 {start|stop|status|restart|condrestart}"
exit 2
esac
|