[Lunar-commits] CVS: theedge/var/lib/lunar/functions config.lunar,
1.4, 1.5
Steven Michaelske
hardkrash at lunar-linux.org
Mon Jan 12 06:51:30 GMT 2004
Update of /var/cvs/lunar/theedge/var/lib/lunar/functions
In directory dbguin.lunar-linux.org:/tmp/cvs-serv18069
Modified Files:
config.lunar
Log Message:
Beginings for new CONFIGURE file scheme that allows for formats and options to change
new system will set a date in the $MODULE_CONFIG file in the CONFIGURED variable with the set_module_configured function
and the get_module configuted function checks if the configuration date is newer than the stored one
this i believe is a better way than we have now
and it prevents yet another variable in DETAILS files
as this coide would only be called by modules that use the new scheme
Index: config.lunar
===================================================================
RCS file: /var/cvs/lunar/theedge/var/lib/lunar/functions/config.lunar,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- config.lunar 4 Aug 2003 23:19:42 -0000 1.4
+++ config.lunar 12 Jan 2004 06:51:27 -0000 1.5
@@ -14,8 +14,11 @@
# #
# Copyrighted Kagan Kongar 2002 under GPLv2 #
# #
+# Parts copyrighted Steven Michalske 2004 under GPLv2 #
+# #
############################################################
+
# function: write_config
# usage : write_config <line to remove> [<line to add>]
# purpose : removes a line from the $LOCAL_CONFIG and adds another (if given)
@@ -64,3 +67,56 @@
rm -f $LOCAL_CONFIG_BACKUP 2>/dev/null
trap INT QUIT TERM
}
+
+# function: get_module_configured
+# usage: get_module_configured <date of config implement>
+# purpose: This function is to implement a standard method
+# to specify a CONFIGURATION file format change in
+# the moonbase. the date passed should be the unix date
+# that the format was last changed. This is so that when
+# a CONFIGURE file has changed we can inform the user
+# instead of ignoring changes.
+
+get_module_configured(){
+ debug_msg "module_configured ($@)"
+ if [ "$#" -ne "1" ]; then
+ message "${PROBLEM_COLOR}Configuration date missing, assuming unconfigured."
+ message "${MESSAGE_COLOR}Please inform the lunar devlopers of this issue. ${DEFAULT_COLOR}"
+ return false
+ fi
+
+ # Check for file, return false for missing
+ if [ ! -f "$MODULE_CONFIG" ]; then
+ debug_msg "Config file for $MODULE not found"
+ return false
+ fi
+
+ # Check for configured date flag
+ MC_CONFIG_DATE=`grep "CONFIGURED=" $MODULE_CONFIG | \
+ sed "s:.*=\([0-9]*\)[^0-9]*:\1:"`
+ if [ -n "$MC_CONFIG_DATE" ]; then
+ if [ "$MC_CONFIG_DATE" -le "$1" ]; then
+ # the file is old, reconfigure
+ return false
+ else
+ # configuration current
+ return true
+ fi
+ fi
+ # other error?
+ return false
+}
+
+
+# function: set_module_configured
+# usage: set_module_configured [<quoted list of lines to append to file>]
+# purpose: to freshen the module configuration file with current config date
+
+set_module_configured() {
+ debug_msg "set_module_configured ($@)"
+ echo "CONFIGURED=`date -u +%Y%m%d`" > $MODULE_CONFIG
+ for line in $@
+ do
+ echo $line >> $MODULE_CONFIG
+ done
+}
More information about the Lunar-commits
mailing list