[Abtlinux-svn] SF.net SVN: abtlinux: [450] src/trunk/abt.rb
Status: Alpha
Brought to you by:
eschabell
From: <esc...@us...> - 2007-12-30 21:04:45
|
Revision: 450 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=450&view=rev Author: eschabell Date: 2007-12-30 13:04:18 -0800 (Sun, 30 Dec 2007) Log Message: ----------- Implemented checks for main config file and for possible local config file to override settings. Refactored this to use load instead of require which ensures each run will load these files (require does it just once), thereby picking up any changes on next pass. If the main config file is missing, it will attempt to svn a copy from the central repo to fix itself. Modified Paths: -------------- src/trunk/abt.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-12-29 18:25:47 UTC (rev 449) +++ src/trunk/abt.rb 2007-12-30 21:04:18 UTC (rev 450) @@ -24,8 +24,26 @@ # AbTLinux; if not, write to the Free Software Foundation, Inc., 51 Franklin # St, Fifth Floor, Boston, MA 02110-1301 USA ## -require 'abtconfig' +# Load our central configuration file. +$ABTLINUX_MAIN_CONFIG = "https://abtlinux.svn.sourceforge.net/svnroot/abtlinux/src/trunk/abtconfig.rb" + +if File.exist?( "/etc/abt/abtconfig.rb" ) + load '/etc/abt/abtconfig.rb' +else + # missing configuration file, do some abt update? + puts "\n[abt.rb] Missing our main configuration file at /etc/abt/abtconfig.rb" + puts "\n Maybe time for an abt update? Let us try to fix it for you!\n" + ["/etc/abt", "/etc/abt/local"].each { |dir| + if ( ! File.directory?( dir ) ) + FileUtils.mkdir_p( dir ) + puts "Created directory: #{dir}." + end + } + system( "svn export #{$ABTLINUX_MAIN_CONFIG} /etc/abt/abtconfig.rb" ) + exit +end + ## # Setup needed classes and get ready to parse arguments. ## @@ -40,10 +58,16 @@ # setup timestamp. logger.datetime_format = "%Y-%m-%d %H:%M:%S " - # TODO: used only until refactoring done. myLogger = AbtLogManager.new +# And loading local file if found. +if File.exist?( "/etc/abt/local/localconfig.rb" ) + load '/etc/abt/local/localconfig.rb' +else + logger.info( "[abt.rb] No local configuration file found, not a problem, just informing." ) +end + # deal with usage request. if ( ARGV.length == 0 || ( ARGV.length == 1 && ( ARGV[0] == '--help' || ARGV[0] == '-h' || ARGV[0].downcase == 'help' ) ) ) show.usage( "all" ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |