summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/oxidized1
-rw-r--r--lib/oxidized/config.rb10
2 files changed, 9 insertions, 2 deletions
diff --git a/bin/oxidized b/bin/oxidized
index f2fb9ff..e5d9bec 100755
--- a/bin/oxidized
+++ b/bin/oxidized
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
+
# FIX ME, killing oxidized needs -9
trap("INT") { exit } # sinatra will otherwise steal this from us
diff --git a/lib/oxidized/config.rb b/lib/oxidized/config.rb
index 9c2faff..02698a6 100644
--- a/lib/oxidized/config.rb
+++ b/lib/oxidized/config.rb
@@ -1,6 +1,7 @@
module Oxidized
require 'asetus'
class NoConfig < OxidizedError; end
+ class InvalidConfig < OxidizedError; end
class Config
Root = File.join ENV['HOME'], '.config', 'oxidized'
Crash = File.join Root, 'crash'
@@ -39,8 +40,13 @@ module Oxidized
'juniper' => 'junos',
}
- CFGS.load # load system+user configs, merge to Config.cfg
- CFG = CFGS.cfg # convenienence, instead of Config.cfg.password, CFG.password
+ begin
+ CFGS.load # load system+user configs, merge to Config.cfg
+ rescue => error
+ raise InvalidConfig, "Error loading config: #{error.message}"
+ ensure
+ CFG = CFGS.cfg # convenienence, instead of Config.cfg.password, CFG.password
+ end
Log.level = Logger::INFO unless CFG.debug
raise NoConfig, 'edit ~/.config/oxidized/config' if CFGS.create