1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
#!/usr/bin/perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::RealBin/../lib";
use Ceni::Backend;
use Getopt::Long;
my $dbg = 0;
my $iface;
my $in = '/etc/network/interfaces';
GetOptions('debug' => \$dbg, 'iface=s' => \$iface, 'input=s' => \$in,);
if (not $in or not $iface) {
print "Usage: Ceni_read_config --iface <iface> [--input <file>]\n";
exit 0;
}
my $source = new Ceni::Backend({ debug => $dbg, file => $in, });
$source->parse_eni or exit 1;
my $config = $source->get_iface_conf($iface);
if ($config) {
for my $k (sort keys %{$config}) {
if ($k eq 'stanza') {
for my $s (sort keys %{ $config->{$k} }) {
print $s . ',' . $config->{$k}->{$s} . "\n";
}
next;
}
elsif ($k =~ /^(pre-|post-)?(up|down)$/) {
for my $s (@{ $config->{$k} }) {
print $k . ',' . $s . "\n";
}
next;
}
print $k . ',' . $config->{$k} . "\n";
}
}
__END__
=head1 NAME
Ceni_read_config - read network interface configuration from input file
=head1 SYNOPSIS
Ceni_read_config --iface <iface> [--input <file>]
=head1 DESCRIPTION
This script reads an input file containing ifupdown configuration data, and
prints the configuration data.
=head1 OPTIONS
=over
=item B<--iface> <iface>
The target network interface with kernel name <iface>.
Exmaples of <iface> are "eth0", "ath0" and "wlan0".
=item B<--input> <file>
Input file containing network interface ifupdown configuration.
If no input file is specified, /etc/network/interfaces is assumed.
=back
=head1 AUTHOR
Kel Modderman, E<lt>kel@otaku42.deE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2007 - 2010 by Kel Modderman
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this package; if not, see <http://www.gnu.org/licenses>
On Debian GNU/Linux systems, the text of the GPL-2 license can be
found in /usr/share/common-licenses/GPL-2.
=cut
|