Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions slapd-cli
Original file line number Diff line number Diff line change
Expand Up @@ -456,15 +456,18 @@ start_slapd() {
fi

# Presence of PID file
if [ ! -r $SLAPD_PID_FILE ]
if [ -n "$SLAPD_PID_FILE" ] && [ ! -r "$SLAPD_PID_FILE" ]
then
message "alert" "[ALERT] No PID file for OpenLDAP"
exit 1
fi

# Is slapd launched?
PID=`cat $SLAPD_PID_FILE`
if [ ! -e /proc/$PID ]
[ -n "$SLAPD_PID_FILE" ] && PID=$(cat "$SLAPD_PID_FILE")
if [ -z "$PID" ] && [ $_use_systemctl -eq 1 ]; then
PID=$(systemctl show --property MainPID --value "$SYSTEMD_SERVICE_NAME")
fi
if [ -n "$PID" ] && [ ! -e "/proc/$PID" ]
then
message "alert" "[ALERT] OpenLDAP not running"
exit 1
Expand All @@ -479,7 +482,7 @@ stop_slapd() {
message "info" "[INFO] Halting OpenLDAP..."

# Presence of PID file
if [ ! -r $SLAPD_PID_FILE ]
if [ -n "$SLAPD_PID_FILE" ] && [ ! -r "$SLAPD_PID_FILE" ]
then
message "info" "[INFO] Can't read PID file, to stop OpenLDAP try: $0 forcestop"
return 1
Expand Down Expand Up @@ -731,7 +734,7 @@ forcestop() {
message "info" "[INFO] Killing OpenLDAP with force..."

# Presence of PID file
if [ ! -r $SLAPD_PID_FILE ]
if [ -n "$SLAPD_PID_FILE" ] && [ ! -r "$SLAPD_PID_FILE" ]
then
# Escape special characters into $SLAPD_SERVICES
slapd_services="`echo "$SLAPD_SERVICES" | sed 's/\*/\\\*/g'`"
Expand All @@ -753,7 +756,10 @@ forcestop() {
fi
fi
else
PID=`cat $SLAPD_PID_FILE`
[ -n "$SLAPD_PID_FILE" ] && PID=$(cat "$SLAPD_PID_FILE")
if [ -z "$PID" ] && [ $_use_systemctl -eq 1 ]; then
PID=$(systemctl show --property MainPID --value "$SYSTEMD_SERVICE_NAME")
fi
if [ $( ${PS_COMMAND_PID} | grep "${PID}" | wc -l ) -eq 0 ] ; then
message "info" "[OK] OpenLDAP already stopped"
exit 0
Expand Down Expand Up @@ -782,7 +788,7 @@ slapd_status() {
fi

# Return 0 if slapd is running, 1 if slapd is stopped, 2 if we can't say
if [ ! -r $SLAPD_PID_FILE ]
if [ -n "$SLAPD_PID_FILE" ] && [ ! -r "$SLAPD_PID_FILE" ]
then
# Escape special characters into $SLAPD_SERVICES
slapd_services="`echo "$SLAPD_SERVICES" | sed 's/\*/\\\*/g'`"
Expand All @@ -795,7 +801,7 @@ slapd_status() {
return 2
fi
else
PID=`cat $SLAPD_PID_FILE`
[ -n "$SLAPD_PID_FILE" ] && PID=$(cat "$SLAPD_PID_FILE")
fi

if [ ! -e /proc/$PID ]
Expand Down Expand Up @@ -841,8 +847,10 @@ display_status() {

if [ $status -eq 0 ]
then
PID=`cat $SLAPD_PID_FILE`

[ -n "$SLAPD_PID_FILE" ] && PID=$(cat "$SLAPD_PID_FILE")
if [ -z $PID ] && [ $_use_systemctl -eq 1 ]; then
PID=$(systemctl show --property MainPID --value "$SYSTEMD_SERVICE_NAME")
fi
message "info" "[INFO] Process OpenLDAP is running (PID $PID)"
VER="$( slapd_version )"
if [ "${VER}" != "" ] ; then
Expand Down