Last change
on this file since 987 was
861,
checked in by nanardon, 13 years ago
|
- reimport missing files from previous svn
|
-
Property svn:executable set to
*
|
File size:
1.6 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 | |
---|
9 | =head1 NAME |
---|
10 | |
---|
11 | la-sql-attreg - Tools to register attributes in LA SQL base |
---|
12 | |
---|
13 | =head1 SYNOPSIS |
---|
14 | |
---|
15 | la-sql-attreg [options] name comment |
---|
16 | |
---|
17 | =cut |
---|
18 | |
---|
19 | GetOptions( |
---|
20 | 'c|config=s' => \my $config, |
---|
21 | 'b|base=s' => \my $base, |
---|
22 | 'o|object=s' => \my $otype, |
---|
23 | 'comment' => \my $comment, |
---|
24 | ) or pod2usage(); |
---|
25 | |
---|
26 | $otype ||= 'user'; |
---|
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 -o|object object_type |
---|
41 | |
---|
42 | Query will be performed on this object. Default is the 'User' object. |
---|
43 | |
---|
44 | =item --comment |
---|
45 | |
---|
46 | Set a comment to existing attribute instead adding the attribute |
---|
47 | |
---|
48 | =back |
---|
49 | |
---|
50 | =cut |
---|
51 | |
---|
52 | if (!$ARGV[0]) { |
---|
53 | warn "You must specify attribute name, aborting\n"; |
---|
54 | pod2usage(); |
---|
55 | } |
---|
56 | |
---|
57 | my $LA = LATMOS::Accounts->new($config, noacl => 1); |
---|
58 | my $labase = $base ? $LA->base($base) : $LA->default_base; |
---|
59 | $labase && $labase->load or die "Cannot load base"; |
---|
60 | $labase->wexported(1); |
---|
61 | |
---|
62 | if ($comment) { |
---|
63 | if ($labase->set_attribute_comment($otype, @ARGV)) { |
---|
64 | $labase->commit; |
---|
65 | print "Attribute $ARGV[0] commented for object $otype\n"; |
---|
66 | exit(0); |
---|
67 | } else { |
---|
68 | warn "Error commenting attribute $ARGV[0] for object $otype\n"; |
---|
69 | exit(1); |
---|
70 | } |
---|
71 | } else { |
---|
72 | if ($labase->register_attribute($otype, @ARGV)) { |
---|
73 | $labase->commit; |
---|
74 | print "Attribute $ARGV[0] register for object $otype\n"; |
---|
75 | exit(0); |
---|
76 | } else { |
---|
77 | warn "Error registing attribute $ARGV[0] for object $otype\n"; |
---|
78 | exit(1); |
---|
79 | } |
---|
80 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.