From 1e6b2741db99b34f7d63ac96dd5a876686d27131 Mon Sep 17 00:00:00 2001 From: Oron Peled Date: Sun, 6 Apr 2014 13:01:32 -0400 Subject: [PATCH] dahdi_genconf: remove hard-coded E1 default * The "spantypes" generator had E1 default if no 'line-mode' parameter was passed. * As a result the new logic in "dahdi_span_types dumpconfig" had no effect when called from dahdi_genconf, as it was always called with "--line-mode=" argument. * Now "dahdi_genconf spantype" behaves just like "dahdi_span_types dumpconfig": - The "--line-mode=" forces generation of provided line-mode (E1/J1/T1) - Without this option, the generated config matches the current spans state according to new dahd_span_types default logic: - Wildcard rule if all spans have same line-mode. - Uncommented specific matches if spans have different line-modes. Signed-off-by: Tzafrir Cohen Acked-by: Russ Meyerriecks --- xpp/perl_modules/Dahdi/Config/Gen/Spantypes.pm | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/xpp/perl_modules/Dahdi/Config/Gen/Spantypes.pm b/xpp/perl_modules/Dahdi/Config/Gen/Spantypes.pm index dfa0608..b1914bb 100644 --- a/xpp/perl_modules/Dahdi/Config/Gen/Spantypes.pm +++ b/xpp/perl_modules/Dahdi/Config/Gen/Spantypes.pm @@ -30,16 +30,21 @@ sub generate($$$) { return if $?; my $line_mode = $genopts->{'line-mode'}; - $line_mode = 'E1' unless defined $line_mode; - $line_mode =~ /^[ETJ]1$/ or die "Bad line-mode='$line_mode'\n"; - warn "Empty configuration -- no spans\n" unless @spans; + my $cmd; + if (defined $line_mode) { + $line_mode =~ /^[ETJ]1$/ or die "Bad line-mode='$line_mode'\n"; + $cmd = "dahdi_span_types --line-mode=$line_mode dumpconfig > $file"; + printf("Generating $file (with default line-mode %s)\n", $line_mode) + if $genopts->{verbose}; + } else { + $cmd = "dahdi_span_types dumpconfig > $file"; + printf("Generating $file (no --line-mode override)\n") + if $genopts->{verbose}; + } rename "$file", "$file.bak" or $! == 2 # ENOENT (No dependency on Errno.pm) or die "Failed to backup old config: $!\n"; #$gconfig->dump; - printf("Generating $file (with default line-mode %s)\n", $line_mode) - if $genopts->{verbose}; - my $cmd = "dahdi_span_types --line-mode=$line_mode dumpconfig > $file"; system $cmd; die "Command failed (status=$?): '$cmd'" if $?; }