[dahdi-commits] tzafrir: tools/trunk r5440 - /tools/trunk/xpp/dahdi_genconf

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Thu Dec 4 18:24:10 CST 2008


Author: tzafrir
Date: Thu Dec  4 18:24:09 2008
New Revision: 5440

URL: http://svn.digium.com/view/dahdi?view=rev&rev=5440
Log:
dahdi_genconf: add output type 'modules' (/etc/dahdi/modules)

Also improved documentation.

Modified:
    tools/trunk/xpp/dahdi_genconf

Modified: tools/trunk/xpp/dahdi_genconf
URL: http://svn.digium.com/view/dahdi/tools/trunk/xpp/dahdi_genconf?view=diff&rev=5440&r1=5439&r2=5440
==============================================================================
--- tools/trunk/xpp/dahdi_genconf (original)
+++ tools/trunk/xpp/dahdi_genconf Thu Dec  4 18:24:09 2008
@@ -12,6 +12,7 @@
 BEGIN { my $dir = dirname($0); unshift(@INC, "$dir", "$dir/perl_modules"); }
 
 use Dahdi;
+use Dahdi::Hardware;
 use Dahdi::Xpp;
 use Dahdi::Config::GenconfDefaults;
 
@@ -131,6 +132,7 @@
 
 
 my $dahdiconf_file;
+my $dahdimods_file;
 my $chan_dahdi_channels_file;
 my $users_file;
 my $chan_dahdi_conf_file;
@@ -138,6 +140,7 @@
 
 my %files = (
 	dahdi		=> { file => \$dahdiconf_file, func => \&gen_dahdiconf },
+	modules		=> { file => \$dahdimods_file, func => \&gen_dahdimods },
 	chan_dahdi	=> { file => \$chan_dahdi_channels_file, func => \&gen_chan_dahdi_channelsconf },
 	users		=> { file => \$users_file, func => \&gen_usersconf },
 	unicall		=> { file => \$unicall_channels_file, func => \&gen_unicall_channels },
@@ -313,6 +316,32 @@
 	select $old;
 }
 
+
+sub gen_dahdimods($) {
+	my $file = shift || die;
+	rename "$file", "$file.bak"
+		or $! == 2	# ENOENT (No dependency on Errno.pm)
+		or die "Failed to backup old config: $!\n";
+	open(F, ">$file") || die "$0: Failed to open $file: $!\n";
+	my $old = select F;
+	printf "# Autogenerated by %s on %s\n", $0, scalar(localtime);
+	print <<"HEAD";
+# List of modules for DAHDI devices detected on the system
+#
+# This file is parsed by the dahdi init.d script, /etc/init.d/dahdi
+# Anything after '#' is a comment. List one module in a line.
+#
+HEAD
+	my $hardware = Dahdi::Hardware->scan;
+	foreach my $dev ($hardware->device_list) {
+		my $description = $dev->description || "";
+		printf "%s\t#%s %s\n", $dev->driver,
+			$dev->description, $dev->hardware_name;
+	}
+	close F;
+	select $old;
+}
+
 my %DefaultConfigs = (
 	context => 'default',
 	group => '63', # FIXME: should not be needed. 
@@ -324,7 +353,7 @@
 
 sub reset_chan_dahdi_values {
 	foreach my $arg (@_) {
-		if (exists $DefaultConfigs{$arg}) {
+		if (exists ($DefaultConfigs{$arg})) {
 			print "$arg = $DefaultConfigs{$arg}\n";
 		} else {
 			print "$arg =\n";
@@ -613,6 +642,7 @@
 		$val =~ s/{fxs_default_start}/$fxs_default_start/g;
 	}
 	$dahdiconf_file = $ENV{DAHDI_CONF_FILE} || "/etc/dahdi/system.conf";
+	$dahdimods_file = $ENV{DAHDI_MODS_FILE} || "/etc/dahdi/modules";
 	$chan_dahdi_channels_file = $ENV{CHAN_DAHDI_CHANNELS_FILE} || "/etc/asterisk/dahdi-channels.conf";
 	$users_file = $ENV{USERS_FILE} || "/etc/asterisk/users.conf";
 	$unicall_channels_file = $ENV{UNICALL_CHANNELS_FILE} || "/etc/asterisk/unicall-channels.conf";
@@ -649,31 +679,48 @@
 
 =head1 DESCRIPTION
 
-This script generate configuration files for Dahdi hardware.
-Currently it can generate three files: dahdi, chan_dahdi, users and chan_dahdi_full (see below).
-Without arguments, it generates only dahdi and chan_dahdi.
+This script generate configuration files for DAHDI hardware. The
+parameters are types of files to generate. By default it will generate
+the types 'dahdi' and 'chan_dahdi'. See below a complete list.
 
 =over 4
 
 =item dahdi - /etc/dahdi/system.conf
 
-Configuration for dahdi_cfg(1). It's location may be overriden by the
+Configuration for dahdi_cfg(1). Its location may be overriden by the
 environment variable DAHDI_CONF_FILE.
 
+=item modules /etc/dahdi/modules
+
+List of DAHDI kernel modules to be loaded by the init.d script. One
+module per line. Its location may be overriden with the variable
+DAHDI_MODS_FILE.
+
 =item chan_dahdi - /etc/asterisk/dahdi-channels.conf
 
 Configuration for asterisk(1). It should be included in the main /etc/asterisk/chan_dahdi.conf.
-It's location may be overriden by the environment variable CHAN_DAHDI_CHANNELS_FILE.
+Its location may be overriden by the environment variable 
+CHAN_DAHDI_CHANNELS_FILE.
 
 =item users - /etc/asterisk/users.conf
 
 Configuration for asterisk(1) and AsteriskGUI.
-It's location may be overriden by the environment variable USERS_FILE.
+Its location may be overriden by the environment variable USERS_FILE.
 
 =item chan_dahdi_full - /etc/asterisk/chan_dahdi.conf
 
 Configuration for asterisk(1) and AsteriskGUI.
-It's location may be overriden by the environment variable CHAN_DAHDI_CONF_FILE.
-
+Its location may be overriden by the environment variable CHAN_DAHDI_CONF_FILE.
 
 =back
+
+=head1 EXAMPLES
+
+Generate /etc/dahdi/system.conf ('dahdi') and a snippet of
+chan_dahdi.conf ('chan_dahdi'):
+
+  dahdi_genconf
+
+Create those two files, and /etc/dahdi/modules:
+
+  dahdi_genconf chan_dahdi dahdi modules




More information about the dahdi-commits mailing list