summaryrefslogtreecommitdiff
path: root/xpp/dahdi_genconf
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2008-12-05 00:24:09 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2008-12-05 00:24:09 +0000
commitb3e8ddc056feb1068314f3d9c44172316ab9138b (patch)
tree0cc2c9dfa79fb93298be2fea427c8041c07c74b4 /xpp/dahdi_genconf
parent1e9d184f0afc673939e66b3d388ab557e9437470 (diff)
dahdi_genconf: add output type 'modules' (/etc/dahdi/modules)
Also improved documentation. git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@5440 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'xpp/dahdi_genconf')
-rwxr-xr-xxpp/dahdi_genconf65
1 files changed, 56 insertions, 9 deletions
diff --git a/xpp/dahdi_genconf b/xpp/dahdi_genconf
index 8135b98..8702906 100755
--- a/xpp/dahdi_genconf
+++ b/xpp/dahdi_genconf
@@ -12,6 +12,7 @@ use File::Basename;
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 @@ sub map_dahdi_defaults {
my $dahdiconf_file;
+my $dahdimods_file;
my $chan_dahdi_channels_file;
my $users_file;
my $chan_dahdi_conf_file;
@@ -138,6 +140,7 @@ my $unicall_channels_file;
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 @@ TAIL
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 @@ my %DefaultConfigs = (
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 @@ sub set_defaults {
$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 @@ dahdi_genconf [FILES...]
=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