Last change
on this file since 1907 was
1322,
checked in by nanardon, 9 years ago
|
Add la-sql-exchange-hostname tools, fix some doc
|
-
Property svn:executable set to
*
|
File size:
1.2 KB
|
Rev | Line | |
---|
[861] | 1 | #!/usr/bin/perl |
---|
| 2 | |
---|
| 3 | use strict; |
---|
| 4 | use warnings; |
---|
| 5 | use LATMOS::Accounts; |
---|
| 6 | use Getopt::Long; |
---|
| 7 | use Pod::Usage; |
---|
| 8 | |
---|
| 9 | =head1 NAME |
---|
| 10 | |
---|
[1322] | 11 | la-sql-rename-host - rename an network host |
---|
[861] | 12 | |
---|
| 13 | =head1 SYNOPSIS |
---|
| 14 | |
---|
[1322] | 15 | la-sql-rename-host [--no-cname] from to |
---|
[861] | 16 | |
---|
| 17 | Example : la-rename-host foo bar |
---|
| 18 | |
---|
| 19 | =cut |
---|
| 20 | |
---|
| 21 | GetOptions( |
---|
| 22 | 'c|config=s' => \my $config, |
---|
| 23 | 'b|base=s' => \my $base, |
---|
| 24 | 'no-cname' => \my $nocname, |
---|
| 25 | 'help' => sub { pod2usage(0) }, |
---|
| 26 | ) or pod2usage(); |
---|
| 27 | |
---|
| 28 | =head1 OPTIONS |
---|
| 29 | |
---|
| 30 | =over 4 |
---|
| 31 | |
---|
| 32 | =item -c|--config configdir |
---|
| 33 | |
---|
| 34 | Use this configuration directory instead of the default one. |
---|
| 35 | |
---|
| 36 | =item -b|--base basename |
---|
| 37 | |
---|
| 38 | Query this specific base instead of the default one. |
---|
| 39 | |
---|
| 40 | =item --no-cname |
---|
| 41 | |
---|
| 42 | By default the old name is added as CNAME for compatibility, this option don't |
---|
| 43 | add previous name as CNAME. |
---|
| 44 | |
---|
| 45 | =back |
---|
| 46 | |
---|
| 47 | =cut |
---|
| 48 | |
---|
| 49 | my $LA = LATMOS::Accounts->new($config, noacl => 1); |
---|
[1044] | 50 | my $labase = $LA->base($base); |
---|
[861] | 51 | $labase && $labase->load or die "Cannot load base"; |
---|
| 52 | |
---|
| 53 | $labase->unexported(1); |
---|
| 54 | |
---|
| 55 | my ($from, $to) = @ARGV or pod2usage(); |
---|
| 56 | |
---|
| 57 | if ($labase->rename_nethost($from, $to, addcname => (!$nocname))) { |
---|
| 58 | $labase->commit; |
---|
| 59 | print "Host succefully rename from $from to $to\n"; |
---|
| 60 | exit(0); |
---|
| 61 | } else { |
---|
| 62 | warn "Error while renaming $from\n"; |
---|
| 63 | exit(1); |
---|
| 64 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.