packages: netconsole/netconsole.init - update with template.init
glen
glen at pld-linux.org
Tue May 11 18:23:11 CEST 2010
Author: glen Date: Tue May 11 16:23:11 2010 GMT
Module: packages Tag: HEAD
---- Log message:
- update with template.init
---- Files affected:
packages/netconsole:
netconsole.init (1.8 -> 1.9)
---- Diffs:
================================================================
Index: packages/netconsole/netconsole.init
diff -u packages/netconsole/netconsole.init:1.8 packages/netconsole/netconsole.init:1.9
--- packages/netconsole/netconsole.init:1.8 Tue May 11 18:19:26 2010
+++ packages/netconsole/netconsole.init Tue May 11 18:23:06 2010
@@ -27,44 +27,72 @@
exit 0
fi
-eerror() {
- echo >&2 "$*"
- log_failed "$*"
-}
-
-checkconfig() {
+# configtest itself
+# must return non-zero if check failed
+# output is discarded if checkconfig is ran without details
+configtest() {
# anything above 8 reports invalid argument
if [ "$LOGLEVEL" -lt 0 -o "$LOGLEVEL" -gt 8 ]; then
- eerror "Invalid kernel console loglevel."
+ nls "Invalid kernel console loglevel."
return 1
fi
if [ "$SRC_PORT" -le 0 ]; then
- eerror "Invalid source port."
+ nls "Invalid source port."
return 1
fi
+ # TODO: use ip(8)
LC_ALL=C /sbin/ifconfig "${DEVICE}" 1>/dev/null 2>/dev/null
ret=$?
if [ -z "${DEVICE}" -o "${ret}" -gt 0 ]; then
- eerror "Source device invalid."
+ nls "Source device invalid."
return 1
fi
if [ "$TGT_PORT" -le 0 ]; then
- eerror "Invalid target port."
+ nls "Invalid target port."
return 1
fi
if [ -z "$TGT_IP" ]; then
- eerror "Unspecified target address."
+ nls "Unspecified target address."
return 1
fi
return 0
}
+# wrapper for configtest
+checkconfig() {
+ local details=${1:-0}
+
+ if [ $details = 1 ]; then
+ # run config test and display report (status action)
+ show "Checking %s configuration" "netconsole"; busy
+ local out
+ out=$(configtest 2>&1)
+ RETVAL=$?
+ if [ $RETVAL = 0 ]; then
+ ok
+ else
+ fail
+ fi
+ [ "$out" ] && echo >&2 "$out"
+ else
+ # run config test and abort with nice message if failed
+ # (for actions checking status before action).
+ configtest >/dev/null 2>&1
+ RETVAL=$?
+ if [ $RETVAL != 0 ]; then
+ show "Checking %s configuration" "netconsole"; fail
+ nls 'Configuration test failed. See details with %s "checkconfig"' $0
+ exit $RETVAL
+ fi
+ fi
+}
+
start() {
# Check if the service is already running?
if [ -f /var/lock/subsys/netconsole ]; then
@@ -72,7 +100,7 @@
return
fi
- checkconfig || exit 1
+ checkconfig
if [ -z "${TGT_MAC}" ]; then
LC_ALL=C /bin/ping -nq -c 3 "${TGT_IP}" -I "${DEVICE}" 1>/dev/null 2>/dev/null
@@ -121,7 +149,7 @@
return
fi
- checkconfig || exit 1
+ checkconfig
stop
start
}
@@ -136,7 +164,7 @@
stop
;;
restart)
- checkconfig || exit 1
+ checkconfig
stop
start
;;
@@ -146,12 +174,15 @@
force-reload)
condrestart 7
;;
+ checkconfig|configtest)
+ checkconfig 1
+ ;;
status)
status netconsole
RETVAL=$?
;;
*)
- msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
+ msg_usage "$0 {start|stop|restart|try-restart|force-reload|checkconfig|status}"
exit 3
esac
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/netconsole/netconsole.init?r1=1.8&r2=1.9&f=u
More information about the pld-cvs-commit
mailing list