Package: hddtemp
Version: 0.3-beta15-44
Severity: wishlist
Tags: patch

Please consider the attached cleanup patch:

  * sed can do grep too; generates CDROMS_LIST using sed only
  * uses already available variable instead of hard coding /usr/sbin/hddtemp
  * replaces '-[ao]' in tests; consist now throughout the file
  * cleans up some whitespace damage
  * breaking long lines is also desirable, but this patch makes no attempt
    to fix that
  * some quoted strings (like "true", "yes") don't need to, but this patch
    makes no attempt to fix that
  * most variables in /etc/default/hddtemp don't need to be quoted, but
    this patch makes no attempt to fix that

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.24-1-686 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE= (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash

Versions of packages hddtemp depends on:
ii  debconf [debconf-2.0]         1.5.22     Debian configuration management sy
ii  libc6                         2.7-12     GNU C Library: Shared libraries
ii  lsb-base                      3.2-12     Linux Standard Base 3.2 init scrip

hddtemp recommends no packages.

-- debconf information excluded

Cheers,

-- 
Cristian
--- hddtemp.orig	2008-06-14 15:44:44.000000000 +0200
+++ hddtemp	2008-06-14 15:43:57.000000000 +0200
@@ -22,7 +22,7 @@
 
 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 NAME=hddtemp
-DAEMON=/usr/sbin/hddtemp
+DAEMON=/usr/sbin/$NAME
 DESC="disk temperature monitoring daemon"
 
 DISKS="/dev/hd? /dev/sr? /dev/sg? /dev/sd?"
@@ -34,11 +34,11 @@
 # Reads config file (will override defaults above)
 [ -r /etc/default/hddtemp ] && . /etc/default/hddtemp
 
-if [ -n "$RUN_SYSLOG" -a "$RUN_SYSLOG" != "0" ] ; then
+if [ -n "$RUN_SYSLOG" ] && [ "$RUN_SYSLOG" != "0" ] ; then
 	SYSLOG_ARG="-S $RUN_SYSLOG"
 fi
 
-if [ "$RUN_DAEMON" = "true" -o "$RUN_DAEMON" = "yes" ] ; then
+if [ "$RUN_DAEMON" = "true" ] || [ "$RUN_DAEMON" = "yes" ] ; then
 	DAEMON_ARG="-d -l $INTERFACE -p $PORT -s $SEPARATOR"
 fi
 
@@ -47,16 +47,16 @@
 . /lib/lsb/init-functions
 
 case "$1" in
-  start)
+    start)
 	# master switch
-  	if [ -n "$DAEMON_ARG" -o -n "$SYSLOG_ARG" ] ; then
-  		log_daemon_msg "Starting $DESC" "$NAME:"
-		CDROMS_LIST="$(grep "^drive name:" /proc/sys/dev/cdrom/info 2>/dev/null | sed -e 's/^drive name:\t//g' -e 's/\t/ \/dev\//g')"
+	if [ -n "$DAEMON_ARG" ] || [ -n "$SYSLOG_ARG" ] ; then
+		log_daemon_msg "Starting $DESC" "$NAME:"
+		CDROMS_LIST=$(sed -ne 's/^drive name:\t\+\(.*\)$/ \/dev\/\1/p' /proc/sys/dev/cdrom/info 2>/dev/null) || :
 		CDROMS_LIST="$CDROMS_LIST $(grep -sl '^ide-scsi ' /proc/ide/hd*/driver | awk -F / '{ print "/dev/"$4 }')"
-        	for disk in $DISKS ; do
+		for disk in $DISKS ; do
 			echo $CDROMS_LIST | grep -wq $disk && continue
 			echo $DISKS_NOPROBE | grep -wq $disk && continue
-			if /usr/sbin/hddtemp -wn $OPTIONS $disk 2>/dev/null | /bin/grep -q '^[0-9]\+$' ; then
+			if $DAEMON -wn $OPTIONS $disk 2>/dev/null | grep -q '^[0-9]\+$' ; then
 				DISKS_LIST="$DISKS_LIST $disk";
 			fi
 		done
@@ -71,18 +71,18 @@
 		fi
 	fi
 	;;
-  stop)
+    stop)
 	# master switch
-  	if [ "$RUN_DAEMON" = "true" -o "$RUN_DAEMON" = "yes" -o "$RUN_SYSLOG" != "0" ] ; then
- 		log_daemon_msg "Stopping $DESC" "$NAME"
+	if [ "$RUN_DAEMON" = "true" ] || [ "$RUN_DAEMON" = "yes" ] || [ "$RUN_SYSLOG" != "0" ] ; then
+		log_daemon_msg "Stopping $DESC" "$NAME"
 		start-stop-daemon --stop --oknodo --exec $DAEMON --retry 30
 		log_end_msg $?
 	fi
 	;;
-  reload|restart|force-reload)
+    reload|restart|force-reload)
 	$0 stop && $0 start
 	;;
-  *)
+    *)
 	echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2
 	exit 1
 	;;

Reply via email to