Last change
on this file since 1834 was
891,
checked in by nanardon, 12 years ago
|
|
-
Property svn:executable set to
*
-
Property svn:keywords set to
Id
|
File size:
1.3 KB
|
Line | |
---|
1 | #!/usr/bin/perl |
---|
2 | |
---|
3 | use strict; |
---|
4 | use warnings; |
---|
5 | use LATMOS::Accounts; |
---|
6 | use Getopt::Long; |
---|
7 | use Pod::Usage; |
---|
8 | use Term::ReadKey; |
---|
9 | |
---|
10 | =head1 NAME |
---|
11 | |
---|
12 | la-rename - rename object in database |
---|
13 | |
---|
14 | =head1 SYNOPSIS |
---|
15 | |
---|
16 | la-rename [options] oid newoid |
---|
17 | |
---|
18 | =head1 OPTIONS |
---|
19 | |
---|
20 | =over 4 |
---|
21 | |
---|
22 | =item -c|--config configdir |
---|
23 | |
---|
24 | Use this configuration directory instead of the default one. |
---|
25 | |
---|
26 | =item -b|--base basename |
---|
27 | |
---|
28 | Query this specific base instead of the default one. |
---|
29 | |
---|
30 | =item -s|--sync syncname |
---|
31 | |
---|
32 | Use this synchronisation |
---|
33 | |
---|
34 | =item -o|--otype otype |
---|
35 | |
---|
36 | Modify object having type 'otype', default is user |
---|
37 | |
---|
38 | =back |
---|
39 | |
---|
40 | =cut |
---|
41 | |
---|
42 | GetOptions( |
---|
43 | 'c|config=s' => \my $config, |
---|
44 | 'b|base=s' => \my $base, |
---|
45 | 't|test' => \my $test, |
---|
46 | 's|sync=s' => \my $sync, |
---|
47 | 'o|otype=s' => \my $otype, |
---|
48 | 'help' => sub { pod2usage(0) }, |
---|
49 | ) or pod2usage(); |
---|
50 | |
---|
51 | if (@ARGV != 2) { pod2usage(); } |
---|
52 | |
---|
53 | $otype ||= 'user'; |
---|
54 | |
---|
55 | my $LA = LATMOS::Accounts->new($config, noacl => 1); |
---|
56 | my $labase = $base ? $LA->base($base) : $LA->sync_access($sync); |
---|
57 | $labase && $labase->load or die "Cannot load base\n"; |
---|
58 | |
---|
59 | $labase->wexported(1); |
---|
60 | |
---|
61 | my $obj = $labase->get_object($otype, $ARGV[0]) or do { |
---|
62 | die "Object $otype $ARGV[0] not found\n"; |
---|
63 | }; |
---|
64 | |
---|
65 | if (!$labase->rename_object($otype, @ARGV)) { |
---|
66 | die "Error while renaming $otype $ARGV[0] to $ARGV[1]\n"; |
---|
67 | } |
---|
68 | |
---|
69 | $labase->commit; |
---|
Note: See
TracBrowser
for help on using the repository browser.