[Abtlinux-svn] SF.net SVN: abtlinux: [452] src/trunk/abt.rb
Status: Alpha
Brought to you by:
eschabell
From: <esc...@us...> - 2007-12-31 11:27:59
|
Revision: 452 http://abtlinux.svn.sourceforge.net/abtlinux/?rev=452&view=rev Author: eschabell Date: 2007-12-31 03:27:36 -0800 (Mon, 31 Dec 2007) Log Message: ----------- Refactored some user paths when non-root users try to start abt. Modified Paths: -------------- src/trunk/abt.rb Modified: src/trunk/abt.rb =================================================================== --- src/trunk/abt.rb 2007-12-31 11:24:54 UTC (rev 451) +++ src/trunk/abt.rb 2007-12-31 11:27:36 UTC (rev 452) @@ -32,30 +32,45 @@ 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 + puts "\nMissing our main configuration file at /etc/abt/abtconfig.rb" + puts "\nMaybe time for an abt update? Let us try to fix it for you!\n" + # TODO: check for root login. + if ( Process.uid != 0 ) + puts "\nMust be root to fix configuration files." + exit + else + ["/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 end ## # Setup needed classes and get ready to parse arguments. ## manager = AbtPackageManager.new -logger = Logger.new($JOURNAL) # initializes all needed paths. reporter = AbtReportManager.new downloader = AbtDownloadManager.new system = AbtSystemManager.new options = Hash.new show = AbtUsage.new +# deal with usage request. +if ( ARGV.length == 0 || ( ARGV.length == 1 && ( ARGV[0] == '--help' || ARGV[0] == '-h' || ARGV[0].downcase == 'help' ) ) ) + show.usage( "all" ) + exit +end + +# login as root for the rest. +manager.root_login( ARGV ) + # setup timestamp. +logger = Logger.new($JOURNAL) # initializes all needed paths. logger.datetime_format = "%Y-%m-%d %H:%M:%S " # TODO: used only until refactoring done. @@ -68,15 +83,7 @@ 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" ) - exit -end -# login as root for the rest. -manager.root_login( ARGV ) - # parse arguments. case ARGV[0] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |