Mapping an upstart job to a init.d script (sssd)

Petter Reinholdtsen pere at hungry.com
Thu Apr 29 05:45:37 UTC 2010


I am currently looking at the sssd package from Ubuntu, which only
provide an upstart job in the package.  As a test, I tried to convert
it to an init.d script, to see how easy it is to generate an init.d
script from a simple upstart job.  Here are both examples.  Is this a
sensible conversion?

I had to use my knowledge to come up with runlevels and dependency
information (surprised sssd should not start after the syslog
collector is operational on Ubuntu, and fail to stop in runlevel 1).
I also had to find the location of the binary from the package.

Comments?

=============== sssd.upstart =================
# sssd - System Security Services Daemon
#
# Provides a set of daemons to manage access to remote directories and
# authentication mechanisms. It provides an NSS and PAM interface toward
# the system and a pluggable backend system to connect to multiple different
# account sources.

description     "System Security Services Daemon"

start on filesystem
stop on runlevel [06]

expect fork
respawn

exec sssd -D
================= sssd.init ==================
### BEGIN INIT INFO
# Provides:          sssd
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: System Security Services Daemon
# Description:       Provides a set of daemons to manage access to
#                    remote directories and authentication
#                    mechanisms. It provides an NSS and PAM interface
#                    toward the system and a pluggable backend system
#                    to connect to multiple different account sources.
### END INIT INFO
# start on filesystem
# stop on runlevel [06]

DESCRIPTION="System Security Services Daemon"
PATH=/bin:/usr/bin:/sbin:/usr/sbin
NAME=sssd
OPTIONS="-D"
DAEMON=/usr/sbin/$NAME
PIDFILE=/var/run/$NAME.pid

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions

initdmain() {
    case "$1" in
        start)
            [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESCRIPTION" "$NAME"
            start_daemon -p $PIDFILE $DAEMON $OPTIONS
            RC=$?
            case "$RC" in
                0)
                    [ "$VERBOSE" != no ] && log_end_msg $RC
                    ;;
                *)
                # Report error also when VERBOSE=no
                    log_daemon_msg "Starting $DESCRIPTION" "$NAME"
                    log_end_msg $RC
                    ;;
            esac
            ;;
        stop)
            [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESCRIPTION" "$NAME"
            killproc -p $PIDFILE $DAEMON
            RC=$?
            case "$RC" in
                0)
                    [ "$VERBOSE" != no ] && log_end_msg $RC
                    ;;
                *)
                # Report error also when VERBOSE=no
                    log_daemon_msg "Stopping $DESCRIPTION" "$NAME"
                    log_end_msg $RC
                    ;;
            esac
            ;;
        force-reload|restart)
            $0 stop
            $0 start
            ;;
        status)
            status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
            ;;
        *)
            echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload|status}"
            exit 1
            ;;
    esac
}

initdmain $@

exit 0

Happy hacking,
-- 
Petter Reinholdtsen




More information about the initscripts-ng-devel mailing list