Last change
on this file since 493 was
457,
checked in by nanardon, 15 years ago
|
- add options to not load acls, command line tools are superuser command, then skip acls checks
|
-
Property svn:executable set to
*
|
File size:
1.3 KB
|
Rev | Line | |
---|
[440] | 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-query - Tools to query base in LATMOS::Accounts system |
---|
| 12 | |
---|
| 13 | =head1 SYNOPSIS |
---|
| 14 | |
---|
| 15 | la-query [options] [obj_id] |
---|
| 16 | |
---|
| 17 | =cut |
---|
| 18 | |
---|
| 19 | GetOptions( |
---|
| 20 | 'c|config=s' => \my $config, |
---|
| 21 | 'b|base=s' => \my $base, |
---|
| 22 | 'help' => sub { pod2usage(0) }, |
---|
| 23 | ) or pod2usage(); |
---|
| 24 | |
---|
| 25 | $otype ||= 'user'; |
---|
| 26 | |
---|
| 27 | =head1 OPTIONS |
---|
| 28 | |
---|
| 29 | =over 4 |
---|
| 30 | |
---|
| 31 | =item -c|--config configfile |
---|
| 32 | |
---|
| 33 | Use this cofngiuration file instead the default one |
---|
| 34 | |
---|
| 35 | =item -b|--base basename |
---|
| 36 | |
---|
| 37 | Query this specific base instead default. |
---|
| 38 | |
---|
| 39 | =item -o|object object_type |
---|
| 40 | |
---|
| 41 | Query should be performed on this objects. Default is to user 'User' object. |
---|
| 42 | |
---|
| 43 | =item -e|--empty |
---|
| 44 | |
---|
| 45 | Include also unset attributes |
---|
| 46 | |
---|
| 47 | =item --ro |
---|
| 48 | |
---|
| 49 | Include also read-only attributes as comment |
---|
| 50 | |
---|
| 51 | =back |
---|
| 52 | |
---|
| 53 | =cut |
---|
| 54 | |
---|
[457] | 55 | my $LA = LATMOS::Accounts->new($config, noacl => 1); |
---|
[440] | 56 | my $labase = $base ? $LA->base($base) : $LA->default_base; |
---|
| 57 | $labase && $labase->load or die "Cannot load base"; |
---|
| 58 | |
---|
| 59 | if (my $ouid = shift(@ARGV)) { |
---|
| 60 | my $obj = $labase->get_object($otype, $ouid) or do { |
---|
| 61 | die "Object $otype $ouid not found\n"; |
---|
| 62 | }; |
---|
| 63 | $obj->text_dump(*STDOUT, |
---|
| 64 | { |
---|
| 65 | empty_attr => $empty_attr, |
---|
| 66 | only_rw => !$with_ro, |
---|
| 67 | } |
---|
| 68 | ); |
---|
| 69 | } else { |
---|
| 70 | foreach (sort $labase->list_objects($otype)) { |
---|
| 71 | print "$_\n"; |
---|
| 72 | } |
---|
| 73 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.