From 4668f6fb3b1eae1cefe2caa7062fcd67a10f1661 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Tue, 10 Sep 2013 11:25:10 +0200 Subject: [PATCH] Config Conversion: Check that icinga.cfg is passed via -c option. --- tools/configconvert/Icinga2/ImportIcinga1Cfg.pm | 2 +- tools/configconvert/icinga2_convert_v1_v2.pl | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/configconvert/Icinga2/ImportIcinga1Cfg.pm b/tools/configconvert/Icinga2/ImportIcinga1Cfg.pm index a1c693c96..3f2557de0 100644 --- a/tools/configconvert/Icinga2/ImportIcinga1Cfg.pm +++ b/tools/configconvert/Icinga2/ImportIcinga1Cfg.pm @@ -46,7 +46,7 @@ sub get_key_from_icinga1_main_cfg { my @key_arr = (); if ( !-f $file) { - errlog(1, "cfg file $file does not exist!"); + print "cfg file $file does not exist!"; return; } diff --git a/tools/configconvert/icinga2_convert_v1_v2.pl b/tools/configconvert/icinga2_convert_v1_v2.pl index ed242d42e..fa007adcf 100755 --- a/tools/configconvert/icinga2_convert_v1_v2.pl +++ b/tools/configconvert/icinga2_convert_v1_v2.pl @@ -90,7 +90,7 @@ GetOptions( "V|version" => \$opt->{version} ); -my $icinga1_cfg = "/etc/icinga/icinga.cfg"; +my $icinga1_cfg; my $icinga2_cfg = {}; my $conf_prefix = "./conf"; my $verbose = 1; @@ -138,6 +138,11 @@ my $type_cnt; # TODO import/export files in parallel? +# verify that we have something to read +if ( !-f $icinga1_cfg) { + pod2usage(1); +} + # the import my $icinga1_cfg_obj = Icinga2::ImportIcinga1Cfg::parse_icinga1_objects($icinga1_cfg); my $icinga1_cfg_obj_cache = Icinga2::ImportIcinga1Cfg::parse_icinga1_objects_cache($icinga1_cfg);