mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Alexander Dahl <post@lespocky.de>
To: ptxdist@pengutronix.de
Subject: Re: [ptxdist] [PATCH] [lldpd] add package
Date: Wed, 11 Sep 2013 15:16:26 +0200	[thread overview]
Message-ID: <195b91ea72e11bb9e2b0129e4e08509f@idefix.lespocky.dyndns.org> (raw)
In-Reply-To: <1378388934-7790-1-git-send-email-post@lespocky.de>

Hei hei, 

before making a new patch, there's one open question.

Am 2013-09-05 15:48, schrieb Alexander Dahl:
> The init script is inspired by the one in Debian Wheezy and adapted
> for busybox. It uses mkdir, seq, sleep, echo, rm and cat from busybox
> so maybe those should be added as dependency.

The start script provided is for busybox startup method and if selected
there's a dependency to busybox start-stop-daemon tool, which the script
uses. The script uses also the above mentioned tools which can be part
of busybox but can also come from coreutils. How to deal with this?
Would adding dependencies to the busybox tools be the right way? Leave
it without dependency or some magic so the busybox or the coreutils tool
is selected? (I didn't test the script with the latter, but those are
fairly basic tools, so I assume it should work.)

This is the diff of the mentioned init script:

> diff --git a/generic/etc/init.d/lldpd b/generic/etc/init.d/lldpd
> new file mode 100644
> index 0000000..8fd0d28
> --- /dev/null
> +++ b/generic/etc/init.d/lldpd
> @@ -0,0 +1,139 @@
> +#!/bin/sh
> +
> +PATH=/sbin:/usr/sbin:/bin:/usr/bin
> +DESC="LLDP daemon"
> +NAME=lldpd
> +DAEMON=/usr/sbin/$NAME
> +DAEMON_ARGS="@DAEMON_ARGS@"
> +PIDFILE=/var/run/$NAME.pid
> +SCRIPTNAME=/etc/init.d/$NAME
> +CHROOT=@PRIVSEP_CHROOT@
> +
> +# exit if binary is missing
> +[ -x "$DAEMON" ] || exit 0
> +
> +# read further config if present
> +[ -r /etc/default/$NAME ] && . /etc/default/$NAME
> +
> +is_running() {
> +    start-stop-daemon -K --quiet --test --exec $DAEMON --pidfile $PIDFILE
> +}
> +
> +do_chroot() {
> +    oldumask=$(umask)
> +    umask 022
> +    [ -d $CHROOT/etc ] || mkdir -p $CHROOT/etc
> +    [ -f $CHROOT/etc/localtime ] || [ ! -f /etc/localtime ] || \
> +        cp /etc/localtime $CHROOT/etc/localtime
> +    umask $oldumask
> +}
> +
> +do_start() {
> +    do_chroot
> +    is_running && return 1
> +    start-stop-daemon -S --quiet --pidfile $PIDFILE --exec $DAEMON -- \
> +        $DAEMON_ARGS \
> +        || return 2
> +}
> +
> +do_stop() {
> +    is_running || return 0
> +    start-stop-daemon -K --quiet --pidfile $PIDFILE --name $NAME
> +    RETVAL="$?"
> +
> +    # wait up to 30 seconds until daemon stopped
> +    for i in $(seq 30)
> +    do
> +        sleep 1
> +        echo -n '.'
> +        if ! is_running
> +        then
> +            break
> +        fi
> +    done
> +
> +    # see if it's still running
> +    if is_running
> +    then
> +        start-stop-daemon -K --quiet --signal KILL --pidfile $PIDFILE
> --name $NAME
> +
> +        for i in $(seq 5)
> +        do
> +            sleep 1
> +            echo -n '.'
> +            if ! is_running
> +            then
> +                break
> +            fi
> +        done
> +        
> +        if is_running
> +        then
> +            return 2
> +        fi
> +    fi
> +
> +    rm -f $PIDFILE
> +    return "$RETVAL"
> +}
> +
> +do_reload() {
> +    # send SIGHUP
> +    start-stop-daemon -K --signal 1 --quiet --pidfile $PIDFILE --name $NAME
> +    return 0
> +}
> +
> +case "$1" in
> +    start)
> +        echo -n "Starting $DESC ..."
> +        do_start
> +        case "$?" in
> +            0|1)    echo " Done." ;;
> +            2)      echo " Failed." ;;
> +        esac
> +        ;;
> +    stop)
> +        echo -n "Stopping $DESC ."
> +        do_stop
> +        case "$?" in
> +            0|1)    echo " Done." ;;
> +            2)      echo " Failed." ;;
> +        esac
> +        ;;
> +    reload)
> +        echo -n "Reloading $DESC ..."
> +        do_reload
> +        echo " Done."
> +        ;;
> +    restart|force-reload)
> +        echo -n "Restarting $DESC .."
> +        do_stop
> +        case "$?" in
> +            0|1)
> +                do_start
> +                case "$?" in
> +                    0)  echo " Done." ;;
> +                    1)  echo " Failed." ;; # Old process still running
> +                    *)  echo " Failed." ;; # Failed to start
> +                esac
> +                ;;
> +            *)
> +                echo " Failed." # Failed to stop
> +                ;;
> +        esac
> +        ;;
> +    status)
> +        if is_running
> +        then
> +            echo "$NAME is running with PID $(cat $PIDFILE) ..."
> +        else
> +            echo "$NAME is not running"
> +        fi
> +        ;;
> +    *)
> +        echo "Usage: $SCRIPTNAME
> {start|stop|restart|reload|force-reload|status}" >&2
> +        exit 3
> +        ;;
> +esac
> +
> +:

Greets
Alex

-- 
»With the first link, the chain is forged. The first speech censured,
the first thought forbidden, the first freedom denied, chains us all
irrevocably.« (Jean-Luc Picard, quoting Judge Aaron Satie)
*** GnuPG-FP: 02C8 A590 7FE5 CA5F 3601  D1D5 8FBA 7744 CC87 10D0 ***

-- 
ptxdist mailing list
ptxdist@pengutronix.de

  parent reply	other threads:[~2013-09-11 13:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-05 13:48 Alexander Dahl
2013-09-09  9:49 ` Michael Olbrich
2013-09-09 10:43   ` Alexander Dahl
2013-09-09 14:45     ` Michael Olbrich
2013-09-09 15:20       ` [ptxdist] [PATCH] lldpd: " Alexander Dahl
2013-09-09 16:01         ` Michael Olbrich
2013-09-27 14:37           ` Alexander Dahl
2013-09-11 13:16 ` Alexander Dahl [this message]
2013-09-16  8:21   ` [ptxdist] [PATCH] [lldpd] " Michael Olbrich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=195b91ea72e11bb9e2b0129e4e08509f@idefix.lespocky.dyndns.org \
    --to=post@lespocky.de \
    --cc=ptxdist@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox