Author: glen                         Date: Mon Sep 29 11:11:15 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- more common code, add try-restart

---- Files affected:
SOURCES:
   netconsole.init (1.3 -> 1.4) 

---- Diffs:

================================================================
Index: SOURCES/netconsole.init
diff -u SOURCES/netconsole.init:1.3 SOURCES/netconsole.init:1.4
--- SOURCES/netconsole.init:1.3 Wed Jul 26 20:03:44 2006
+++ SOURCES/netconsole.init     Mon Sep 29 13:11:09 2008
@@ -66,69 +66,86 @@
 }
 
 start() {
-       checkconfig || return 1
-       if [ -z "${TGT_MAC}" ]; then
-               LC_ALL=C /bin/ping -nq -c 3 "${TGT_IP}" -I "${DEVICE}" 
1>/dev/null 2>/dev/null
-               ret=$?
-               # ping worked, try arp
-               if [ $ret -eq 0 ]; then
-                       TGT_MAC="$(LC_ALL=C arp -an -i ${DEVICE} ${TGT_IP} 
|egrep -v 'incomplete|no match' | awk '{print $4}')"
+       # Check if the service is already running?
+       if [ ! -f /var/lock/subsys/netconsole ]; then
+               checkconfig || exit 1
+
+               if [ -z "${TGT_MAC}" ]; then
+                       LC_ALL=C /bin/ping -nq -c 3 "${TGT_IP}" -I "${DEVICE}" 
1>/dev/null 2>/dev/null
+                       ret=$?
+                       # ping worked, try arp
+                       if [ $ret -eq 0 ]; then
+                               TGT_MAC="$(LC_ALL=C arp -an -i ${DEVICE} 
${TGT_IP} | egrep -v 'incomplete|no match' | awk '{print $4}')"
+                       fi
+               elif [ "${TGT_MAC}" == "broadcast" ]; then
+                       TGT_MAC=''
                fi
-       elif [ "${TGT_MAC}" == "broadcast" ]; then
-               TGT_MAC=''
-       fi
 
-       nls "Starting netconsole %s:%d(%s) -> %s:%d %s" "${SRC_IP}" 
"${SRC_PORT}" "${DEVICE}" "${TGT_IP}" "${TGT_PORT}" "${TGT_MAC}"
-       # else we use the MAC that we are given
-       modprobe netconsole [EMAIL PROTECTED]/${DEVICE},[EMAIL 
PROTECTED]/${TGT_MAC}
-       ret=$?
-       [ $ret -eq 0 ] && dmesg -n ${LOGLEVEL}
+               nls "Starting netconsole %s:%d(%s) -> %s:%d %s" "${SRC_IP}" 
"${SRC_PORT}" "${DEVICE}" "${TGT_IP}" "${TGT_PORT}" "${TGT_MAC}"
+               # else we use the MAC that we are given
+               modprobe netconsole [EMAIL PROTECTED]/${DEVICE},[EMAIL 
PROTECTED]/${TGT_MAC}
+               RETVAL=$?
+               if [ $RETVAL = 0 ]; then
+                       dmesg -n ${LOGLEVEL}
+                       touch /var/lock/subsys/netconsole
+               fi
+       else
+               msg_already_running netconsole
+       fi
 }
 
 stop() {
-       nls "Stopping netconsole"
-       modprobe -r netconsole
-       rc=$?
-       [ "$rc" = 0 ] && ok || fail
-       return $rc
-}
-
-# See how we were called.
-case "$1" in
-  start)
-       # Check if the service is already running?
-       if [ ! -f /var/lock/subsys/netconsole ]; then
-               start
+       if [ -f /var/lock/subsys/netconsole ]; then
+               nls "Stopping netconsole"
+               modprobe -r netconsole
                RETVAL=$?
-               [ $RETVAL -eq 0 ] && touch /var/lock/subsys/netconsole
+               if [ $RETVAL = 0 ]; then
+                       rm -f /var/lock/subsys/netconsole
+                       ok
+               else
+                       fail
+               fi
        else
-               msg_already_running netconsole
+               msg_not_running netconsole
        fi
-       ;;
-  stop)
+}
+
+condrestart() {
        if [ -f /var/lock/subsys/netconsole ]; then
                stop
-               RETVAL=$?
-               [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/netconsole
+               start
        else
                msg_not_running netconsole
+               RETVAL=$1
        fi
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+       start
        ;;
-  restart|force-reload)
-       $0 stop
-       $0 start
-       exit $?
+  stop)
+       stop
+       ;;
+  restart)
+       stop
+       start
+       ;;
+  try-restart)
+       condrestart 0
+       ;;
+  force-reload)
+       condrestart 7
        ;;
   status)
        status netconsole
        RETVAL=$?
        ;;
   *)
-       msg_usage "$0 {start|stop|restart|force-reload|status}"
+       msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
        exit 3
 esac
 
 exit $RETVAL
-
-# This must be last line !
-# vi:syntax=sh
================================================================

---- CVS-web:
    
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/netconsole.init?r1=1.3&r2=1.4&f=u

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to