[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: pbbuttonsd script interface - future?



On Sun, Apr 25, 2004 at 06:35:19PM +0200, Matthias Grimm wrote:
> Ok, thats a sollution I can live with. We introduce something new and keep 
> compatibility with existing systems. I would be thankfull for your patch.
The script is attached (again this is based on things Michel Dänzer once
sent do this list). I'd like to suggest several more things.  Please use
a .d suffix for directories processed by run-parts. That's good practise
and helps sysadmins to identify what these directories are for.
Furthermore please use several subdirs:

These two since apmd uses these names and so it eases migration

event.d    <-> former active
scripts.d  <-> former storage

These two since we might want to have scripts for suspend/resume ordered
in different ways:

sleep.d    <-> executed before suspend (suspend.d might be better)
wakeup.d   <-> executed after resume (resume.d might be better)

We can the have symlinks here like:
sleep.d/20nfs  -> ../scripts.d/nfs
sleep.d/21eth0 -> ../scripts.d/eth0

wakeup.d/20eth0 -> ../scripts.d/eth0
wakeup.d/21nfs  -> ../scripts.d/nfs

Where the former first unmounts all nfs mounted directories, then shuts
down eth0 and the later first brings up eth0 again, then mounts the
directories per nfs again. This could be implemented by this patch:

--- ../power.orig/pmcs-pbbuttonsd	2004-04-23 01:52:00.000000000 +0200
+++ pmcs-pbbuttonsd	2004-04-26 15:08:38.687541040 +0200
@@ -20,6 +20,9 @@
 
 PATH=/bin:/sbin:/usr/bin:/usr/sbin
 
+[ -x /usr/bin/logger ] && \
+    	/usr/bin/logger -p daemon.info -t pmcs-pbbuttonsd "called with $1 $2"
+
 case "$1" in
   emergency)
     wall "Low battery - system will go down now!"
@@ -27,7 +30,8 @@
     ;;
   *)
     cd `dirname $0`
-    run-parts --arg="$1" --arg="$2" active
+    [ -d ${1}.d ] && run-parts --arg="$1" --arg="$2" ${1}.d
+    run-parts --arg="$1" --arg="$2" event.d
     ;;
 esac

Did you get in touch with the acpid folks, they might be interested in
this too.
Cheers,
 -- Guido
#!/bin/sh
#
# name        : apmd-compat
# author      : Guido Guenther <agx@sigxcpu.org>
# description : Execute scripts in /etc/apm for compatibility
#
# --- end of public part -- don't change below this line ---

. /etc/power/config

[ "$apmd_compat" = "no" ] && exit 0

case "$2" in
  battery)
	if [ -x /etc/apm/apmd_proxy ]; then 
		/etc/apm/apmd_proxy change power
	else
		run-parts --arg=change --arg=power /etc/apm/event.d	
    		if [ -d /etc/apm/other.d ]; then
            		run-parts --arg=change --arg=power /etc/apm/other.d
	        fi
	fi
  ;;
  ac)
	if [ -x /etc/apm/apmd_proxy ]; then 
		/etc/apm/apmd_proxy change power
	else
		run-parts --arg=change --arg=power /etc/apm/event.d	
    		if [ -d /etc/apm/other.d ]; then
            		run-parts --arg=change --arg=power /etc/apm/other.d
	        fi
	fi
  ;;
esac

case "$1" in
  sleep)
	if [ -x /etc/apm/apmd_proxy ]; then 
		/etc/apm/apmd_proxy suspend user
	else	
		run-parts --arg=suspend --arg=user /etc/apm/event.d
		if [ -d /etc/apm/suspend.d ]; then
        		run-parts --arg=suspend --arg=user /etc/apm/suspend.d
	    	fi
	fi
  ;;
  wakeup)
	if [ -x /etc/apm/apmd_proxy ]; then 
		/etc/apm/apmd_proxy resume suspend
	else
		if [ -d /etc/apm/resume.d ]; then
        		run-parts --arg=resume --arg=suspend /etc/apm/resume.d
		fi
		run-parts --arg=resume --arg=suspend /etc/apm/event.d
	fi
  ;;
esac

Attachment: signature.asc
Description: Digital signature


Reply to: