File: restart-dirsrv.in

package info (click to toggle)
389-ds-base 1.4.0.21-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 50,776 kB
  • sloc: ansic: 303,582; python: 59,673; cpp: 10,380; perl: 5,807; sh: 2,654; makefile: 2,457; yacc: 806; xml: 376; lex: 366; java: 50
file content (63 lines) | stat: -rw-r--r-- 1,477 bytes parent folder | download | duplicates (2)
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
#!/bin/bash

# Script that restarts the ns-slapd server.
# Exit status can be:
#       0: Server restarted successfully
#       1: Server could not be started
#       2: Server started successfully (was not running)
#       3: Server could not be stopped

. @datadir@/@package_name@/data/DSSharedLib

restart_instance() {
    SERV_ID=$1

    server_already_stopped=0
    @sbindir@/stop-dirsrv -d $initconfig_dir $SERV_ID
    status=$?
    if [ $status -eq 1 ] ; then
        return 3;
    else
       if [ $status -eq 2 ] ; then
            server_already_stopped=1
       fi
    fi
    @sbindir@/start-dirsrv -d $initconfig_dir $SERV_ID
    status=$?
    if [ $server_already_stopped -eq 1 ] && [ $status -eq 0 ] ; then
        return 2;
    fi
    return $status
}

while getopts "d:" flag
do
    case "$flag" in
        d) initconfig_dir="$OPTARG";;
    esac
done
shift $(($OPTIND-1))

if [ "$initconfig_dir" = "" ]; then
    initconfig_dir=@initconfigdir@
fi

if [ "$#" -eq 0 ]; then
    # We're restarting all instances.
    ret=0
    initfiles=`get_initconfig_files $initconfig_dir` || { echo No instances found in $initconfig_dir ; exit 1 ; }
    for i in $initfiles; do
        inst=`normalize_server_id $i`
        echo Restarting instance \"$inst\"
        restart_instance $inst
        rv=$?
        if [ "$rv" -ne 0 ]; then
            ret=$rv
        fi
    done
    exit $ret
else
    # We're restarting a single instance.
    restart_instance $*
    exit $?
fi