diff options
Diffstat (limited to 'lib/oxidized/config')
-rw-r--r-- | lib/oxidized/config/bootstrap.rb | 3 | ||||
-rw-r--r-- | lib/oxidized/config/core.rb | 9 |
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/oxidized/config/bootstrap.rb b/lib/oxidized/config/bootstrap.rb index 73750de..4f9e2ab 100644 --- a/lib/oxidized/config/bootstrap.rb +++ b/lib/oxidized/config/bootstrap.rb @@ -10,7 +10,7 @@ module Oxidized CFG.threads = 30 CFG.timeout = 5 CFG.prompt = /^([\w.@-]+[#>]\s?)$/ - CFG.rest = 8888 + CFG.rest = '0.0.0.0:8888' CFG.vars = { :enable => 'enablePW', } @@ -30,5 +30,4 @@ module Oxidized 'cisco' => 'ios', 'juniper' => 'junos', } - CFG.save end diff --git a/lib/oxidized/config/core.rb b/lib/oxidized/config/core.rb index c2cde58..9b93d91 100644 --- a/lib/oxidized/config/core.rb +++ b/lib/oxidized/config/core.rb @@ -11,17 +11,22 @@ module Oxidized # load config from file or bootstrap with built-ins def load if File.exists? @file - marshal_load YAML.load_file @file + cfg = YAML.load_file @file + marshal_load self.to_h.merge(cfg) else - require 'oxidized/config/bootstrap' + save end end + def defaults + require 'oxidized/config/bootstrap' + end # save config to file def save File.write @file, YAML.dump(marshal_dump) end end CFG = Config.new + CFG.defaults CFG.load Log.file = CFG.log if CFG.log Log.level = Logger::INFO unless CFG.debug |