On Sun, Aug 27, 2006 at 09:11:44PM +0200, Bart Samwel wrote:
David Härdeman wrote:
the attached patch changes the laptop-mode-tools init.d script(s) to use lsb logging functions.

Looks good, thanks very much for contributing! It will be included in the next release.

Actually, I just saw that the laptop_mode executable generates output which messes up the LSB log output lines. I've attached an updated version of the patch which catches the output and prints it properly using the lsb functions. Please use this version instead.

Regards,
David
diff -ur ./laptop-mode-tools-1.31.orig/debian/control 
./laptop-mode-tools-1.31/debian/control
--- ./laptop-mode-tools-1.31.orig/debian/control        2006-08-28 
18:07:31.000000000 +0200
+++ ./laptop-mode-tools-1.31/debian/control     2006-08-28 18:07:58.000000000 
+0200
@@ -7,6 +7,7 @@
 
 Package: laptop-mode-tools
 Architecture: all
+Depends: lsb-base (>= 3.0-10)
 Recommends: acpid | apmd | pbbuttonsd | pmud, hdparm, sdparm
 Conflicts: noflushd
 Description: Scripts to spin down hard drive and save power
diff -ur ./laptop-mode-tools-1.31.orig/etc/init.d/laptop-mode 
./laptop-mode-tools-1.31/etc/init.d/laptop-mode
--- ./laptop-mode-tools-1.31.orig/etc/init.d/laptop-mode        2006-02-06 
11:33:38.000000000 +0100
+++ ./laptop-mode-tools-1.31/etc/init.d/laptop-mode     2006-08-28 
18:11:13.000000000 +0200
@@ -8,43 +8,45 @@
 
 test -f /usr/sbin/laptop_mode || exit 0
 
+. /lib/lsb/init-functions
+
 # Enable laptop mode when the system is booted when running on battery.
 
 case $1 in
   start)
-    echo -n "Enabling laptop mode: "
+    log_action_begin_msg "Enabling laptop mode"
     touch /var/run/laptop-mode-enabled        
-    /usr/sbin/laptop_mode auto init
-    exit 0
+    RESULT=$(/usr/sbin/laptop_mode auto init)
+    log_action_end_msg 0 "$RESULT"
     ;;
 
   restart|reload|force-reload)
     set -e
-    echo -n "Restarting laptop mode: "    
-    /usr/sbin/laptop_mode auto init force
-    exit 0
+    log_action_begin_msg "Restarting laptop mode"
+    RESULT=$(/usr/sbin/laptop_mode auto init force)
+    log_action_end_msg 0 "$RESULT"
     ;;
 
   stop)
     rm -f /var/run/laptop-mode-enabled
-    echo -n "Disabling laptop mode: "
-    if ! ( /usr/sbin/laptop_mode stop init ) ; then
-       echo " (failed)."
+    log_action_begin_msg "Disabling laptop mode"
+    RESULT=$(/usr/sbin/laptop_mode stop init)
+    if [ $? -ne 0 ]; then
+       log_action_end_msg 1 "$RESULT"
        exit 1
     fi
-    exit 0
+    log_action_end_msg 0
     ;;
 
   status)
     echo "Laptop mode status:"
     echo
     /usr/sbin/laptop_mode status
-    exit 0
     ;;
     
   *)
-      echo "Usage: $0 {stop|start|restart|reload|force-reload|status}" >&2
-      exit 1
+    echo "Usage: $0 {stop|start|restart|reload|force-reload|status}" >&2
+    exit 2
     ;;
 esac
-
+exit 0

Reply via email to