diff options
author | Peter Jones <pjones@redhat.com> | 2006-04-27 18:52:47 +0000 |
---|---|---|
committer | Peter Jones <pjones@redhat.com> | 2006-04-27 18:52:47 +0000 |
commit | f4d24f06dd905563f628b11155c8244f8639e328 (patch) | |
tree | 14f56cdc0cc125a38a7e091cc0d260658094b897 | |
parent | 3a3d1ba965163a5ede3329973e458a09e105a155 (diff) |
- allow for /etc/pm/config.d/
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | README | 27 | ||||
-rwxr-xr-x | pm/functions | 18 |
3 files changed, 46 insertions, 0 deletions
@@ -46,6 +46,7 @@ install: install -m 755 -d $(sysconfdir)/security/console.apps install -m 755 -d $(sysconfdir)/pm install -m 755 -d $(sysconfdir)/pm/hooks + install -m 755 -d $(sysconfdir)/pm/config.d install -m 644 pm-suspend.pam $(sysconfdir)/pam.d/pm-suspend install -m 644 pm-suspend.app $(sysconfdir)/security/console.apps/pm-suspend install -m 644 pm-hibernate.pam $(sysconfdir)/pam.d/pm-hibernate @@ -23,3 +23,30 @@ file into the hooks directory, for example: - removing and modprobing modules when needed - setting grub to be the default target for a hibernate-resume - other wacky things that need doing on specific systems + +How do "hooks" work? + +* You put a file in /etc/pm/hooks, which is executable. When suspend or + hibernate is called, several things happen: + + 1) a new virtual terminal is alloced and switched to + 2) /etc/pm/config is evaluated . This config file that should only be + modified by end-users. + 3) /etc/pm/config.d/* are evaluated in C sort order. These files can be + provided by individual packages outside of pm-utils. If a global config + variable is set, the value set to will be appended to the previous value. + If any other variable is set, it will be ignored. + 4) each of /etc/pm/hooks/* are executed in C sort order. The first command + line argument is "suspend" or "hibernate". These files may source + configuration files from /etc/pm/config.d/ on their own in order to pick + up variables set there that aren't part of the global list. Note that + hooks should take care to preserve any global configuration variable + which _that_ hook will later need to use, as sourcing this config file + will clobber any such variables. + 5) the system suspends or hibernates. + 6) some event happens to wake the machine up + 7) each of /etc/pm/hooks/* are executed in reverse C sort order. The first + command line argument is "resume" or "thaw". + 8) the system switches back to the original virtual terminal from step 1. + + That's it! diff --git a/pm/functions b/pm/functions index 741d5cf..7d9d3a3 100755 --- a/pm/functions +++ b/pm/functions @@ -12,6 +12,24 @@ SUSPEND_MODULES="" export HIBERNATE_RESUME_POST_VIDEO export SUSPEND_MODULES +GLOBAL_CONFIG_VARIABLES="HIBERNATE_RESUME_POST_VIDEO SUSPEND_MODULES" + +source_configs() +{ + for cfg in /etc/pm/config.d/* ; do + STR=". $cfg" + for v in $GLOBAL_CONFIG_VARIABLES ; do + STR="$STR ; echo x_$v=\"\$(eval echo \$$v)\"" + done + eval $(bash -c "$STR") + for v in $GLOBAL_CONFIG_VARIABLES ; do + eval $v="$(eval echo $(eval echo \$$v) \$x_$v)" + done + done +} + +source_configs + take_suspend_lock() { VT=$(/usr/bin/fgconsole) |