mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH] [lldpd] add package
@ 2013-09-05 13:48 Alexander Dahl
  2013-09-09  9:49 ` Michael Olbrich
  2013-09-11 13:16 ` [ptxdist] [PATCH] [lldpd] " Alexander Dahl
  0 siblings, 2 replies; 9+ messages in thread
From: Alexander Dahl @ 2013-09-05 13:48 UTC (permalink / raw)
  To: ptxdist

This adds a package lldpd implementing 802.1ab aka LLDP protocol. It's
the daemon written by Vincent Bernat licensed under ISC license from
http://vincentbernat.github.io/lldpd/

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.

Signed-off-by: Alexander Dahl <post@lespocky.de>
---
 generic/etc/init.d/lldpd |  139 ++++++++++++++++++++++++++++++++++++++++++++++
 rules/lldpd-bbinit.in    |    9 +++
 rules/lldpd.in           |   97 ++++++++++++++++++++++++++++++++
 rules/lldpd.make         |   89 +++++++++++++++++++++++++++++
 4 files changed, 334 insertions(+)
 create mode 100644 generic/etc/init.d/lldpd
 create mode 100644 rules/lldpd-bbinit.in
 create mode 100644 rules/lldpd.in
 create mode 100644 rules/lldpd.make

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
+
+:
diff --git a/rules/lldpd-bbinit.in b/rules/lldpd-bbinit.in
new file mode 100644
index 0000000..103452a
--- /dev/null
+++ b/rules/lldpd-bbinit.in
@@ -0,0 +1,9 @@
+## SECTION=initmethod_bbinit
+
+config LLDPD_BBINIT_LINK
+	string
+	depends on LLDPD_STARTSCRIPT
+	prompt "lldpd"
+	default "S28lldpd"
+
+# vim: ft=kconfig noet tw=72
diff --git a/rules/lldpd.in b/rules/lldpd.in
new file mode 100644
index 0000000..7d19712
--- /dev/null
+++ b/rules/lldpd.in
@@ -0,0 +1,97 @@
+## SECTION=networking
+
+menuconfig LLDPD
+	tristate
+	prompt "lldpd                         "
+	select INITMETHOD
+	select LIBEVENT
+	select NET_SNMP if LLDPD_SNMP
+	select LIBXML2 if LLDPD_XML
+	select BUSYBOX_START_STOP_DAEMON if LLDPD_STARTSCRIPT
+	select BUSYBOX_FEATURE_START_STOP_DAEMON_LONG_OPTIONS if LLDPD_STARTSCRIPT
+	help
+	  lldpd is an ISC-licensed implementation of LLDP for various
+	  Unixes. It also supports some proprietary protocols.
+
+if LLDPD
+
+config LLDPD_PRIVSEP_USER
+	string
+	prompt "Which user to use for privilege separation"
+	default "_lldpd"
+
+config LLDPD_PRIVSEP_GROUP
+	string
+	prompt "Which group to use for privilege separation"
+	default "_lldpd"
+
+config LLDPD_PRIVSEP_CHROOT
+	string
+	prompt "Which directory to use to chroot lldpd"
+	default "/var/run/lldpd"
+
+config LLDPD_CDP
+	bool
+	prompt "Enable Cisco Discovery Protocol"
+	default y
+
+config LLDPD_FDP
+	bool
+	prompt "Enable Foundry Discovery Protocol"
+	default y
+
+config LLDPD_EDP
+	bool
+	prompt "Enable Extreme Discovery Protocol"
+	default y
+
+config LLDPD_SONMP
+	bool
+	prompt "Enable SynOptics Network Management Protocol"
+	default y
+
+config LLDPD_LLDPMED
+	bool
+	prompt "Enable LLDP-MED extension"
+	default y
+
+config LLDPD_DOT1
+	bool
+	prompt "Enable Dot1 extension (VLAN stuff)"
+	default y
+
+config LLDPD_DOT3
+	bool
+	prompt "Enable Dot3 extension (PHY stuff)"
+	default y
+
+config LLDPD_OLDIES
+	bool
+	prompt "Enable compatibility with Linux kernel older than 2.6.18"
+	default n
+
+config LLDPD_SNMP
+	bool
+	prompt "Enable the use of SNMP"
+	default n
+
+config LLDPD_XML
+	bool
+	prompt "Enable XML output via libxml2"
+	default n
+
+config LLDPD_STARTSCRIPT
+	bool
+	prompt "install /etc/init.d/lldpd"
+	default y
+
+config LLDPD_DAEMON_ARGS
+	string
+	prompt "additional arguments for daemon startup"
+	default ""
+	help
+	  This could be -c -e -f -s …
+
+endif
+
+# vim: ft=kconfig noet tw=72
diff --git a/rules/lldpd.make b/rules/lldpd.make
new file mode 100644
index 0000000..a999100
--- /dev/null
+++ b/rules/lldpd.make
@@ -0,0 +1,89 @@
+# -*-makefile-*-
+#
+# Copyright (C) 2013 by Alexander Dahl <post@lespocky.de>
+#
+# See CREDITS for details about who has contributed to this project.
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+#
+# We provide this package
+#
+PACKAGES-$(PTXCONF_LLDPD) += lldpd
+
+#
+# Paths and names
+#
+LLDPD_VERSION	:= 0.7.6
+LLDPD_MD5		:= dbd90a68b91448dcb94a4a77c5d8ef65
+LLDPD			:= lldpd-$(LLDPD_VERSION)
+LLDPD_SUFFIX	:= tar.gz
+LLDPD_URL		:= http://media.luffy.cx/files/lldpd//$(LLDPD).$(LLDPD_SUFFIX)
+LLDPD_SOURCE	:= $(SRCDIR)/$(LLDPD).$(LLDPD_SUFFIX)
+LLDPD_DIR		:= $(BUILDDIR)/$(LLDPD)
+LLDPD_LICENSE	:= ICS
+
+# ----------------------------------------------------------------------------
+# Prepare
+# ----------------------------------------------------------------------------
+
+LLDPD_CONF_TOOL	:= autoconf
+LLDPD_CONF_OPT	:= $(CROSS_AUTOCONF_USR) \
+	--disable-doxygen-doc \
+	--without-embedded-libevent \
+	--$(call ptx/endis, PTXCONF_LLDPD_CDP)-cdp \
+	--$(call ptx/endis, PTXCONF_LLDPD_FDP)-fdp \
+	--$(call ptx/endis, PTXCONF_LLDPD_EDP)-edp \
+	--$(call ptx/endis, PTXCONF_LLDPD_SONMP)-sonmp \
+	--$(call ptx/endis, PTXCONF_LLDPD_LLDPMED)-lldpmed \
+	--$(call ptx/endis, PTXCONF_LLDPD_DOT1)-dot1 \
+	--$(call ptx/endis, PTXCONF_LLDPD_DOT3)-dot3 \
+	--$(call ptx/endis, PTXCONF_LLDPD_OLDIES)-oldies \
+	--$(call ptx/wwo, PTXCONF_LLDPD_SNMP)-snmp \
+	--$(call ptx/wwo, PTXCONF_LLDPD_XML)-xml \
+	--with-privsep-user="$(PTXCONF_LLDPD_PRIVSEP_USER)" \
+	--with-privsep-group="$(PTXCONF_LLDPD_PRIVSEP_GROUP)" \
+	--with-privsep-chroot="$(PTXCONF_LLDPD_PRIVSEP_CHROOT)"
+
+# ----------------------------------------------------------------------------
+# Target-Install
+# ----------------------------------------------------------------------------
+
+$(STATEDIR)/lldpd.targetinstall:
+	@$(call targetinfo)
+
+	@$(call install_init, lldpd)
+	@$(call install_fixup, lldpd,PRIORITY,optional)
+	@$(call install_fixup, lldpd,SECTION,base)
+	@$(call install_fixup, lldpd,AUTHOR,"Alexander Dahl <post@lespocky.de>")
+	@$(call install_fixup, lldpd,DESCRIPTION,missing)
+
+	@$(call install_copy, lldpd, 0, 0, 0755, -, /usr/sbin/lldpd)
+	@$(call install_copy, lldpd, $(PTXCONF_LLDPD_PRIVSEP_USER), \
+		$(PTXCONF_LLDPD_PRIVSEP_GROUP), 4750, -, /usr/sbin/lldpcli)
+	@$(call install_link, lldpd, lldpcli, /usr/sbin/lldpctl)
+
+	@$(call install_lib, lldpd, 0, 0, 0644, liblldpctl)
+
+ifdef PTXCONF_INITMETHOD_BBINIT
+ifdef PTXCONF_LLDPD_STARTSCRIPT
+	@$(call install_alternative, lldpd, 0, 0, 0755, /etc/init.d/lldpd)
+	@$(call install_replace, lldpd, /etc/init.d/lldpd, \
+		@DAEMON_ARGS@, $(PTXCONF_LLDPD_DAEMON_ARGS))
+	@$(call install_replace, lldpd, /etc/init.d/lldpd, \
+		@PRIVSEP_CHROOT@, $(PTXCONF_LLDPD_PRIVSEP_CHROOT))
+
+ifneq ($(call remove_quotes,$(PTXCONF_LLDPD_BBINIT_LINK)),)
+	@$(call install_link, lldpd, ../init.d/lldpd, \
+		/etc/rc.d/$(PTXCONF_LLDPD_BBINIT_LINK))
+endif
+endif
+endif
+
+	@$(call install_finish, lldpd)
+
+	@$(call touch)
+
+# vim: ft=make noet
-- 
1.7.10.4


-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [ptxdist] [PATCH] [lldpd] add package
  2013-09-05 13:48 [ptxdist] [PATCH] [lldpd] add package Alexander Dahl
@ 2013-09-09  9:49 ` Michael Olbrich
  2013-09-09 10:43   ` Alexander Dahl
  2013-09-11 13:16 ` [ptxdist] [PATCH] [lldpd] " Alexander Dahl
  1 sibling, 1 reply; 9+ messages in thread
From: Michael Olbrich @ 2013-09-09  9:49 UTC (permalink / raw)
  To: ptxdist

On Thu, Sep 05, 2013 at 03:48:54PM +0200, Alexander Dahl wrote:
> This adds a package lldpd implementing 802.1ab aka LLDP protocol. It's
> the daemon written by Vincent Bernat licensed under ISC license from
> http://vincentbernat.github.io/lldpd/
> 
> 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.

This fail to compile here:
[...]
checking for snmp_register_callback in -lnetsnmp... yes
checking for netsnmp_enable_subagent... no
configure: error: *** no subagent support in net-snmp
make: *** [..../state/lldpd.prepare] Error 1
[...]

Any idea what might go wrong here?

> Signed-off-by: Alexander Dahl <post@lespocky.de>
> ---
>  generic/etc/init.d/lldpd |  139 ++++++++++++++++++++++++++++++++++++++++++++++
>  rules/lldpd-bbinit.in    |    9 +++
>  rules/lldpd.in           |   97 ++++++++++++++++++++++++++++++++
>  rules/lldpd.make         |   89 +++++++++++++++++++++++++++++
>  4 files changed, 334 insertions(+)
>  create mode 100644 generic/etc/init.d/lldpd
>  create mode 100644 rules/lldpd-bbinit.in
>  create mode 100644 rules/lldpd.in
>  create mode 100644 rules/lldpd.make
> 
> 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
> +
> +:
> diff --git a/rules/lldpd-bbinit.in b/rules/lldpd-bbinit.in
> new file mode 100644
> index 0000000..103452a
> --- /dev/null
> +++ b/rules/lldpd-bbinit.in
> @@ -0,0 +1,9 @@
> +## SECTION=initmethod_bbinit
> +
> +config LLDPD_BBINIT_LINK
> +	string
> +	depends on LLDPD_STARTSCRIPT
> +	prompt "lldpd"
> +	default "S28lldpd"
> +
> +# vim: ft=kconfig noet tw=72
> diff --git a/rules/lldpd.in b/rules/lldpd.in
> new file mode 100644
> index 0000000..7d19712
> --- /dev/null
> +++ b/rules/lldpd.in
> @@ -0,0 +1,97 @@
> +## SECTION=networking
> +
> +menuconfig LLDPD
> +	tristate
> +	prompt "lldpd                         "
> +	select INITMETHOD
> +	select LIBEVENT
> +	select NET_SNMP if LLDPD_SNMP
> +	select LIBXML2 if LLDPD_XML
> +	select BUSYBOX_START_STOP_DAEMON if LLDPD_STARTSCRIPT
> +	select BUSYBOX_FEATURE_START_STOP_DAEMON_LONG_OPTIONS if LLDPD_STARTSCRIPT
> +	help
> +	  lldpd is an ISC-licensed implementation of LLDP for various
> +	  Unixes. It also supports some proprietary protocols.
> +
> +if LLDPD
> +
> +config LLDPD_PRIVSEP_USER
> +	string
> +	prompt "Which user to use for privilege separation"
> +	default "_lldpd"

this seems to be a strange user. Why with '_'?

> +
> +config LLDPD_PRIVSEP_GROUP
> +	string
> +	prompt "Which group to use for privilege separation"
> +	default "_lldpd"
> +
> +config LLDPD_PRIVSEP_CHROOT
> +	string
> +	prompt "Which directory to use to chroot lldpd"
> +	default "/var/run/lldpd"
> +
> +config LLDPD_CDP
> +	bool
> +	prompt "Enable Cisco Discovery Protocol"
> +	default y
> +
> +config LLDPD_FDP
> +	bool
> +	prompt "Enable Foundry Discovery Protocol"
> +	default y
> +
> +config LLDPD_EDP
> +	bool
> +	prompt "Enable Extreme Discovery Protocol"
> +	default y
> +
> +config LLDPD_SONMP
> +	bool
> +	prompt "Enable SynOptics Network Management Protocol"
> +	default y
> +
> +config LLDPD_LLDPMED
> +	bool
> +	prompt "Enable LLDP-MED extension"
> +	default y
> +
> +config LLDPD_DOT1
> +	bool
> +	prompt "Enable Dot1 extension (VLAN stuff)"
> +	default y
> +
> +config LLDPD_DOT3
> +	bool
> +	prompt "Enable Dot3 extension (PHY stuff)"
> +	default y
> +
> +config LLDPD_OLDIES
> +	bool
> +	prompt "Enable compatibility with Linux kernel older than 2.6.18"
> +	default n

no "default n" needed. Thats the default anyways.

> +
> +config LLDPD_SNMP
> +	bool
> +	prompt "Enable the use of SNMP"
> +	default n
> +
> +config LLDPD_XML
> +	bool
> +	prompt "Enable XML output via libxml2"
> +	default n
> +
> +config LLDPD_STARTSCRIPT
> +	bool
> +	prompt "install /etc/init.d/lldpd"
> +	default y
> +
> +config LLDPD_DAEMON_ARGS
> +	string
> +	prompt "additional arguments for daemon startup"
> +	default ""
> +	help
> +	  This could be -c -e -f -s …
> +
> +endif
> +
> +# vim: ft=kconfig noet tw=72
> diff --git a/rules/lldpd.make b/rules/lldpd.make
> new file mode 100644
> index 0000000..a999100
> --- /dev/null
> +++ b/rules/lldpd.make
> @@ -0,0 +1,89 @@
> +# -*-makefile-*-
> +#
> +# Copyright (C) 2013 by Alexander Dahl <post@lespocky.de>
> +#
> +# See CREDITS for details about who has contributed to this project.
> +#
> +# For further information about the PTXdist project and license conditions
> +# see the README file.
> +#
> +
> +#
> +# We provide this package
> +#
> +PACKAGES-$(PTXCONF_LLDPD) += lldpd
> +
> +#
> +# Paths and names
> +#
> +LLDPD_VERSION	:= 0.7.6
> +LLDPD_MD5		:= dbd90a68b91448dcb94a4a77c5d8ef65
> +LLDPD			:= lldpd-$(LLDPD_VERSION)
> +LLDPD_SUFFIX	:= tar.gz
> +LLDPD_URL		:= http://media.luffy.cx/files/lldpd//$(LLDPD).$(LLDPD_SUFFIX)
> +LLDPD_SOURCE	:= $(SRCDIR)/$(LLDPD).$(LLDPD_SUFFIX)
> +LLDPD_DIR		:= $(BUILDDIR)/$(LLDPD)
> +LLDPD_LICENSE	:= ICS
> +
> +# ----------------------------------------------------------------------------
> +# Prepare
> +# ----------------------------------------------------------------------------
> +
> +LLDPD_CONF_TOOL	:= autoconf
> +LLDPD_CONF_OPT	:= $(CROSS_AUTOCONF_USR) \
> +	--disable-doxygen-doc \
> +	--without-embedded-libevent \
> +	--$(call ptx/endis, PTXCONF_LLDPD_CDP)-cdp \
> +	--$(call ptx/endis, PTXCONF_LLDPD_FDP)-fdp \
> +	--$(call ptx/endis, PTXCONF_LLDPD_EDP)-edp \
> +	--$(call ptx/endis, PTXCONF_LLDPD_SONMP)-sonmp \
> +	--$(call ptx/endis, PTXCONF_LLDPD_LLDPMED)-lldpmed \
> +	--$(call ptx/endis, PTXCONF_LLDPD_DOT1)-dot1 \
> +	--$(call ptx/endis, PTXCONF_LLDPD_DOT3)-dot3 \
> +	--$(call ptx/endis, PTXCONF_LLDPD_OLDIES)-oldies \
> +	--$(call ptx/wwo, PTXCONF_LLDPD_SNMP)-snmp \
> +	--$(call ptx/wwo, PTXCONF_LLDPD_XML)-xml \
> +	--with-privsep-user="$(PTXCONF_LLDPD_PRIVSEP_USER)" \
> +	--with-privsep-group="$(PTXCONF_LLDPD_PRIVSEP_GROUP)" \
> +	--with-privsep-chroot="$(PTXCONF_LLDPD_PRIVSEP_CHROOT)"
> +
> +# ----------------------------------------------------------------------------
> +# Target-Install
> +# ----------------------------------------------------------------------------
> +
> +$(STATEDIR)/lldpd.targetinstall:
> +	@$(call targetinfo)
> +
> +	@$(call install_init, lldpd)
> +	@$(call install_fixup, lldpd,PRIORITY,optional)
> +	@$(call install_fixup, lldpd,SECTION,base)
> +	@$(call install_fixup, lldpd,AUTHOR,"Alexander Dahl <post@lespocky.de>")
> +	@$(call install_fixup, lldpd,DESCRIPTION,missing)
> +
> +	@$(call install_copy, lldpd, 0, 0, 0755, -, /usr/sbin/lldpd)
> +	@$(call install_copy, lldpd, $(PTXCONF_LLDPD_PRIVSEP_USER), \
> +		$(PTXCONF_LLDPD_PRIVSEP_GROUP), 4750, -, /usr/sbin/lldpcli)
> +	@$(call install_link, lldpd, lldpcli, /usr/sbin/lldpctl)
> +
> +	@$(call install_lib, lldpd, 0, 0, 0644, liblldpctl)
> +
> +ifdef PTXCONF_INITMETHOD_BBINIT
> +ifdef PTXCONF_LLDPD_STARTSCRIPT
> +	@$(call install_alternative, lldpd, 0, 0, 0755, /etc/init.d/lldpd)
> +	@$(call install_replace, lldpd, /etc/init.d/lldpd, \
> +		@DAEMON_ARGS@, $(PTXCONF_LLDPD_DAEMON_ARGS))
> +	@$(call install_replace, lldpd, /etc/init.d/lldpd, \
> +		@PRIVSEP_CHROOT@, $(PTXCONF_LLDPD_PRIVSEP_CHROOT))
> +
> +ifneq ($(call remove_quotes,$(PTXCONF_LLDPD_BBINIT_LINK)),)
> +	@$(call install_link, lldpd, ../init.d/lldpd, \
> +		/etc/rc.d/$(PTXCONF_LLDPD_BBINIT_LINK))
> +endif
> +endif
> +endif
> +
> +	@$(call install_finish, lldpd)
> +
> +	@$(call touch)
> +
> +# vim: ft=make noet
> -- 
> 1.7.10.4
> 
> 
> -- 
> ptxdist mailing list
> ptxdist@pengutronix.de

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [ptxdist] [PATCH] [lldpd] add package
  2013-09-09  9:49 ` Michael Olbrich
@ 2013-09-09 10:43   ` Alexander Dahl
  2013-09-09 14:45     ` Michael Olbrich
  0 siblings, 1 reply; 9+ messages in thread
From: Alexander Dahl @ 2013-09-09 10:43 UTC (permalink / raw)
  To: ptxdist

Hei hei, 

Am 2013-09-09 11:49, schrieb Michael Olbrich:
> This fail to compile here:
> [...]
> checking for snmp_register_callback in -lnetsnmp... yes
> checking for netsnmp_enable_subagent... no
> configure: error: *** no subagent support in net-snmp
> make: *** [..../state/lldpd.prepare] Error 1
> [...]
> 
> Any idea what might go wrong here?

Yes. This is tricky and didn't have a good idea how to check it. There's
the parameter NET_SNMP_MIB_MODULES which is used in this parameter in
the prepare stage:

  --with-mib-modules=$(PTXCONF_NET_SNMP_MIB_MODULES)

You have to add/include "agentx" in the ptxdist menuconfig entry
NET_SNMP_MIB_MODULES. You can add other and there's no simple switch for
each of them. This is the way to enable several things in net-snmp and
lldpd seems to check it the right way, but I had no idea how to
"translate" this mechanism to the ptxdist layer above.

>> +if LLDPD
>> +
>> +config LLDPD_PRIVSEP_USER
>> +	string
>> +	prompt "Which user to use for privilege separation"
>> +	default "_lldpd"
> 
> this seems to be a strange user. Why with '_'?

This is the default lldpd uses. See the output of ./configure from
lldpd:

  --with-privsep-user     Which user to use for privilege separation
                          [default=_lldpd]
  --with-privsep-group    Which group to use for privilege separation
                          [default=_lldpd]
  --with-privsep-chroot   Which directory to use to chroot lldpd
                          [default=/var/run/lldpd]

Actually I set this user to nobody and the group to daemon. As far as I
understood lldpd this is hardcoded and I wanted to have it configurable
so I added it to the ptxdist menu and copied the defaults from lldpd.
Maybe the do not make sense for most of the users. Do you have a better
suggestion for this user and group?

>> +config LLDPD_OLDIES
>> +	bool
>> +	prompt "Enable compatibility with Linux kernel older than 2.6.18"
>> +	default n
> 
> no "default n" needed. Thats the default anyways.

Good to know, but for me the code of the in rule is more clear if I add
this. However, if you want to have it removed, I'll remove it.

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [ptxdist] [PATCH] [lldpd] add package
  2013-09-09 10:43   ` Alexander Dahl
@ 2013-09-09 14:45     ` Michael Olbrich
  2013-09-09 15:20       ` [ptxdist] [PATCH] lldpd: " Alexander Dahl
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Olbrich @ 2013-09-09 14:45 UTC (permalink / raw)
  To: ptxdist

Hi,

please change the subject to "lldpd: ..."

On Mon, Sep 09, 2013 at 12:43:09PM +0200, Alexander Dahl wrote:
> Am 2013-09-09 11:49, schrieb Michael Olbrich:
> > This fail to compile here:
> > [...]
> > checking for snmp_register_callback in -lnetsnmp... yes
> > checking for netsnmp_enable_subagent... no
> > configure: error: *** no subagent support in net-snmp
> > make: *** [..../state/lldpd.prepare] Error 1
> > [...]
> > 
> > Any idea what might go wrong here?
> 
> Yes. This is tricky and didn't have a good idea how to check it. There's
> the parameter NET_SNMP_MIB_MODULES which is used in this parameter in
> the prepare stage:
> 
>   --with-mib-modules=$(PTXCONF_NET_SNMP_MIB_MODULES)
> 
> You have to add/include "agentx" in the ptxdist menuconfig entry
> NET_SNMP_MIB_MODULES. You can add other and there's no simple switch for
> each of them. This is the way to enable several things in net-snmp and
> lldpd seems to check it the right way, but I had no idea how to
> "translate" this mechanism to the ptxdist layer above.

Make an option for "agentx", so you can select it.

> >> +if LLDPD
> >> +
> >> +config LLDPD_PRIVSEP_USER
> >> +	string
> >> +	prompt "Which user to use for privilege separation"
> >> +	default "_lldpd"
> > 
> > this seems to be a strange user. Why with '_'?
> 
> This is the default lldpd uses. See the output of ./configure from
> lldpd:
> 
>   --with-privsep-user     Which user to use for privilege separation
>                           [default=_lldpd]
>   --with-privsep-group    Which group to use for privilege separation
>                           [default=_lldpd]
>   --with-privsep-chroot   Which directory to use to chroot lldpd
>                           [default=/var/run/lldpd]
> 
> Actually I set this user to nobody and the group to daemon. As far as I
> understood lldpd this is hardcoded and I wanted to have it configurable
> so I added it to the ptxdist menu and copied the defaults from lldpd.
> Maybe the do not make sense for most of the users. Do you have a better
> suggestion for this user and group?

use "nobody" by default. Otherwise the defaults break targetinstall

> >> +config LLDPD_OLDIES
> >> +	bool
> >> +	prompt "Enable compatibility with Linux kernel older than 2.6.18"
> >> +	default n
> > 
> > no "default n" needed. Thats the default anyways.
> 
> Good to know, but for me the code of the in rule is more clear if I add
> this. However, if you want to have it removed, I'll remove it.

thanks.

Michael

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [ptxdist] [PATCH] lldpd: add package
  2013-09-09 14:45     ` Michael Olbrich
@ 2013-09-09 15:20       ` Alexander Dahl
  2013-09-09 16:01         ` Michael Olbrich
  0 siblings, 1 reply; 9+ messages in thread
From: Alexander Dahl @ 2013-09-09 15:20 UTC (permalink / raw)
  To: ptxdist

Hei Michael, 

Am 2013-09-09 16:45, schrieb Michael Olbrich:
> please change the subject to "lldpd: ..."

I'll do it in the next patch, I noticed this right after sending it. :-/

>> Yes. This is tricky and didn't have a good idea how to check it. There's
>> the parameter NET_SNMP_MIB_MODULES which is used in this parameter in
>> the prepare stage:
>>
>>   --with-mib-modules=$(PTXCONF_NET_SNMP_MIB_MODULES)
>>
>> You have to add/include "agentx" in the ptxdist menuconfig entry
>> NET_SNMP_MIB_MODULES. You can add other and there's no simple switch for
>> each of them. This is the way to enable several things in net-snmp and
>> lldpd seems to check it the right way, but I had no idea how to
>> "translate" this mechanism to the ptxdist layer above.
> 
> Make an option for "agentx", so you can select it.

This would be an option in net-snmp package and this is the difficulty.
At the moment there's PTXCONF_NET_SNMP_MIB_MODULES which is a space
separated list. From the `./configure --help` of net-snmp:

  --with-mib-modules="item1 ..."  Compile with additional mib modules
                                    (Space separated list).
  --with-out-mib-modules="list"   Compile without these mib modules.

Possible entries make a list of two screen pages, I guess around 30
entries (and "agentx" is one of them). If I choose one of them to be a
separate option in ptxdist net-snmp conf (maybe as submenu) while
keeping the list in PTXCONF_NET_SNMP_MIB_MODULES, we would have to test
the new option in net-snmp.make and add it to the list if selected. But
what if someone puts the same option in the list?

Or would it be better to put variables for almost 30 options to the
ptxdist config?

However this is no change in lldpd package but in net-snmp, which would
have to be made first.

>> This is the default lldpd uses. See the output of ./configure from
>> lldpd:
>>
>>   --with-privsep-user     Which user to use for privilege separation
>>                           [default=_lldpd]
>>   --with-privsep-group    Which group to use for privilege separation
>>                           [default=_lldpd]
>>   --with-privsep-chroot   Which directory to use to chroot lldpd
>>                           [default=/var/run/lldpd]
>>
>> Actually I set this user to nobody and the group to daemon. As far as I
>> understood lldpd this is hardcoded and I wanted to have it configurable
>> so I added it to the ptxdist menu and copied the defaults from lldpd.
>> Maybe the do not make sense for most of the users. Do you have a better
>> suggestion for this user and group?
> 
> use "nobody" by default. Otherwise the defaults break targetinstall

Okay, and for the group?

>> > no "default n" needed. Thats the default anyways.
>>
>> Good to know, but for me the code of the in rule is more clear if I add
>> this. However, if you want to have it removed, I'll remove it.
> 
> thanks.

Okay I'll remove every "default n" in the next patch.

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [ptxdist] [PATCH] lldpd: add package
  2013-09-09 15:20       ` [ptxdist] [PATCH] lldpd: " Alexander Dahl
@ 2013-09-09 16:01         ` Michael Olbrich
  2013-09-27 14:37           ` Alexander Dahl
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Olbrich @ 2013-09-09 16:01 UTC (permalink / raw)
  To: ptxdist

On Mon, Sep 09, 2013 at 05:20:09PM +0200, Alexander Dahl wrote:
> Hei Michael, 
> 
> Am 2013-09-09 16:45, schrieb Michael Olbrich:
> > please change the subject to "lldpd: ..."
> 
> I'll do it in the next patch, I noticed this right after sending it. :-/
> 
> >> Yes. This is tricky and didn't have a good idea how to check it. There's
> >> the parameter NET_SNMP_MIB_MODULES which is used in this parameter in
> >> the prepare stage:
> >>
> >>   --with-mib-modules=$(PTXCONF_NET_SNMP_MIB_MODULES)
> >>
> >> You have to add/include "agentx" in the ptxdist menuconfig entry
> >> NET_SNMP_MIB_MODULES. You can add other and there's no simple switch for
> >> each of them. This is the way to enable several things in net-snmp and
> >> lldpd seems to check it the right way, but I had no idea how to
> >> "translate" this mechanism to the ptxdist layer above.
> > 
> > Make an option for "agentx", so you can select it.
> 
> This would be an option in net-snmp package and this is the difficulty.
> At the moment there's PTXCONF_NET_SNMP_MIB_MODULES which is a space
> separated list. From the `./configure --help` of net-snmp:
> 
>   --with-mib-modules="item1 ..."  Compile with additional mib modules
>                                     (Space separated list).
>   --with-out-mib-modules="list"   Compile without these mib modules.
> 
> Possible entries make a list of two screen pages, I guess around 30
> entries (and "agentx" is one of them). If I choose one of them to be a
> separate option in ptxdist net-snmp conf (maybe as submenu) while
> keeping the list in PTXCONF_NET_SNMP_MIB_MODULES, we would have to test
> the new option in net-snmp.make and add it to the list if selected. But
> what if someone puts the same option in the list?
> 
> Or would it be better to put variables for almost 30 options to the
> ptxdist config?
> 
> However this is no change in lldpd package but in net-snmp, which would
> have to be made first.

Yes, this should be a change in net-snmp. Take a look at how the modules
are handled in lighttpd. It's the same idea. Use options for modules with
extra dependencies (not relevant here) or for modules that are needed by
other packages and keep the string variable for all the rest.

NET_SNMP_MIB_MODULES-y := $(PTXCONF_NET_SNMP_MIB_MODULES)
NET_SNMP_MIB_MODULES-$(PTXCONF_NET_SNMP_MIB_MODULE_XAGENT) += agentx

[...]
	--with-mib-modules=$(NET_SNMP_MIB_MODULES-y)
[...]

> >> This is the default lldpd uses. See the output of ./configure from
> >> lldpd:
> >>
> >>   --with-privsep-user     Which user to use for privilege separation
> >>                           [default=_lldpd]
> >>   --with-privsep-group    Which group to use for privilege separation
> >>                           [default=_lldpd]
> >>   --with-privsep-chroot   Which directory to use to chroot lldpd
> >>                           [default=/var/run/lldpd]
> >>
> >> Actually I set this user to nobody and the group to daemon. As far as I
> >> understood lldpd this is hardcoded and I wanted to have it configurable
> >> so I added it to the ptxdist menu and copied the defaults from lldpd.
> >> Maybe the do not make sense for most of the users. Do you have a better
> >> suggestion for this user and group?
> > 
> > use "nobody" by default. Otherwise the defaults break targetinstall
> 
> Okay, and for the group?

"nogroup"

Michael

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [ptxdist] [PATCH] [lldpd] add package
  2013-09-05 13:48 [ptxdist] [PATCH] [lldpd] add package Alexander Dahl
  2013-09-09  9:49 ` Michael Olbrich
@ 2013-09-11 13:16 ` Alexander Dahl
  2013-09-16  8:21   ` Michael Olbrich
  1 sibling, 1 reply; 9+ messages in thread
From: Alexander Dahl @ 2013-09-11 13:16 UTC (permalink / raw)
  To: ptxdist

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [ptxdist] [PATCH] [lldpd] add package
  2013-09-11 13:16 ` [ptxdist] [PATCH] [lldpd] " Alexander Dahl
@ 2013-09-16  8:21   ` Michael Olbrich
  0 siblings, 0 replies; 9+ messages in thread
From: Michael Olbrich @ 2013-09-16  8:21 UTC (permalink / raw)
  To: ptxdist

Hi,

On Wed, Sep 11, 2013 at 03:16:26PM +0200, Alexander Dahl wrote:
> 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:
[...]

Just select BUSYBOX_START_STOP_DAEMON and ignore the rest. Those can be
expected to be there. If not, a lot of other stuff won't work either.

Michael

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ptxdist] [PATCH] lldpd: add package
  2013-09-09 16:01         ` Michael Olbrich
@ 2013-09-27 14:37           ` Alexander Dahl
  0 siblings, 0 replies; 9+ messages in thread
From: Alexander Dahl @ 2013-09-27 14:37 UTC (permalink / raw)
  To: ptxdist

This adds lldpd from http://vincentbernat.github.io/lldpd/ to the list
of packages. Quote: »lldpd is a 802.1ab implementation (LLDP) to help
you locate neighbors of all your equipments.«

Signed-off-by: Alexander Dahl <post@lespocky.de>
---
 generic/etc/init.d/lldpd |  139 ++++++++++++++++++++++++++++++++++++++++++++++
 rules/lldpd-bbinit.in    |    9 +++
 rules/lldpd.in           |   95 +++++++++++++++++++++++++++++++
 rules/lldpd.make         |   89 +++++++++++++++++++++++++++++
 4 files changed, 332 insertions(+)
 create mode 100755 generic/etc/init.d/lldpd
 create mode 100644 rules/lldpd-bbinit.in
 create mode 100644 rules/lldpd.in
 create mode 100644 rules/lldpd.make

diff --git a/generic/etc/init.d/lldpd b/generic/etc/init.d/lldpd
new file mode 100755
index 0000000..00c8240
--- /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
+
+:
diff --git a/rules/lldpd-bbinit.in b/rules/lldpd-bbinit.in
new file mode 100644
index 0000000..103452a
--- /dev/null
+++ b/rules/lldpd-bbinit.in
@@ -0,0 +1,9 @@
+## SECTION=initmethod_bbinit
+
+config LLDPD_BBINIT_LINK
+	string
+	depends on LLDPD_STARTSCRIPT
+	prompt "lldpd"
+	default "S28lldpd"
+
+# vim: ft=kconfig noet tw=72
diff --git a/rules/lldpd.in b/rules/lldpd.in
new file mode 100644
index 0000000..c4b4434
--- /dev/null
+++ b/rules/lldpd.in
@@ -0,0 +1,95 @@
+## SECTION=networking
+
+menuconfig LLDPD
+	tristate
+	prompt "lldpd                         "
+	select INITMETHOD
+	select LIBEVENT
+	select NET_SNMP if LLDPD_SNMP
+	select NET_SNMP_MIB_MODULES_AGENTX if LLDPD_SNMP
+	select LIBXML2 if LLDPD_XML
+	select BUSYBOX_START_STOP_DAEMON if LLDPD_STARTSCRIPT
+	select BUSYBOX_FEATURE_START_STOP_DAEMON_LONG_OPTIONS if LLDPD_STARTSCRIPT
+	help
+	  lldpd is an ISC-licensed implementation of LLDP for various
+	  Unixes. It also supports some proprietary protocols.
+
+if LLDPD
+
+config LLDPD_PRIVSEP_USER
+	string
+	prompt "Which user to use for privilege separation"
+	default "nobody"
+
+config LLDPD_PRIVSEP_GROUP
+	string
+	prompt "Which group to use for privilege separation"
+	default "nogroup"
+
+config LLDPD_PRIVSEP_CHROOT
+	string
+	prompt "Which directory to use to chroot lldpd"
+	default "/var/run/lldpd"
+
+config LLDPD_CDP
+	bool
+	prompt "Enable Cisco Discovery Protocol"
+	default y
+
+config LLDPD_FDP
+	bool
+	prompt "Enable Foundry Discovery Protocol"
+	default y
+
+config LLDPD_EDP
+	bool
+	prompt "Enable Extreme Discovery Protocol"
+	default y
+
+config LLDPD_SONMP
+	bool
+	prompt "Enable SynOptics Network Management Protocol"
+	default y
+
+config LLDPD_LLDPMED
+	bool
+	prompt "Enable LLDP-MED extension"
+	default y
+
+config LLDPD_DOT1
+	bool
+	prompt "Enable Dot1 extension (VLAN stuff)"
+	default y
+
+config LLDPD_DOT3
+	bool
+	prompt "Enable Dot3 extension (PHY stuff)"
+	default y
+
+config LLDPD_OLDIES
+	bool
+	prompt "Enable compatibility with Linux kernel older than 2.6.18"
+
+config LLDPD_SNMP
+	bool
+	prompt "Enable the use of SNMP"
+
+config LLDPD_XML
+	bool
+	prompt "Enable XML output via libxml2"
+
+config LLDPD_STARTSCRIPT
+	bool
+	prompt "install /etc/init.d/lldpd"
+	default y
+
+config LLDPD_DAEMON_ARGS
+	string
+	prompt "additional arguments for daemon startup"
+	default ""
+	help
+	  This could be -c -e -f -s …
+
+endif
+
+# vim: ft=kconfig noet tw=72
diff --git a/rules/lldpd.make b/rules/lldpd.make
new file mode 100644
index 0000000..a999100
--- /dev/null
+++ b/rules/lldpd.make
@@ -0,0 +1,89 @@
+# -*-makefile-*-
+#
+# Copyright (C) 2013 by Alexander Dahl <post@lespocky.de>
+#
+# See CREDITS for details about who has contributed to this project.
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+#
+# We provide this package
+#
+PACKAGES-$(PTXCONF_LLDPD) += lldpd
+
+#
+# Paths and names
+#
+LLDPD_VERSION	:= 0.7.6
+LLDPD_MD5		:= dbd90a68b91448dcb94a4a77c5d8ef65
+LLDPD			:= lldpd-$(LLDPD_VERSION)
+LLDPD_SUFFIX	:= tar.gz
+LLDPD_URL		:= http://media.luffy.cx/files/lldpd//$(LLDPD).$(LLDPD_SUFFIX)
+LLDPD_SOURCE	:= $(SRCDIR)/$(LLDPD).$(LLDPD_SUFFIX)
+LLDPD_DIR		:= $(BUILDDIR)/$(LLDPD)
+LLDPD_LICENSE	:= ICS
+
+# ----------------------------------------------------------------------------
+# Prepare
+# ----------------------------------------------------------------------------
+
+LLDPD_CONF_TOOL	:= autoconf
+LLDPD_CONF_OPT	:= $(CROSS_AUTOCONF_USR) \
+	--disable-doxygen-doc \
+	--without-embedded-libevent \
+	--$(call ptx/endis, PTXCONF_LLDPD_CDP)-cdp \
+	--$(call ptx/endis, PTXCONF_LLDPD_FDP)-fdp \
+	--$(call ptx/endis, PTXCONF_LLDPD_EDP)-edp \
+	--$(call ptx/endis, PTXCONF_LLDPD_SONMP)-sonmp \
+	--$(call ptx/endis, PTXCONF_LLDPD_LLDPMED)-lldpmed \
+	--$(call ptx/endis, PTXCONF_LLDPD_DOT1)-dot1 \
+	--$(call ptx/endis, PTXCONF_LLDPD_DOT3)-dot3 \
+	--$(call ptx/endis, PTXCONF_LLDPD_OLDIES)-oldies \
+	--$(call ptx/wwo, PTXCONF_LLDPD_SNMP)-snmp \
+	--$(call ptx/wwo, PTXCONF_LLDPD_XML)-xml \
+	--with-privsep-user="$(PTXCONF_LLDPD_PRIVSEP_USER)" \
+	--with-privsep-group="$(PTXCONF_LLDPD_PRIVSEP_GROUP)" \
+	--with-privsep-chroot="$(PTXCONF_LLDPD_PRIVSEP_CHROOT)"
+
+# ----------------------------------------------------------------------------
+# Target-Install
+# ----------------------------------------------------------------------------
+
+$(STATEDIR)/lldpd.targetinstall:
+	@$(call targetinfo)
+
+	@$(call install_init, lldpd)
+	@$(call install_fixup, lldpd,PRIORITY,optional)
+	@$(call install_fixup, lldpd,SECTION,base)
+	@$(call install_fixup, lldpd,AUTHOR,"Alexander Dahl <post@lespocky.de>")
+	@$(call install_fixup, lldpd,DESCRIPTION,missing)
+
+	@$(call install_copy, lldpd, 0, 0, 0755, -, /usr/sbin/lldpd)
+	@$(call install_copy, lldpd, $(PTXCONF_LLDPD_PRIVSEP_USER), \
+		$(PTXCONF_LLDPD_PRIVSEP_GROUP), 4750, -, /usr/sbin/lldpcli)
+	@$(call install_link, lldpd, lldpcli, /usr/sbin/lldpctl)
+
+	@$(call install_lib, lldpd, 0, 0, 0644, liblldpctl)
+
+ifdef PTXCONF_INITMETHOD_BBINIT
+ifdef PTXCONF_LLDPD_STARTSCRIPT
+	@$(call install_alternative, lldpd, 0, 0, 0755, /etc/init.d/lldpd)
+	@$(call install_replace, lldpd, /etc/init.d/lldpd, \
+		@DAEMON_ARGS@, $(PTXCONF_LLDPD_DAEMON_ARGS))
+	@$(call install_replace, lldpd, /etc/init.d/lldpd, \
+		@PRIVSEP_CHROOT@, $(PTXCONF_LLDPD_PRIVSEP_CHROOT))
+
+ifneq ($(call remove_quotes,$(PTXCONF_LLDPD_BBINIT_LINK)),)
+	@$(call install_link, lldpd, ../init.d/lldpd, \
+		/etc/rc.d/$(PTXCONF_LLDPD_BBINIT_LINK))
+endif
+endif
+endif
+
+	@$(call install_finish, lldpd)
+
+	@$(call touch)
+
+# vim: ft=make noet
-- 
1.7.10.4


-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-09-27 14:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-05 13:48 [ptxdist] [PATCH] [lldpd] add package 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 ` [ptxdist] [PATCH] [lldpd] " Alexander Dahl
2013-09-16  8:21   ` Michael Olbrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox