Package: iscsitarget Version: 0.4.16+svn162-2 Severity: normal Tags: patch This patch, from Ubuntu, makes the iscitarget an LSB-style init script, with more consistent reporting.
It also makes the module unloading in the "stop" action a non-fatal error. Appropriate error messages are logged, but they do not cause the init script to exit non-zero. :-Dustin
diff -u iscsitarget-0.4.16+svn162/debian/iscsitarget.init iscsitarget-0.4.16+svn162/debian/iscsitarget.init
--- iscsitarget-0.4.16+svn162/debian/iscsitarget.init
+++ iscsitarget-0.4.16+svn162/debian/iscsitarget.init
@@ -19,6 +19,8 @@
# with knowledge about it.
MEM_SIZE=1048576
+. /lib/lsb/init-functions
+
configure_memsize()
{
if [ -e /proc/sys/net/core/wmem_max ]; then
@@ -54,68 +56,67 @@
ietd_start()
{
- echo -n "Starting iSCSI enterprise target service: "
+ log_daemon_msg "Starting iSCSI enterprise target service"
configure_memsize
- modprobe -q crc32c
- modprobe iscsi_trgt
+ modprobe -q crc32c && modprobe -q iscsi_trgt
RETVAL=$?
if [ $RETVAL != "0" ] ; then
- echo "failed - module is missing!"
+ log_end_msg 1
exit $RETVAL
fi
start-stop-daemon --start --exec $DAEMON --quiet --oknodo
RETVAL=$?
- if [ $RETVAL = "0" ]; then
- echo "succeeded."
- else
- echo "failed."
+ if [ $RETVAL != "0" ]; then
+ log_end_msg 1
exit $RETVAL
- fi
+ fi
+ log_end_msg 0
+ exit 0
}
ietd_stop()
{
- echo -n "Removing iSCSI enterprise target devices: "
- pidof ietd >/dev/null 2>&1
+ log_daemon_msg "Removing iSCSI enterprise target devices"
+ pgrep -s `cat $PID_FILE 2>/dev/null || echo "x"` >/dev/null 2>&1
RETVAL=$?
if [ $RETVAL = "0" ] ; then
# ugly, but ietadm does not allways provides correct exit values
RETURN=`ietadm --op delete 2>&1`
RETVAL=$?
if [ $RETVAL = "0" ] && [ "$RETURN" != "something wrong" ] ; then
- echo "succeeded."
+ log_end_msg 0
else
- echo "failed with reason :$RETURN"
- exit 1
+ log_end_msg 1
+ log_failure_msg "Failed with reason: $RETURN"
+ exit $RETVAL
fi
- echo -n "Stopping iSCSI enterprise target service: "
+ log_daemon_msg "Stopping iSCSI enterprise target service"
start-stop-daemon --stop --quiet --exec $DAEMON --pidfile $PID_FILE --oknodo
RETVAL=$?
- if [ $RETVAL = "0" ]; then
- echo "succeeded."
- else
- echo "failed."
+ if [ $RETVAL != "0" ]; then
+ log_end_msg 1
+ else
+ log_end_msg 0
fi
else
- echo "service not running."
+ log_end_msg 0
fi
# ugly, but pid file is not removed ba ietd
- rm -f $PID_FILE
+ rm -f $PID_FILE 2>/dev/null
# check if the module is loaded at all
lsmod | grep -q iscsi_trgt
RETVAL=$?
if [ $RETVAL = "0" ] ; then
-
- echo -n "Removing iSCSI enterprise target modules: "
- modprobe -r iscsi_trgt
+ log_warning_msg "Removing iSCSI enterprise target modules"
+ modprobe -r iscsi_trgt 2>/dev/null && modprobe -q crc32c 2>/dev/null
RETVAL=$?
- modprobe -r crc32c 2>/dev/null
if [ $RETVAL = "0" ]; then
- echo "succeeded."
+ log_end_msg 0
else
- echo "failed."
- exit 1
+ log_end_msg 1
+ # Lack of module unloading should be reported,
+ # but not necessarily exit non-zero
fi
fi
}
@@ -133,16 +134,10 @@
ietd_start
;;
status)
- PID=`pidof ietd`
- if [ $PID ]; then
- echo "iSCSI enterprise target is running at pid $PID"
- else
- echo "no iSCSI enterprise target found!"
- exit 1
- fi
- ;;
+ status_of_proc -p $PID_FILE $DAEMON "iSCSI enterprise target" && exit 0 || exit $?
+ ;;
*)
- echo "Usage: $0 {start|stop|restart|status}"
+ log_action_msg "Usage: $0 {start|stop|restart|status}"
exit 1
esac
diff -u iscsitarget-0.4.16+svn162/debian/control iscsitarget-0.4.16+svn162/debian/control
--- iscsitarget-0.4.16+svn162/debian/control
+++ iscsitarget-0.4.16+svn162/debian/control
@@ -9,7 +10,7 @@
Package: iscsitarget
Architecture: any
-Depends: ${shlibs:Depends}
+Depends: ${shlibs:Depends}, lsb-base (>= 3.2-14)
Recommends: iscsitarget-module
Suggests: iscsitarget-source
Description: iSCSI Enterprise Target userland tools
signature.asc
Description: This is a digitally signed message part

