From f543cf5b0c9cbe3053ee445f6f9b2f3506a2e949 Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Wed, 25 Jun 2008 10:01:11 +0000 Subject: * Rename Dahdi::Config::Defaults to Dahdi::Config::GenconfDefaults . * Reads from the new /etc/dahdi/genconf_parameters . * Do installl xpp_fxloader (the firmware loading wrapper script). * Even more /etc/dahdi/system.conf string fixes. git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@4463 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- xpp/perl_modules/Dahdi/Config/Defaults.pm | 57 ------------------------ xpp/perl_modules/Dahdi/Config/GenconfDefaults.pm | 39 ++++++++++++++++ 2 files changed, 39 insertions(+), 57 deletions(-) delete mode 100644 xpp/perl_modules/Dahdi/Config/Defaults.pm create mode 100644 xpp/perl_modules/Dahdi/Config/GenconfDefaults.pm (limited to 'xpp/perl_modules/Dahdi/Config') diff --git a/xpp/perl_modules/Dahdi/Config/Defaults.pm b/xpp/perl_modules/Dahdi/Config/Defaults.pm deleted file mode 100644 index e720568..0000000 --- a/xpp/perl_modules/Dahdi/Config/Defaults.pm +++ /dev/null @@ -1,57 +0,0 @@ -package Dahdi::Config::Defaults; -# -# Written by Oron Peled -# Copyright (C) 2007, Xorcom -# This program is free software; you can redistribute and/or -# modify it under the same terms as Perl itself. -# -# $Id$ -# -use strict; - -# Use the shell to source a file and expand a given list -# of variables. -sub do_source($@) { - my $file = shift; - my @vars = @_; - my @output = `env -i sh -ec '. $file; export @vars; for i in @vars; do eval echo \$i=\\\$\$i; done'`; - die "$0: Sourcing '$file' exited with $?" if $?; - my %vars; - - foreach my $line (@output) { - chomp $line; - my ($k, $v) = split(/=/, $line, 2); - $vars{$k} = $v if grep /^$k$/, @vars; - } - return %vars; -} - -sub source_vars { - my @vars = @_; - my $default_file; - my %system_files = ( - "/etc/default/zaptel" => 'Debian and friends', - "/etc/sysconfig/zaptel" => 'Red Hat and friends', - "/etc/dahdi/defaults" => 'Dahdi generic', - ); - - if(defined $ENV{DAHDI_DEFAULTS}) { - $default_file = $ENV{DAHDI_DEFAULTS}; - } else { - foreach my $f (keys %system_files) { - if(-r $f) { - if(defined $default_file) { - die "An '$f' collides with '$default_file'"; - } - $default_file = $f; - } - } - } - if (! $default_file) { - return ("", ()); - } - my %vars = Dahdi::Config::Defaults::do_source($default_file, @vars); - return ($default_file, %vars); -} - -1; diff --git a/xpp/perl_modules/Dahdi/Config/GenconfDefaults.pm b/xpp/perl_modules/Dahdi/Config/GenconfDefaults.pm new file mode 100644 index 0000000..9988929 --- /dev/null +++ b/xpp/perl_modules/Dahdi/Config/GenconfDefaults.pm @@ -0,0 +1,39 @@ +package Dahdi::Config::GenconfDefaults; +# +# Written by Oron Peled +# Copyright (C) 2007, Xorcom +# This program is free software; you can redistribute and/or +# modify it under the same terms as Perl itself. +# +# $Id$ +# +use strict; + +# Use the shell to source a file and expand a given list +# of variables. +sub do_source($@) { + my $file = shift; + my @vars = @_; + my @output = `env -i sh -ec '. $file; export @vars; for i in @vars; do eval echo \$i=\\\$\$i; done'`; + die "$0: Sourcing '$file' exited with $?" if $?; + my %vars; + + foreach my $line (@output) { + chomp $line; + my ($k, $v) = split(/=/, $line, 2); + $vars{$k} = $v if grep /^$k$/, @vars; + } + return %vars; +} + +sub source_vars { + my @vars = @_; + my $default_file = $ENV{GENCONF_PARAMETERS} || "/etc/dahdi/genconf_parameters"; + if (! -r $default_file) { + return ("", ()); + } + my %vars = do_source($default_file, @vars); + return ($default_file, %vars); +} + +1; -- cgit v1.2.3