Re: openldap and FDS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2007-03-09 at 21:01 -0500, Ric Moore wrote:
> On Fri, 2007-03-09 at 19:37 +0530, Rahul Sundaram wrote:
> > Ric Moore wrote:
> > > On Fri, 2007-03-09 at 19:22 +0530, Rahul Sundaram wrote:
> > >> Ric Moore wrote:
> > >>
> > >>> I installed the fedora-ds-1.0.4-1.FC6.i386.opt.rpm
> > >>> Do I now yum install fedora-ds-base after? There are no init scripts in
> > >>> the original rpm, that are installed to /etc/rc.d/init.d/
> > >>> I'd like to get this right the first time. 
> > >> If you already installed fedora-ds package, don't bother with 
> > >> fedora-ds-base which is a subset. The advantage to the package in the 
> > >> repository is that it better follows Fedora packaging guidelines.
> > > 
> > > And the init scripts? I'd rather the entire affair be yumable and
> > > following Fedora packaging quide-lines. What would you do? I have done
> > > anything at this point other than run the config script, I have no
> > > problem doing this right and running through the config process again. 
> > 
> > Check fedora directory server announce list and fedora directory server 
> > list for details. You can continue further discussions on the latter.
> 
> That wasn't particularly the answer I needed. :( Ric
----
2 scripts follow...

# cat /etc/init.d/fds
#!/bin/sh
# Startup script for Fedora Directory Server
#
# chkconfig: 345 86 14
# description: Run each LDAP slapd server in the Fedora Directory Server

# Source function library.
. /etc/rc.d/init.d/functions

myName=`basename $0`
fdsRoot="/opt/fedora-ds"

# Get a list of all slapd server ID's
# We will iterate over all server ID's when executing a command
if [ -d ${fdsRoot}/slapd-srv1 ]; then
    serverIDS=`ls -d $fdsRoot/slapd-srv1 | sed -r 's!.*/slapd-([^/]+)/?!
\1!'`
else
    servierIDS=""
fi

start()
{
    RETVAL=0
    failed=""
    listSeparator=""
    failSeparator=""
    echo -n "Starting slapd trying: "
    for serverID in $serverIDS; do
        slapd="slapd-${serverID}"
        echo -n "${listSeparator}${serverID}"
        ${fdsRoot}/${slapd}/start-slapd > /dev/null 2>&1
        slapdStatus=$?
        # 0: Server started successfully
        # 1: Server could not be started
        # 2: Server already running
        if [ $slapdStatus = 0 ]; then
            touch /var/lock/subsys/${slapd}
        else

failed="${failed}${failSeparator}${serverID}(${slapdStatus})"
            failSeparator=","
            RETVAL=$slapdStatus
        fi
        listSeparator=","
    done

    if [ ! -z $failed ]; then
        echo -n " (FAIL ${failed})"
    fi

    if [ $RETVAL -eq 0 ]; then
        success
    else
        failure
    fi
    echo

    return $RETVAL
}

stop()
{
    RETVAL=0
    failed=""
    listSeparator=""
    failSeparator=""
    echo -n "Stopping slapd trying: "
    for serverID in $serverIDS; do
        slapd="slapd-${serverID}"
        echo -n "${listSeparator}${serverID}"
        ${fdsRoot}/${slapd}/stop-slapd > /dev/null 2>&1
        slapdStatus=$?
        # 0: Server stopped successfully
        # 1: Server could not be stopped
        # 2: Server was not running
        if [ $slapdStatus = 0 ]; then
            rm -f /var/lock/subsys/${slapd}
        else
            if [ $slapdStatus != 1 ]; then
                rm -f /var/lock/subsys/${slapd}
            fi

failed="${failed}${failSeparator}${serverID}(${slapdStatus})"
            failSeparator=","
            RETVAL=$slapdStatus
        fi
        listSeparator=","
    done

    if [ ! -z $failed ]; then
        echo -n " (FAIL ${failed})"
    fi

    if [ $RETVAL -eq 0 ]; then
        success
    else
        failure
    fi
    echo

    return $RETVAL
}

restart()
{
    stop
    start
}

condrestart()
{
    RETVAL=0
    failed=""
    listSeparator=""
    failSeparator=""
    echo -n "Restarting slapd trying: "
    for serverID in $serverIDS; do
        slapd="slapd-${serverID}"
        if [ -f /var/lock/subsys/${slapd} ]; then
            echo -n "${listSeparator}${serverID}"
            ${fdsRoot}/${slapd}/restart-slapd > /dev/null 2>&1
            slapdStatus=$?
            # 0: Server restarted successfully
            # 1: Server could not be started
            # 2: Server started successfully (was not running)
            # 3: Server could not be stopped
            if [ $slapdStatus = 0 ]; then
                touch /var/lock/subsys/${slapd}
            else

failed="${failed}${failSeparator}${serverID}(${slapdStatus})"
                failSeparator=","
                RETVAL=$slapdStatus
            fi
            listSeparator=","
        fi
    done

    if [ ! -z $failed ]; then
        echo -n " (FAIL ${failed})"
    fi

    if [ $RETVAL -eq 0 ]; then
        success
    else
        failure
    fi
    echo

    return $RETVAL
}

status()
{

    # Note: there are two pid files in the slapd-*/logs directory a
    # startpid file and a pid file. The startpid file is written when
    # the server is attempting to initialize, this may take a long
    # time. When the server is fully initialized and ready to receive
    # connections the pid file is written. Thus there is the question
    # of what constitutes running, initializing or ready? In this
    # instance we decide to report a running state when the server is
    # fully initalized and ready to serve clients.

    # init.d status should return:
    # 0  "$prog (pid $pid) is running..."
    # 1  "$prog dead but pid file exists"
    # 2  "$prog dead but subsys locked"
    # 3  "$prog is stopped"

    RETVAL=0
    for serverID in $serverIDS; do
        slapd="slapd-${serverID}"

        pidFile=${fdsRoot}/${slapd}/logs/pid
        if test -f $pidFile ; then
            pid=`cat $pidFile`
            if kill -0 $pid > /dev/null 2>&1 ; then
                # slapd process $pid is running
                echo "$slapd (pid $pid) is running..."
            else
                echo "$slapd dead but pid file exists"
                if [ $RETVAL -eq 0 ]; then
                    RETVAL=1
                fi
            fi
        else
            if [ -f /var/lock/subsys/${slapd} ]; then
                echo "$slapd dead but subsys locked"
                if [ $RETVAL -eq 0 ]; then
                    RETVAL=2
                fi
            else
                echo "$slapd is stopped"
                if [ $RETVAL -eq 0 ]; then
                    RETVAL=3
                fi
            fi
        fi

    done

    return $RETVAL
}


case "$1" in
start)
    start
    RETVAL=$?
    ;;
stop)
    stop
    RETVAL=$?
    ;;
reload|restart)
    restart
    RETVAL=$?
    ;;
condrestart)
    condrestart
    RETVAL=$?
    ;;
status)
    status
    RETVAL=$?
    ;;
*)
    echo $"Usage: $myName {start|stop|restart|condrestart|status}"
    RETVAL=3
esac

exit $RETVAL

***** the second script *****

 cat /etc/init.d/fds-admin
#!/bin/sh
#
# fedora-ds-admin      Start/Stop the fedora DS admin daemon.
#
# chkconfig: 2345 99 01
# description: Run LDAP Adminstration console

# Source function library.
. /etc/init.d/functions

myName=`basename $0`

# Source our configuration file for these variables.
FLAGS=
RETVAL=0

# Set up some common variables before we launch into what might be
# considered boilerplate by now.
path_start=/opt/fedora-ds/start-admin
path_restart=/opt/fedora-ds/restart-admin
path_stop=/opt/fedora-ds/stop-admin
path=./ns-httpd
prog="Fedora-DS Admin"

start() {
        echo -n $"Starting $prog: "
        daemon $path_start
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
        return $RETVAL
}

stop() {
        echo -n $"Stopping $prog: "
        $path_stop
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
        return $RETVAL
}
restart() {
        echo -n $"Restarting $prog: "
        daemon $path_restart
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
        return $RETVAL
}


case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        restart
        ;;
  status)
        status $path
        ;;
  condrestart)
        [ -f /var/lock/subsys/$prog ] && restart || :
        ;;
  *)
        echo $"Usage: $0 {start|stop|status|reload|restart|condrestart}"
        exit 1
esac

exit $?



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux