source: trunk/LATMOS-Accounts/bin/la-sql-rename-host @ 1806

Last change on this file since 1806 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
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use LATMOS::Accounts;
6use Getopt::Long;
7use Pod::Usage;
8
9=head1 NAME
10
11    la-sql-rename-host - rename an network host
12
13=head1 SYNOPSIS
14
15    la-sql-rename-host [--no-cname] from to
16
17Example : la-rename-host foo bar
18
19=cut
20
21GetOptions(
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
34Use this configuration directory instead of the default one.
35
36=item -b|--base basename
37
38Query this specific base instead of the default one.
39
40=item --no-cname
41
42By default the old name is added as CNAME for compatibility, this option don't
43add previous name as CNAME.
44
45=back
46
47=cut
48
49my $LA = LATMOS::Accounts->new($config, noacl => 1);
50my $labase = $LA->base($base);
51$labase && $labase->load or die "Cannot load base";
52
53$labase->unexported(1);
54
55my ($from, $to) = @ARGV or pod2usage();
56
57if ($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.