#!/usr/bin/perl use warnings; use strict; use POSIX; use Getopt::Long qw(:config pass_through); our $opt_user = '__APACHEUSER__'; our $opt_group = '__APACHEGROUP__'; GetOptions( "user=s" => \$opt_user, "group=s" => \$opt_group ) or die("Error in command line arguments\n"); my $action; eval { POSIX::setgid( scalar( getgrnam($opt_group) ) ); POSIX::setuid( scalar( getpwnam($opt_user) ) ); }; for ( my $i = 0 ; $i < @ARGV ; $i++ ) { if ( $ARGV[$i] =~ /^-/ ) { $i++; next; } $action = $ARGV[$i]; last; } $action ||= "help"; if ( $action =~ /^(?:[gs]et|del|(?:add|del)Key|(?:add|del)PostVars|save|restore|rollback)$/ ) { eval { require Lemonldap::NG::Manager::Cli; }; die "Manager libraries not available, aborting ($@)" if ($@); Lemonldap::NG::Manager::Cli->run(@ARGV); } elsif ( $action =~ /^(?:info|update-cache|test-email)$/ ) { eval { require Lemonldap::NG::Common::Cli; }; die "Lemonldap::NG common libraries not available, aborting ($@)" if ($@); Lemonldap::NG::Common::Cli->run(@ARGV); } else { help(); } sub help { print STDERR qq{Usage: $0 action Available actions: - help : print this - info : get currentconfiguration info - update-cache : force configuration cache to be updated - test-email : send a test email - get : get values of parameters - set : set parameter(s) value(s) - del : delete parameters - addKey : add or set a subkey in a parameter - delKey : delete subkey of a parameter - addPostVars : add post vars for form replay - delPostVars : delete post vars for form replay - save : export configuration to STDOUT - restore - : import configuration from STDIN - restore : import configuration from file - rollback : restore previous configuration Options: - yes <0|1> : accept confirmation prompt automatically - log : 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 : set new configuration number (requires -force 1) - sep : separator of hierarchical values (by default: /) - iniFile : path to an alternate lemonldap-ng.ini file Additional options: - --user= : change user running the script - --group= : change group running the script See Lemonldap::NG::Manager::Cli(3) for more }; } __END__ =head1 NAME =encoding utf8 lemonldap-ng-cli - Command-line manager for Lemonldap::NG web-SSO system. =head1 SYNOPSIS Get information about current configuration $ lemonldap-ng-cli info Update local configuration cache $ lemonldap-ng-cli update-cache Send a test email $ lemonldap-ng-cli test-email dwho@badwolf.org Save configuration $ lemonldap-ng-cli save >conf.json $ lemonldap-ng-cli -cfgNum 19 save >conf-19.json Restore configuration $ lemonldap-ng-cli restore conf.json # OR $ lemonldap-ng-cli restore - and L =head2 Available commands =over =item info =item update-cache =item test-email =item save =item restore =item get =item set =item addKey =item delKey =back =head2 Available options =over =item -yes Confirm modification automatically (default: 0) =item -log Allows you to set the log message that will be displayed in the manager =item -safe The configuration change will be aborted if it contains errors (default: 0) =item -force Allows you to force overwriting an existing configuration (default: 0) =item -cfgNum Choose a particular configuration number (default: latest) =item -sep Allows you to define hierarchical separator =item -iniFile Allows you to set an alternative ini file =back =head1 SEE ALSO L, L L =head1 AUTHORS =over =item Clement Oudot, Eclement@oodo.netE =item Xavier Guimard, Eyadd@debian.orgE =item Maxime Besson, Emaxime.besson@worteks.comE =item Christophe Maudoux, Echrmdx@gmail.comE =back =head1 BUG REPORT Use OW2 system to report bug or ask for features: L =head1 DOWNLOAD Lemonldap::NG is available at L =head1 COPYRIGHT AND LICENSE =over =item Copyright (C) 2016 by Xavier Guimard, Ex.guimard@free.frE =item Copyright (C) 2016 by Clément Oudot, Eclem.oudot@gmail.comE =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. =cut