/usr/sbin/stop-dirsrv is in 389-ds-base 1.3.2.16-0ubuntu1.
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 | #!/bin/sh
# Script that stops the ns-slapd server.
# Exit status can be:
#       0: Server stopped successfully
#       1: Server could not be stopped
#       2: Server was not running
. /usr/share/dirsrv/data/DSSharedLib
stop_instance() {
    SERV_ID=$1
    initfile=`get_init_file $initconfig_dir $SERV_ID` || { echo Instance $SERV_ID not found. ; return 1 ; }
    # source env. for this instance
    if [ -f $initfile ] ; then
        . $initfile
    else
        echo Instance $SERV_ID not found.
        return 1
    fi
    PIDFILE=$RUN_DIR/$PRODUCT_NAME-$SERV_ID.pid
    if test ! -f $PIDFILE ; then
        echo No ns-slapd PID file found. Server is probably not running
        return 2
    fi
    PID=`cat $PIDFILE`
    # see if the server is already stopped
    kill -0 $PID > /dev/null 2>&1 || {
        echo Server not running
        if test -f $PIDFILE ; then
            rm -f $PIDFILE
        fi
        return 2
    }
    
    #
    # use systemctl if running as root
    #
    if [ -d "" ] && [ "$(id -u)" == "0" ];then
        # 
        # Now, check if systemctl is aware of this running instance
        #
        /usr/bin/systemctl is-active dirsrv@$SERV_ID.service > /dev/null 2>&1
        if [ $? -eq 0 ]; then
            # 
            # systemctl sees the running process, so stop it correctly
            #
            /usr/bin/systemctl stop dirsrv@$SERV_ID.service
        else
            # 
            # Have to kill it since systemctl doesn't think it's running
            #
            kill $PID
        fi
    else
        # server is running - kill it
        kill $PID
    fi
    
    # wait for 10 minutes (600 times 1 second)
    loop_counter=1
    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
            return 0
        fi
    done
    if test -f $PIDFILE ; then
        echo Server still running!! Failed to stop the ns-slapd process: $PID.  Please check the errors log for problems.
    fi
    return 1
}
while getopts "d:" flag
do
    case "$flag" in
        d) initconfig_dir="$OPTARG";;
    esac
done
shift $(($OPTIND-1))
if [ "$initconfig_dir" = "" ]; then
    initconfig_dir=/etc/default
fi
if [ "$#" -eq 0 ]; then
    # We're stopping all instances.
    ret=0
    initfiles=`get_initconfig_files $initconfig_dir` || { echo No instances found in $initconfig_dir ; exit 1 ; }
    for i in $initfiles; do
        if [ ! -f "$i" ] ; then
            echo No instances found in $initconfig_dir
            exit 1
        fi
        inst=`normalize_server_id $i`
        echo Stopping instance \"$inst\"
        stop_instance $inst
        rv=$?
        if [ "$rv" -ne 0 ]; then
            ret=$rv
        fi
    done
    exit $ret
else
    # We're stopping a single instance.
    stop_instance $@
    exit $?
fi
 |