diff mbox

[1/4] Package netsnmp: Created start(), stop(), reload().

Message ID 1456435484-4723-1-git-send-email-universeII@gmx.de
State Accepted
Headers show

Commit Message

universe II Feb. 25, 2016, 9:24 p.m. UTC
Changed init script to get rid of double code.
Start, stop and reload code has been put into
separate functions and 'restart' will just call
stop() and start() with a delay in between.

Signed-off-by: Andreas Ehmanns <universeII@gmx.de>
---
 package/netsnmp/S59snmpd | 71 +++++++++++++++++++++++++-----------------------
 1 file changed, 37 insertions(+), 34 deletions(-)

Comments

Yann E. MORIN July 1, 2016, 10:08 a.m. UTC | #1
Andreas, All,

On 2016-02-25 22:24 +0100, Andreas Ehmanns spake thusly:
> Changed init script to get rid of double code.
> Start, stop and reload code has been put into
> separate functions and 'restart' will just call
> stop() and start() with a delay in between.
> 
> Signed-off-by: Andreas Ehmanns <universeII@gmx.de>

Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>

Regards,
Yann E. MORIN.

> ---
>  package/netsnmp/S59snmpd | 71 +++++++++++++++++++++++++-----------------------
>  1 file changed, 37 insertions(+), 34 deletions(-)
> 
> diff --git a/package/netsnmp/S59snmpd b/package/netsnmp/S59snmpd
> index 4eea512..cfda625 100755
> --- a/package/netsnmp/S59snmpd
> +++ b/package/netsnmp/S59snmpd
> @@ -38,56 +38,59 @@ if [ "$SNMPDCOMPAT" = "yes" ]; then
>    ln -sf /var/agentx/master /var/run/agentx
>  fi
>  
> -case "$1" in
> -  start)
> +start() {
>      printf "Starting network management services:"
>      if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
> -      start-stop-daemon -q -S -x /usr/sbin/snmpd -- $SNMPDOPTS
> -      printf " snmpd"
> +        start-stop-daemon -q -S -x /usr/sbin/snmpd -- $SNMPDOPTS
> +        printf " snmpd"
>      fi
>      if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
> -      start-stop-daemon -q -S -x /usr/sbin/snmptrapd -- $TRAPDOPTS
> -      printf " snmptrapd"
> +        start-stop-daemon -q -S -x /usr/sbin/snmptrapd -- $TRAPDOPTS
> +        printf " snmptrapd"
>      fi
>      echo "."
> -    ;;
> -  stop)
> +}
> +
> +stop() {
>      printf "Stopping network management services:"
>      start-stop-daemon -q -K $ssd_oknodo -x /usr/sbin/snmpd
>      printf " snmpd"
>      start-stop-daemon -q -K $ssd_oknodo -x /usr/sbin/snmptrapd
>      printf " snmptrapd"
>      echo "."
> -    ;;
> -  restart)
> -    printf "Restarting network management services:"
> -    start-stop-daemon -q -K $ssd_oknodo -x /usr/sbin/snmpd
> -    start-stop-daemon -q -K $ssd_oknodo -x /usr/sbin/snmptrapd
> -    # Allow the daemons time to exit completely.
> -    sleep 2
> -    if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
> -      start-stop-daemon -q -S -x /usr/sbin/snmpd -- $SNMPDOPTS
> -      printf " snmpd"
> -    fi
> -    if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
> -      # Allow snmpd time to start up.
> -      sleep 1
> -      start-stop-daemon -q -S -x /usr/sbin/snmptrapd -- $TRAPDOPTS
> -      printf " snmptrapd"
> -    fi
> -    echo "."
> -    ;;
> -  reload|force-reload)
> +}
> +
> +reload() {
>      printf "Reloading network management services:"
>      if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
> -      start-stop-daemon -q -K -s 1 -p /var/run/snmpd.pid -x /usr/sbin/snmpd
> -      printf " snmpd"
> +        start-stop-daemon -q -K -s 1 -p /var/run/snmpd.pid -x /usr/sbin/snmpd
> +        printf " snmpd"
>      fi
>      echo "."
> -    ;;
> -  *)
> -    echo "Usage: /etc/init.d/snmpd {start|stop|restart|reload|force-reload}"
> -    exit 1
> +}
> +
> +case "$1" in
> +    start)
> +        start
> +        ;;
> +
> +    stop)
> +        stop
> +        ;;
> +
> +    restart)
> +        stop
> +        # Allow the daemons time to exit completely.
> +        sleep 2
> +        start
> +        ;;
> +
> +    reload|force-reload)
> +        reload
> +        ;;
> +    *)
> +        echo "Usage: $0 {start|stop|restart|reload|force-reload}"
> +        exit 1
>  esac
>  
>  exit 0
> -- 
> 2.1.4
> 
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Thomas Petazzoni July 1, 2016, 1:01 p.m. UTC | #2
Hello,

On Thu, 25 Feb 2016 22:24:41 +0100, Andreas Ehmanns wrote:
> Changed init script to get rid of double code.
> Start, stop and reload code has been put into
> separate functions and 'restart' will just call
> stop() and start() with a delay in between.
> 
> Signed-off-by: Andreas Ehmanns <universeII@gmx.de>
> ---
>  package/netsnmp/S59snmpd | 71 +++++++++++++++++++++++++-----------------------
>  1 file changed, 37 insertions(+), 34 deletions(-)

Entire series applied, after tweaking the commit titles and in some
cases the commit log.

Thanks!

Thomas
Peter Korsgaard July 2, 2016, 10:25 a.m. UTC | #3
>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:

 > Hello,
 > On Thu, 25 Feb 2016 22:24:41 +0100, Andreas Ehmanns wrote:
 >> Changed init script to get rid of double code.
 >> Start, stop and reload code has been put into
 >> separate functions and 'restart' will just call
 >> stop() and start() with a delay in between.
 >> 
 >> Signed-off-by: Andreas Ehmanns <universeII@gmx.de>
 >> ---
 >> package/netsnmp/S59snmpd | 71 +++++++++++++++++++++++++-----------------------
 >> 1 file changed, 37 insertions(+), 34 deletions(-)

 > Entire series applied, after tweaking the commit titles and in some
 > cases the commit log.

For the future, please use your full name in the From: as well (git
commit user.name "Andreas Ehmanns"). Now these commits are listed as
being from "universe II".

Thanks.
Thomas Petazzoni July 2, 2016, 10:40 a.m. UTC | #4
Hello,

On Sat, 02 Jul 2016 12:25:50 +0200, Peter Korsgaard wrote:

> For the future, please use your full name in the From: as well (git
> commit user.name "Andreas Ehmanns"). Now these commits are listed as
> being from "universe II".

Yeah, also noticed that, but after pushing :-/ The Signed-off-by line
is more visible and that one was correct, so I didn't notice.

Sadly, the new pedantic git commit hook checks that the e-mail between
the From and the SoB line are matching, but not the name itself.

Thomas
diff mbox

Patch

diff --git a/package/netsnmp/S59snmpd b/package/netsnmp/S59snmpd
index 4eea512..cfda625 100755
--- a/package/netsnmp/S59snmpd
+++ b/package/netsnmp/S59snmpd
@@ -38,56 +38,59 @@  if [ "$SNMPDCOMPAT" = "yes" ]; then
   ln -sf /var/agentx/master /var/run/agentx
 fi
 
-case "$1" in
-  start)
+start() {
     printf "Starting network management services:"
     if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
-      start-stop-daemon -q -S -x /usr/sbin/snmpd -- $SNMPDOPTS
-      printf " snmpd"
+        start-stop-daemon -q -S -x /usr/sbin/snmpd -- $SNMPDOPTS
+        printf " snmpd"
     fi
     if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
-      start-stop-daemon -q -S -x /usr/sbin/snmptrapd -- $TRAPDOPTS
-      printf " snmptrapd"
+        start-stop-daemon -q -S -x /usr/sbin/snmptrapd -- $TRAPDOPTS
+        printf " snmptrapd"
     fi
     echo "."
-    ;;
-  stop)
+}
+
+stop() {
     printf "Stopping network management services:"
     start-stop-daemon -q -K $ssd_oknodo -x /usr/sbin/snmpd
     printf " snmpd"
     start-stop-daemon -q -K $ssd_oknodo -x /usr/sbin/snmptrapd
     printf " snmptrapd"
     echo "."
-    ;;
-  restart)
-    printf "Restarting network management services:"
-    start-stop-daemon -q -K $ssd_oknodo -x /usr/sbin/snmpd
-    start-stop-daemon -q -K $ssd_oknodo -x /usr/sbin/snmptrapd
-    # Allow the daemons time to exit completely.
-    sleep 2
-    if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
-      start-stop-daemon -q -S -x /usr/sbin/snmpd -- $SNMPDOPTS
-      printf " snmpd"
-    fi
-    if [ "$TRAPDRUN" = "yes" -a -f /etc/snmp/snmptrapd.conf ]; then
-      # Allow snmpd time to start up.
-      sleep 1
-      start-stop-daemon -q -S -x /usr/sbin/snmptrapd -- $TRAPDOPTS
-      printf " snmptrapd"
-    fi
-    echo "."
-    ;;
-  reload|force-reload)
+}
+
+reload() {
     printf "Reloading network management services:"
     if [ "$SNMPDRUN" = "yes" -a -f /etc/snmp/snmpd.conf ]; then
-      start-stop-daemon -q -K -s 1 -p /var/run/snmpd.pid -x /usr/sbin/snmpd
-      printf " snmpd"
+        start-stop-daemon -q -K -s 1 -p /var/run/snmpd.pid -x /usr/sbin/snmpd
+        printf " snmpd"
     fi
     echo "."
-    ;;
-  *)
-    echo "Usage: /etc/init.d/snmpd {start|stop|restart|reload|force-reload}"
-    exit 1
+}
+
+case "$1" in
+    start)
+        start
+        ;;
+
+    stop)
+        stop
+        ;;
+
+    restart)
+        stop
+        # Allow the daemons time to exit completely.
+        sleep 2
+        start
+        ;;
+
+    reload|force-reload)
+        reload
+        ;;
+    *)
+        echo "Usage: $0 {start|stop|restart|reload|force-reload}"
+        exit 1
 esac
 
 exit 0