[Pm-utils] config files
Peter Jones
pjones at redhat.com
Thu Apr 27 11:59:51 PDT 2006
On Thu, 2006-04-27 at 13:17 -0400, David Zeuthen wrote:
> On Thu, 2006-04-27 at 17:19 +0100, Richard Hughes wrote:
> > > No, this looks terrible. The config.d is only for 3rd party and you
> > > really want all config the vendor supplies in a single
> > > file /etc/pm/config.
> >
> > Seems okay I guess, but for what reason, speed?
>
> No, basically so you can have comments in the single config file telling
> that e.g. PM_STOP_START_SERVICE_ON_SLEEP (or whatever we call it) can be
> extended in a file in config.d by doing
>
> PM_STOP_START_SERVICE_ON_SLEEP="$PM_STOP_START_SERVICE_ON_SLEEP some-lame-service"
Er, ew. That's bug prone; somebody will write a script that forgets to
do include the old one.
I've committed this patch, which allows packages to add config files.
It defines a list of config variables that are "global", which adds them
to the default environment, but also allows hooks to source their own
config files if they need to.
Without further ado:
Index: Makefile
===================================================================
RCS file: /cvs/pm-utils/pm-utils/Makefile,v
retrieving revision 1.24
diff -u -p -r1.24 Makefile
--- Makefile 25 Apr 2006 22:08:17 -0000 1.24
+++ Makefile 27 Apr 2006 18:33:22 -0000
@@ -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
Index: pm/functions
===================================================================
RCS file: /cvs/pm-utils/pm-utils/pm/functions,v
retrieving revision 1.14
diff -u -p -r1.14 functions
--- pm/functions 27 Apr 2006 08:05:43 -0000 1.14
+++ pm/functions 27 Apr 2006 18:33:35 -0000
@@ -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)
(I've add some more info to the README as well)
--
Peter
More information about the Pm-utils
mailing list