2017-12-01 06:42:02 +01:00
|
|
|
#!/usr/bin/perl
|
2016-02-06 10:00:54 +01:00
|
|
|
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
2016-02-26 07:41:38 +01:00
|
|
|
use POSIX;
|
2021-07-18 17:51:19 +02:00
|
|
|
use Getopt::Long qw(:config pass_through);
|
2021-08-13 11:10:20 +02:00
|
|
|
use Pod::Usage;
|
2021-07-15 17:38:35 +02:00
|
|
|
|
2021-07-16 12:35:29 +02:00
|
|
|
our $opt_user = '__APACHEUSER__';
|
2021-07-16 12:03:59 +02:00
|
|
|
our $opt_group = '__APACHEGROUP__';
|
2021-07-16 12:35:29 +02:00
|
|
|
GetOptions(
|
|
|
|
"user=s" => \$opt_user,
|
|
|
|
"group=s" => \$opt_group
|
2021-08-13 11:10:20 +02:00
|
|
|
) or pod2usage("Error in command line arguments");
|
2016-02-06 10:00:54 +01:00
|
|
|
|
2016-02-06 13:22:10 +01:00
|
|
|
my $action;
|
|
|
|
|
2016-02-26 07:41:38 +01:00
|
|
|
eval {
|
2021-07-15 17:39:34 +02:00
|
|
|
POSIX::setgid( scalar( getgrnam($opt_group) ) );
|
|
|
|
POSIX::setuid( scalar( getpwnam($opt_user) ) );
|
2016-02-26 07:41:38 +01:00
|
|
|
};
|
|
|
|
|
2016-02-06 13:22:10 +01:00
|
|
|
for ( my $i = 0 ; $i < @ARGV ; $i++ ) {
|
|
|
|
if ( $ARGV[$i] =~ /^-/ ) {
|
|
|
|
$i++;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
$action = $ARGV[$i];
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
$action ||= "usage";
|
2016-02-22 15:52:16 +01:00
|
|
|
|
2021-01-10 17:46:03 +01:00
|
|
|
if ( $action =~
|
2022-08-11 16:46:11 +02:00
|
|
|
/^(?:[gs]et|del|(?:add|del)Key|(?:add|del)PostVars|merge|save|restore|rollback)$/
|
2021-01-10 17:46:03 +01:00
|
|
|
)
|
|
|
|
{
|
2016-02-06 10:00:54 +01:00
|
|
|
eval { require Lemonldap::NG::Manager::Cli; };
|
2017-02-26 09:04:39 +01:00
|
|
|
die "Manager libraries not available, aborting ($@)" if ($@);
|
2016-02-06 10:00:54 +01:00
|
|
|
Lemonldap::NG::Manager::Cli->run(@ARGV);
|
|
|
|
}
|
2020-09-16 16:56:06 +02:00
|
|
|
elsif ( $action =~ /^(?:info|update-cache|test-email)$/ ) {
|
2016-02-06 10:00:54 +01:00
|
|
|
eval { require Lemonldap::NG::Common::Cli; };
|
2016-02-06 13:22:10 +01:00
|
|
|
die "Lemonldap::NG common libraries not available, aborting ($@)" if ($@);
|
2016-02-06 10:00:54 +01:00
|
|
|
Lemonldap::NG::Common::Cli->run(@ARGV);
|
|
|
|
}
|
|
|
|
else {
|
2021-08-13 11:10:20 +02:00
|
|
|
pod2usage(1) if $action eq "help";
|
|
|
|
pod2usage(2) if $action eq "usage";
|
2016-02-06 10:00:54 +01:00
|
|
|
}
|
|
|
|
|
2016-02-06 19:41:26 +01:00
|
|
|
__END__
|
2016-02-06 10:00:54 +01:00
|
|
|
|
2016-02-06 19:41:26 +01:00
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
=encoding utf8
|
|
|
|
|
|
|
|
lemonldap-ng-cli - Command-line manager for Lemonldap::NG web-SSO system.
|
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
|
|
|
lemonldap-ng-cli is a command line interface to interact with Lemonldap::NG
|
|
|
|
configuration. It can be used to read or update configuration variables
|
|
|
|
programmatically, or perform global operations on the configuration.
|
|
|
|
|
2016-02-06 19:41:26 +01:00
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
Usage: lemonldap-ng-cli [options] ACTION [parameters ...]
|
|
|
|
|
|
|
|
Available actions:
|
|
|
|
|
|
|
|
help : print the full documentation
|
|
|
|
info : get currentconfiguration info
|
|
|
|
update-cache : force configuration cache to be updated
|
|
|
|
test-email DESTINATION : send a test email
|
|
|
|
get KEY : get values of parameters
|
|
|
|
set KEY VALUE : set parameter(s) value(s)
|
|
|
|
del KEY : delete parameters
|
|
|
|
addKey KEY SUBKEY VALUE : add or set a subkey in a parameter
|
|
|
|
delKey KEY SUBKEY : delete subkey of a parameter
|
|
|
|
addPostVars HOST URI KEY VALUE : add post vars for form replay
|
|
|
|
delPostVars HOST URI KEY : delete post vars for form replay
|
2022-08-11 16:46:11 +02:00
|
|
|
merge FILE [FILE ...] : merge JSON/YAML files with existing configuration
|
2021-08-13 11:10:20 +02:00
|
|
|
save : export configuration to STDOUT
|
|
|
|
restore - : import configuration from STDIN
|
|
|
|
restore FILE : import configuration from file
|
|
|
|
rollback : restore previous configuration
|
|
|
|
|
|
|
|
Options:
|
|
|
|
|
|
|
|
-yes 0|1 : accept confirmation prompt automatically
|
|
|
|
-log msg : set configuration log message
|
|
|
|
-safe 0|1 : fail in case the requested configuration is invalid
|
|
|
|
-force 0|1 : allow overwrite of existing config number
|
|
|
|
-cfgNum NUM : set new configuration number (requires -force 1)
|
|
|
|
-sep CHAR : separator of hierarchical values (by default: /)
|
|
|
|
-iniFile FILE : path to an alternate lemonldap-ng.ini file
|
|
|
|
|
|
|
|
Additional options:
|
|
|
|
|
|
|
|
--user=USER : change user running the script
|
|
|
|
--group=GROUP : change group running the script
|
|
|
|
|
|
|
|
=head1 EXAMPLES
|
|
|
|
|
2019-05-30 09:48:43 +02:00
|
|
|
Get information about current configuration
|
|
|
|
|
2016-02-06 19:41:26 +01:00
|
|
|
$ lemonldap-ng-cli info
|
|
|
|
|
2019-05-30 09:48:43 +02:00
|
|
|
Update local configuration cache
|
|
|
|
|
2016-02-06 19:41:26 +01:00
|
|
|
$ lemonldap-ng-cli update-cache
|
|
|
|
|
2020-09-16 16:56:06 +02:00
|
|
|
Send a test email
|
|
|
|
|
|
|
|
$ lemonldap-ng-cli test-email dwho@badwolf.org
|
|
|
|
|
2019-05-30 09:48:43 +02:00
|
|
|
Save configuration
|
|
|
|
|
|
|
|
$ lemonldap-ng-cli save >conf.json
|
2020-02-24 11:57:56 +01:00
|
|
|
$ lemonldap-ng-cli -cfgNum 19 save >conf-19.json
|
2019-05-30 09:48:43 +02:00
|
|
|
|
2019-05-30 10:18:41 +02:00
|
|
|
Restore configuration
|
|
|
|
|
|
|
|
$ lemonldap-ng-cli restore conf.json
|
|
|
|
# OR
|
|
|
|
$ lemonldap-ng-cli restore - <conf.json
|
|
|
|
|
2020-02-24 11:58:29 +01:00
|
|
|
Cancel the last configuration change
|
|
|
|
|
|
|
|
$ lemonldap-ng-cli rollback
|
|
|
|
|
2019-05-30 09:48:43 +02:00
|
|
|
Get a configuration parameter value
|
|
|
|
|
2016-02-06 19:41:26 +01:00
|
|
|
$ lemonldap-ng-cli get portal domain cookieName
|
|
|
|
|
2019-05-30 09:48:43 +02:00
|
|
|
Set some values
|
2016-02-06 19:41:26 +01:00
|
|
|
|
2019-05-30 09:48:43 +02:00
|
|
|
$ lemonldap-ng-cli set portal http://auth.e.com/ domain e.com
|
2016-02-06 19:41:26 +01:00
|
|
|
# add or set a key
|
|
|
|
$ lemonldap-ng-cli addKey macro fullname '$givenName." ".$lastName'
|
|
|
|
|
2020-01-29 08:44:51 +01:00
|
|
|
# without changing the version number
|
|
|
|
$ lemonldap-ng-cli -force 1 -cfgNum 1 set portal http://auth.e.com/ domain e.com
|
|
|
|
|
|
|
|
# without asking for confirmation
|
|
|
|
$ lemonldap-ng-cli -yes 1 set portal http://auth.e.com/ domain e.com
|
|
|
|
|
2016-02-06 19:41:26 +01:00
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
=head1 ARGUMENTS
|
2019-05-30 09:48:43 +02:00
|
|
|
|
|
|
|
=over
|
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
=item B<info>
|
|
|
|
|
|
|
|
Print configuration metadata, such as number, author, date and log
|
2019-05-30 09:48:43 +02:00
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
=item B<update-cache>
|
2019-05-30 09:48:43 +02:00
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
Update the local configuration cache, this command only affects the server on which it is run
|
2020-09-16 16:56:06 +02:00
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
=item B<test-email I<DESTINATION>>
|
2019-05-30 09:48:43 +02:00
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
Sends a test email to the specified I<DESTINATION>, this lets you check your SMTP settings
|
2019-05-30 10:18:41 +02:00
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
=item B<get I<KEY> [ I<KEY> ... ]>
|
2019-05-30 09:48:43 +02:00
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
Print the specified I<KEY> from configuration. Multiple keys may be given
|
2019-05-30 09:48:43 +02:00
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
=item B<set I<KEY> I<VALUE> [I<KEY> I<VALUE> ...]>
|
2019-05-30 09:48:43 +02:00
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
Set the specified I<KEY> to the specified I<VALUE>. Multiple key-value pairs may be given.
|
|
|
|
|
|
|
|
The configuration number is increased once all given key-value pairs have been processesed.
|
|
|
|
|
|
|
|
=item B<delete I<KEY> [ I<KEY> ... ]>
|
|
|
|
|
|
|
|
Delete the specified I<KEY> from configuration. Multiple keys can be given.
|
|
|
|
|
|
|
|
The configuration number is increased once all keys have been deleted.
|
|
|
|
|
|
|
|
=item B<addKey I<KEY> I<SUBKEY> I<VALUE> [I<KEY> I<SUBKEY> I<VALUE> ...]>
|
|
|
|
|
|
|
|
This action can be used to set a sub-key inside a composite configuration key
|
|
|
|
(such as globalStorageOptions, locationRules, etc.)
|
|
|
|
|
|
|
|
Multiple key-subkey-value triplets may be given.
|
|
|
|
|
|
|
|
The configuration number is increased once all given triplets have been processesed.
|
|
|
|
|
|
|
|
=item B<delKey I<KEY> I<SUBKEY> [I<KEY> I<SUBKEY> ...]>
|
|
|
|
|
|
|
|
This action can be used to delete a sub-key from a composite configuration key
|
|
|
|
(such as globalStorageOptions, locationRules, etc.)
|
|
|
|
|
|
|
|
Multiple key-subkey pairs may be given.
|
|
|
|
|
|
|
|
The configuration number is increased once all given pairs have been processesed.
|
|
|
|
|
|
|
|
=item B<addPostVars I<HOST> I<URI> I<KEY> I<VALUE>>
|
|
|
|
|
|
|
|
This action lets you add a new POST var in a form replay configuration.
|
|
|
|
|
|
|
|
=item B<delPostVars I<HOST> I<URI> I<KEY>>
|
|
|
|
|
|
|
|
This action lets you delete a new POST var in a form replay configuration.
|
|
|
|
|
2022-08-11 16:46:11 +02:00
|
|
|
=item B<merge I<FILE> [I<FILE> ...]>
|
|
|
|
|
|
|
|
This action iterates through the given JSON or YAML files and merges the
|
|
|
|
existing configuration with the keys contained in those files
|
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
=item B<save>
|
|
|
|
|
|
|
|
Dump the entire LemonLDAP::NG configuration to standard output, in JSON format.
|
|
|
|
|
|
|
|
The resulting dump can be imported into the manager's interface, or restored
|
|
|
|
with the B<restore> command.
|
|
|
|
|
|
|
|
=item B<restore I<FILE>>
|
|
|
|
|
|
|
|
Replace the existing configuration with the content of the provided
|
|
|
|
JSON-formatted I<FILE>. If I<FILE> is the I<-> string, configuration will be
|
|
|
|
read from standard input.
|
|
|
|
|
|
|
|
=item B<rollback>
|
|
|
|
|
|
|
|
This command can be used to cancel the latest configuration change. The
|
|
|
|
previous configuration is fetched from configuration history and saved under a
|
|
|
|
new configuration number.
|
|
|
|
|
|
|
|
This action is meant to be a convenient wrapper around B<save> and B<restore>,
|
|
|
|
and does not handle rolling back to an arbitrary version. Rolling back to an
|
|
|
|
arbitrary version can be done manually with B<save> and B<restore>
|
2019-05-30 09:48:43 +02:00
|
|
|
|
|
|
|
=back
|
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
=head1 OPTIONS
|
2020-01-29 08:44:51 +01:00
|
|
|
|
|
|
|
=over
|
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
=item B<-yes I<0|1>>
|
2020-01-29 08:44:51 +01:00
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
Skip confirmation prompt (default: 0)
|
2020-01-29 08:44:51 +01:00
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
=item B<-log I<MESSAGE>>
|
2020-01-29 08:44:51 +01:00
|
|
|
|
|
|
|
Allows you to set the log message that will be displayed in the manager
|
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
=item B<-safe I<0|1>>
|
2020-01-29 08:44:51 +01:00
|
|
|
|
|
|
|
The configuration change will be aborted if it contains errors (default: 0)
|
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
=item B<-force I<0|1>>
|
2021-04-25 23:21:09 +02:00
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
Allows you to force overwriting an existing configuration number (default: 0)
|
2021-04-25 23:21:09 +02:00
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
=item B<-cfgNum I<NUMBER>>
|
2020-01-29 08:44:51 +01:00
|
|
|
|
|
|
|
Choose a particular configuration number (default: latest)
|
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
=item B<-sep I<CHARACTER>>
|
2021-04-25 23:21:09 +02:00
|
|
|
|
|
|
|
Allows you to define hierarchical separator
|
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
=item B<-iniFile I<FILE>>
|
2021-04-25 23:21:09 +02:00
|
|
|
|
|
|
|
Allows you to set an alternative ini file
|
2020-01-29 08:44:51 +01:00
|
|
|
|
2021-08-13 11:10:20 +02:00
|
|
|
=item B<-u I<USER>, --user=I<USER>>
|
|
|
|
|
|
|
|
Run the script under the I<USER> system user identity
|
|
|
|
|
|
|
|
=item B<-g I<GROUP>, --group=I<GROUP>>
|
|
|
|
|
|
|
|
Run the script under the I<GROUP> system group identity
|
|
|
|
|
2020-01-29 08:44:51 +01:00
|
|
|
=back
|
|
|
|
|
2016-02-06 19:41:26 +01:00
|
|
|
=head1 SEE ALSO
|
|
|
|
|
2019-07-03 15:10:53 +02:00
|
|
|
L<Lemonldap::NG::Manager::Cli>, L<Lemonldap::NG::Common::Cli>
|
2016-02-06 19:41:26 +01:00
|
|
|
L<http://lemonldap-ng.org/>
|
|
|
|
|
|
|
|
=head1 AUTHORS
|
|
|
|
|
|
|
|
=over
|
|
|
|
|
2021-04-25 23:21:09 +02:00
|
|
|
=item Clement Oudot, E<lt>clement@oodo.netE<gt>
|
|
|
|
|
|
|
|
=item Xavier Guimard, E<lt>yadd@debian.orgE<gt>
|
2016-02-06 19:41:26 +01:00
|
|
|
|
2021-04-25 23:21:09 +02:00
|
|
|
=item Maxime Besson, E<lt>maxime.besson@worteks.comE<gt>
|
2016-02-06 19:41:26 +01:00
|
|
|
|
2021-04-25 23:21:09 +02:00
|
|
|
=item Christophe Maudoux, E<lt>chrmdx@gmail.comE<gt>
|
2016-02-06 19:41:26 +01:00
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
=head1 BUG REPORT
|
|
|
|
|
|
|
|
Use OW2 system to report bug or ask for features:
|
2017-11-11 14:06:23 +01:00
|
|
|
L<https://gitlab.ow2.org/lemonldap-ng/lemonldap-ng/issues>
|
2016-02-06 19:41:26 +01:00
|
|
|
|
|
|
|
=head1 DOWNLOAD
|
|
|
|
|
|
|
|
Lemonldap::NG is available at
|
2021-04-25 23:21:09 +02:00
|
|
|
L<https://release.ow2.org/lemonldap/>
|
2016-02-06 19:41:26 +01:00
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE
|
|
|
|
|
|
|
|
=over
|
|
|
|
|
|
|
|
=item Copyright (C) 2016 by Xavier Guimard, E<lt>x.guimard@free.frE<gt>
|
|
|
|
|
|
|
|
=item Copyright (C) 2016 by Clément Oudot, E<lt>clem.oudot@gmail.comE<gt>
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see L<http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
=cut
|