2013-03-07 18:37:22 +01:00
|
|
|
package Lemonldap::NG::Manager::Cli;
|
|
|
|
|
|
|
|
# Required packages
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Lemonldap::NG::Common::Conf;
|
2014-02-19 18:04:24 +01:00
|
|
|
use Lemonldap::NG::Common::Conf::SubAttributes;
|
2014-01-23 14:32:46 +01:00
|
|
|
use POSIX qw(strftime);
|
2013-03-07 18:37:22 +01:00
|
|
|
|
|
|
|
# Constants
|
|
|
|
|
2014-02-19 18:04:24 +01:00
|
|
|
our $VERSION = "1.4.0";
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-03-10 15:39:41 +01:00
|
|
|
my $ERRORS = {
|
|
|
|
TOO_FEW_ARGUMENTS => "Too few arguments",
|
|
|
|
UNKNOWN_ACTION => "Unknown action",
|
|
|
|
CONFIG_WRITE_ERROR => "Error while writting the configuration",
|
2014-01-17 23:14:30 +01:00
|
|
|
CONFIG_READ_ERROR => "Error while reading the configuration",
|
2013-03-07 18:37:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
## @cmethod Lemonldap::NG::Manager::Cli new ()
|
|
|
|
# Create a new Lemonldap::NG::Manager::Cli object
|
|
|
|
#
|
|
|
|
# @return New Lemonldap::NG::Manager::Cli object
|
2013-03-10 15:39:41 +01:00
|
|
|
sub new {
|
|
|
|
my ($class) = @_;
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2014-02-19 18:04:24 +01:00
|
|
|
my $self = {
|
|
|
|
"confAccess" => Lemonldap::NG::Common::Conf->new(),
|
|
|
|
"subAttributes" => Lemonldap::NG::Common::Conf::SubAttributes->new(),
|
|
|
|
};
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
$self->{conf} = $self->{confAccess}->getConf();
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
bless( $self, $class );
|
|
|
|
return $self;
|
2013-03-07 18:37:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
## @method int saveConf ()
|
|
|
|
# Save LemonLDAP::NG configuration
|
|
|
|
#
|
2014-01-23 15:05:18 +01:00
|
|
|
# @return Configuration identifier
|
2013-03-10 15:39:41 +01:00
|
|
|
sub saveConf {
|
|
|
|
my ($self) = @_;
|
2014-01-23 14:32:46 +01:00
|
|
|
|
|
|
|
$self->{conf}->{cfgAuthor} = "LemonLDAP::NG CLI";
|
|
|
|
$self->{conf}->{cfgAuthorIP} = "127.0.0.1";
|
|
|
|
$self->{conf}->{cfgDate} = time();
|
|
|
|
|
2013-03-10 15:39:41 +01:00
|
|
|
my $ret = $self->{confAccess}->saveConf( $self->{conf} );
|
|
|
|
return $ret;
|
2013-03-07 18:37:22 +01:00
|
|
|
}
|
|
|
|
|
2014-01-23 15:05:18 +01:00
|
|
|
## @method int increment ()
|
|
|
|
# Force increment of configuration number
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub increment {
|
|
|
|
my ($self) = @_;
|
|
|
|
|
2014-01-23 16:00:40 +01:00
|
|
|
# Update cache to save modified data
|
|
|
|
$self->updateCache();
|
|
|
|
|
2014-01-23 15:05:18 +01:00
|
|
|
$self->{confAccess}->{cfgNumFixed} = 0;
|
|
|
|
$self->{confModified} = 1;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-23 16:00:40 +01:00
|
|
|
## @method updateCache()
|
|
|
|
# Update configuration cache
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub updateCache {
|
|
|
|
my ($self) = @_;
|
|
|
|
|
|
|
|
# Get configuration from DB (update cache)
|
|
|
|
my $cfgNum = $self->{conf}->{cfgNum};
|
|
|
|
$self->{conf} = $self->{confAccess}->getDBConf( { cfgNum => $cfgNum } );
|
|
|
|
|
|
|
|
print "Cache updated with configuration number $cfgNum\n";
|
|
|
|
}
|
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
## @method string determineMethod ()
|
2013-11-26 10:19:28 +01:00
|
|
|
# Determine the method from the arguments
|
2013-03-07 18:37:22 +01:00
|
|
|
#
|
2013-11-26 08:54:10 +01:00
|
|
|
# @return method name
|
|
|
|
sub determineMethod {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $opt ) = @_;
|
2013-11-26 08:54:10 +01:00
|
|
|
$opt =~ s/-(\w+)/ucfirst($1)/ge;
|
|
|
|
return $opt;
|
|
|
|
}
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
## @method void setError (string str)
|
|
|
|
# Set error message
|
|
|
|
#
|
|
|
|
# @param str Text of the error
|
|
|
|
sub setError {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $msg ) = @_;
|
2013-11-26 08:54:10 +01:00
|
|
|
$self->{errormsg} = $msg;
|
|
|
|
}
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
## @method string getError ()
|
|
|
|
# Get error message
|
|
|
|
#
|
|
|
|
# @return Text of the error
|
|
|
|
sub getError {
|
|
|
|
my ($self) = @_;
|
|
|
|
return $self->{errormsg};
|
|
|
|
}
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
## @method int run (string method, array args)
|
|
|
|
# Run the requested method with @args
|
|
|
|
#
|
|
|
|
# @return result code of the method
|
|
|
|
sub run {
|
2013-11-26 10:19:28 +01:00
|
|
|
my $self = shift;
|
2013-11-26 08:54:10 +01:00
|
|
|
my $method = shift;
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
my @args;
|
2013-11-26 10:19:28 +01:00
|
|
|
@args = @_ if ( @_ >= 1 );
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-11-26 10:19:28 +01:00
|
|
|
# perl black magic :)
|
|
|
|
return ( @args >= 1 ) ? $self->$method(@args) : $self->$method();
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
## @method void set ( string variable, string value )
|
|
|
|
# Set the requested variable to the given value
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub set {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $var, $val ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ( $var and $val ) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
$self->{conf}->{$var} = $val;
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->{confModified} = 1;
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
## @method void unset (string variable)
|
|
|
|
# Unset the requested variable
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub unset {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $var ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ($var) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if ( not defined( $self->{conf}->{$var} ) ) {
|
|
|
|
$self->setError( "$var: "
|
2013-11-26 10:19:28 +01:00
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
2014-01-23 16:00:40 +01:00
|
|
|
. ": There is no variable named $var" );
|
2013-11-26 08:54:10 +01:00
|
|
|
return 0;
|
2013-03-10 15:39:41 +01:00
|
|
|
}
|
2014-01-17 23:14:30 +01:00
|
|
|
delete $self->{conf}->{$var};
|
|
|
|
$self->{confModified} = 1;
|
2013-03-10 15:39:41 +01:00
|
|
|
}
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2014-01-17 23:14:30 +01:00
|
|
|
## @method void get (string variable)
|
2013-11-26 08:54:10 +01:00
|
|
|
# Get the value of the requested variable
|
2013-03-10 15:39:41 +01:00
|
|
|
#
|
2013-11-26 08:54:10 +01:00
|
|
|
# @return nothing
|
|
|
|
sub get {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $var ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ($var) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if ( not defined( $self->{conf}->{$var} ) ) {
|
|
|
|
$self->setError( "$var: "
|
|
|
|
. $ERRORS->{CONFIG_READ_ERROR}
|
2014-01-23 16:00:40 +01:00
|
|
|
. ": There is no variable named $var" );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ref( $self->{conf}->{$var} ) ) {
|
|
|
|
$self->setError("$var is not a scalar parameter. Try getHash $var");
|
2013-03-10 15:39:41 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2014-01-23 16:00:40 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
print "$var = " . $self->{conf}->{$var} . "\n";
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2014-01-23 16:00:40 +01:00
|
|
|
## @method void setHash ( string variable, string key, string value )
|
|
|
|
# Set for the requested variable the key/value pair
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub setHash {
|
|
|
|
my ( $self, $var, $key, $val ) = @_;
|
|
|
|
unless ( $var and $key and $val ) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
$self->{conf}->{$var}->{$key} = $val;
|
|
|
|
$self->{confModified} = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
## @method void unsetHash (string variable, string key)
|
|
|
|
# Unset the key for the requested variable
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub unsetHash {
|
|
|
|
my ( $self, $var, $key ) = @_;
|
|
|
|
unless ( $var and $key ) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if ( not defined( $self->{conf}->{$var} ) ) {
|
|
|
|
$self->setError( "$var: "
|
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
|
|
|
. ": There is no variable named $var" );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if ( not defined( $self->{conf}->{$var}->{$key} ) ) {
|
|
|
|
$self->setError( "$var: "
|
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
|
|
|
. ": There is no key $key for variable $var" );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
delete $self->{conf}->{$var}->{$key};
|
|
|
|
$self->{confModified} = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
## @method void getHash (string variable)
|
|
|
|
# Get all key/value pair of the requested variable
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub getHash {
|
|
|
|
my ( $self, $var ) = @_;
|
|
|
|
unless ($var) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if ( not defined( $self->{conf}->{$var} ) ) {
|
|
|
|
$self->setError( "$var: "
|
|
|
|
. $ERRORS->{CONFIG_READ_ERROR}
|
|
|
|
. ": There is no variable named $var" );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
unless ( ref( $self->{conf}->{$var} ) eq "HASH" ) {
|
|
|
|
$self->setError("$var is not a Hash parameter. Try get $var.");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
use Data::Dumper;
|
|
|
|
print Dumper( $self->{conf}->{$var} ) . "\n";
|
|
|
|
}
|
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
## @method void setMacro (string macro, string value)
|
|
|
|
# Set the requested macro to the given value
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub setMacro {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $macro, $value ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ( $macro and $value ) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
$self->{conf}->{macros}->{$macro} = $value;
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->{confModified} = 1;
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2014-01-17 23:14:30 +01:00
|
|
|
## @method void unsetMacro (string macro)
|
2013-11-26 08:54:10 +01:00
|
|
|
# Unset the requested macro
|
|
|
|
#
|
|
|
|
# return nothing
|
|
|
|
sub unsetMacro {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $macro ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ($macro) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
if ( not defined( $self->{conf}->{macros}->{$macro} ) ) {
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->setError( "$macro: "
|
2013-11-26 10:19:28 +01:00
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
|
|
|
. ": There is no macro named $macro" );
|
2013-11-26 08:54:10 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
delete $self->{conf}->{macros}->{$macro};
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->{confModified} = 1;
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
## @method void getMacro (string macro)
|
|
|
|
# Get the value of the requested macro
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub getMacro {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $macro ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ($macro) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
if ( not defined( $self->{conf}->{macros}->{$macro} ) ) {
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->setError( "$macro: "
|
2013-11-26 10:19:28 +01:00
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
|
|
|
. ": There is no macro named $macro" );
|
2013-11-26 08:54:10 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
print "$macro = " . $self->{conf}->{macros}->{$macro} . "\n";
|
|
|
|
}
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2014-01-17 23:14:30 +01:00
|
|
|
## @method void appsSetCat ( int id, string name )
|
2013-11-26 10:19:28 +01:00
|
|
|
# Set the category name by its id
|
2013-11-26 08:54:10 +01:00
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub appsSetCat {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $id, $name ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ( $id and $name ) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
if ( defined( $self->{conf}->{applicationList}->{$id} ) ) {
|
2013-11-26 10:19:28 +01:00
|
|
|
$self->{conf}->{applicationList}->{$id}->{catname} = $name;
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$self->{conf}->{applicationList}->{$id} = {
|
2013-11-26 10:19:28 +01:00
|
|
|
type => "category",
|
|
|
|
name => $name
|
2013-11-26 08:54:10 +01:00
|
|
|
};
|
|
|
|
}
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->{confModified} = 1;
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
## @method void appsGetCat ( int id )
|
|
|
|
# Get a category name by its id
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub appsGetCat {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $id ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ($id) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
if ( not defined( $self->{conf}->{applicationList}->{$id} ) ) {
|
|
|
|
$self->setError("$_: There is no category $id");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
print "$id : " . $self->{conf}->{applicationList}->{$id}->{catname} . "\n";
|
|
|
|
}
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
## @method void appsAdd (int appId, int catId )
|
|
|
|
# Add a new application to a category
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub appsAdd {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $appId, $catId ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ( $appId and $catId ) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
if ( not defined( $self->{conf}->{applicationList}->{$catId} ) ) {
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->setError( "$catId"
|
2013-11-26 10:19:28 +01:00
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
|
|
|
. ": Category $catId doesn't exist" );
|
2013-11-26 08:54:10 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if ( defined( $self->{conf}->{applicationList}->{$catId}->{$appId} ) ) {
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->setError( "$catId"
|
2013-11-26 10:19:28 +01:00
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
|
|
|
. ": Application $appId exists" );
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
|
|
|
$self->{conf}->{applicationList}->{$catId}->{$appId} = {
|
|
|
|
type => "application",
|
|
|
|
options => {
|
|
|
|
logo => "demo.png",
|
|
|
|
name => $appId,
|
|
|
|
description => $appId,
|
|
|
|
display => "auto",
|
|
|
|
uri => "http://test1.example.com"
|
|
|
|
}
|
|
|
|
};
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->{confModified} = 1;
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
## @cmethod void appsSetUri ( string id, string uri )
|
|
|
|
# Set given application's uri
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub appsSetUri {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $id, $uri ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ( $id and $uri ) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
my $found = 0;
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-11-26 10:19:28 +01:00
|
|
|
while ( my ( $catId, $appList ) = each %{ $self->{conf}->{applicationList} }
|
|
|
|
and $found != 1 )
|
|
|
|
{
|
2013-11-26 08:54:10 +01:00
|
|
|
while ( my ( $_appid, $app ) = each %{$appList} and $found != 1 ) {
|
|
|
|
if ( $id eq $_appid ) {
|
|
|
|
$app->{options}->{uri} = $uri;
|
2014-01-17 23:14:30 +01:00
|
|
|
$found = 1;
|
|
|
|
$self->{confModified} = 1;
|
2013-03-10 15:39:41 +01:00
|
|
|
}
|
|
|
|
}
|
2013-11-26 10:19:28 +01:00
|
|
|
}
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
if ( $found == 0 ) {
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->setError( "$id: "
|
2013-11-26 10:19:28 +01:00
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
|
|
|
. ": Application $id not found" );
|
2013-11-26 08:54:10 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2014-01-17 23:14:30 +01:00
|
|
|
## @method void appsSetName ( string id, string name )
|
2013-11-26 08:54:10 +01:00
|
|
|
# Set the name of the given application
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub appsSetName {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $id, $name ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ( $id and $name ) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
my $found = 0;
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 10:19:28 +01:00
|
|
|
while ( my ( $catId, $appList ) = each %{ $self->{conf}->{applicationList} }
|
|
|
|
and $found != 1 )
|
|
|
|
{
|
2013-11-26 08:54:10 +01:00
|
|
|
while ( my ( $_appid, $app ) = each %{$appList} and $found != 1 ) {
|
|
|
|
if ( $id eq $_appid ) {
|
|
|
|
$app->{options}->{name} = $name;
|
2014-01-17 23:14:30 +01:00
|
|
|
$found = 1;
|
|
|
|
$self->{confModified} = 1;
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2014-02-19 17:32:29 +01:00
|
|
|
if ( $found == 0 ) {
|
|
|
|
$self->setError( "$id: "
|
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
|
|
|
. ": Application $id not found" );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
## @method void appsSetDesc ( string id, string desc )
|
|
|
|
# Set the description of the given application
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub appsSetDesc {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $id, $desc ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ( $id and $desc ) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
my $found = 0;
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 10:19:28 +01:00
|
|
|
while ( my ( $catId, $appList ) = each %{ $self->{conf}->{applicationList} }
|
|
|
|
and $found != 1 )
|
|
|
|
{
|
2013-11-26 08:54:10 +01:00
|
|
|
while ( my ( $_appid, $app ) = each %{$appList} and $found != 1 ) {
|
|
|
|
if ( $id eq $_appid ) {
|
|
|
|
$app->{options}->{description} = $desc;
|
2014-01-17 23:14:30 +01:00
|
|
|
$found = 1;
|
|
|
|
$self->{confModified} = 1;
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2014-02-19 17:32:29 +01:00
|
|
|
if ( $found == 0 ) {
|
|
|
|
$self->setError( "$id: "
|
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
|
|
|
. ": Application $id not found" );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
## @method void appsSetLogo ( string id, string logo )
|
|
|
|
# Set the logo of the given application
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub appsSetLogo {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $id, $logo ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ( $id and $logo ) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
my $found = 0;
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 10:19:28 +01:00
|
|
|
while ( my ( $catId, $appList ) = each %{ $self->{conf}->{applicationList} }
|
|
|
|
and $found != 1 )
|
|
|
|
{
|
2013-11-26 08:54:10 +01:00
|
|
|
while ( my ( $_appid, $app ) = each %{$appList} and $found != 1 ) {
|
|
|
|
if ( $id eq $_appid ) {
|
|
|
|
$app->{options}->{logo} = $logo;
|
2014-01-17 23:14:30 +01:00
|
|
|
$found = 1;
|
|
|
|
$self->{confModified} = 1;
|
2013-03-10 15:39:41 +01:00
|
|
|
}
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2014-02-19 17:32:29 +01:00
|
|
|
if ( $found == 0 ) {
|
|
|
|
$self->setError( "$id: "
|
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
|
|
|
. ": Application $id not found" );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
## @method void appsSetDisplay ( string id, string display )
|
|
|
|
# Set display setting of the given application
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub appsSetDisplay {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $id, $display ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ( $id and $display ) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
my $found = 0;
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 10:19:28 +01:00
|
|
|
while ( my ( $catId, $appList ) = each %{ $self->{conf}->{applicationList} }
|
|
|
|
and $found != 1 )
|
|
|
|
{
|
2013-11-26 08:54:10 +01:00
|
|
|
while ( my ( $_appid, $app ) = each %{$appList} and $found != 1 ) {
|
|
|
|
if ( $id eq $_appid ) {
|
|
|
|
$app->{options}->{display} = $display;
|
2014-01-17 23:14:30 +01:00
|
|
|
$found = 1;
|
|
|
|
$self->{confModified} = 1;
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2014-02-19 17:32:29 +01:00
|
|
|
|
|
|
|
if ( $found == 0 ) {
|
|
|
|
$self->setError( "$id: "
|
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
|
|
|
. ": Application $id not found" );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2014-01-17 23:14:30 +01:00
|
|
|
## @method void appsGet ( string id )
|
2013-11-26 08:54:10 +01:00
|
|
|
# Show all the given application's settings
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub appsGet {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $id ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ($id) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
my $found = 0;
|
2013-11-26 10:19:28 +01:00
|
|
|
|
|
|
|
while ( my ( $catid, $applist ) = each %{ $self->{conf}->{applicationList} }
|
|
|
|
and $found != 1 )
|
|
|
|
{
|
|
|
|
while ( my ( $_appid, $app ) = each %{$applist} and $found != 1 ) {
|
|
|
|
if ( $id eq $_appid ) {
|
|
|
|
print "Category $catid: "
|
|
|
|
. $self->{conf}->{applicationList}->{$catid}->{catname}
|
|
|
|
. "\n";
|
2013-11-26 08:54:10 +01:00
|
|
|
print "Application $id: " . $app->{options}->{name} . "\n";
|
|
|
|
print "- Description: " . $app->{options}->{description} . "\n";
|
|
|
|
print "- URI: " . $app->{options}->{uri} . "\n";
|
|
|
|
print "- Logo: " . $app->{options}->{logo} . "\n";
|
|
|
|
print "- Display: " . $app->{options}->{display} . "\n";
|
|
|
|
$found = 1;
|
2013-03-10 15:39:41 +01:00
|
|
|
}
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
if ( $found == 0 ) {
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->setError("Application $id not found");
|
2013-11-26 08:54:10 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2014-01-17 23:14:30 +01:00
|
|
|
## @method void appsRm ( string id )
|
2013-11-26 08:54:10 +01:00
|
|
|
# Delete the given application from the configuration
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub appsRm {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $id ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ($id) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
my $found = 0;
|
2013-11-26 10:19:28 +01:00
|
|
|
|
|
|
|
while ( my ( $catid, $applist ) = each %{ $self->{conf}->{applicationList} }
|
|
|
|
and $found != 1 )
|
|
|
|
{
|
2013-11-26 08:54:10 +01:00
|
|
|
while ( my ( $_appid, $app ) = each %{$applist} and $found != 1 ) {
|
2013-11-26 10:19:28 +01:00
|
|
|
if ( $id eq $_appid ) {
|
2013-11-26 08:54:10 +01:00
|
|
|
delete $applist->{$id};
|
|
|
|
$found = 1;
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->{confModified} = 1;
|
2013-03-10 15:39:41 +01:00
|
|
|
}
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2014-01-17 23:14:30 +01:00
|
|
|
if ( $found == 0 ) {
|
|
|
|
$self->setError("Application $id not found");
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
## @method void rulesSet ( string uri, string expr, string rule )
|
2014-01-17 23:14:30 +01:00
|
|
|
# Set a rule for the given vhost
|
2013-11-26 08:54:10 +01:00
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub rulesSet {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $uri, $expr, $rule ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ( $uri and $expr and $rule ) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
if ( not defined( $self->{conf}->{locationRules}->{$uri} ) ) {
|
|
|
|
$self->{conf}->{locationRules}->{$uri} = {};
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
$self->{conf}->{locationRules}->{$uri}->{$expr} = $rule;
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->{confModified} = 1;
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2014-01-17 23:14:30 +01:00
|
|
|
## @method void rulesUnset ( string uri, string expr)
|
2013-11-26 08:54:10 +01:00
|
|
|
# Unset a rule for the given vhost
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub rulesUnset {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $uri, $expr ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ( $uri and $expr ) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
if ( not defined( $self->{conf}->{locationRules}->{$uri} ) ) {
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->setError( "$uri: "
|
2013-11-26 10:19:28 +01:00
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
|
|
|
. ": There is rule $expr for virtual host $uri" );
|
2013-11-26 08:54:10 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
delete $self->{conf}->{locationRules}->{$uri}->{$expr};
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->{confModified} = 1;
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2014-01-17 23:14:30 +01:00
|
|
|
## @method void rulesGet ( string uri )
|
2013-11-26 08:54:10 +01:00
|
|
|
# Get the rules of the given vhost
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub rulesGet {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $uri ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ($uri) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
if ( not defined( $self->{conf}->{locationRules}->{$uri} ) ) {
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->setError("There is no virtual host $uri");
|
2013-11-26 08:54:10 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
print "Virtual Host : $uri\n";
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 10:19:28 +01:00
|
|
|
while ( my ( $expr, $rule ) =
|
|
|
|
each %{ $self->{conf}->{locationRules}->{$uri} } )
|
|
|
|
{
|
2013-11-26 08:54:10 +01:00
|
|
|
print "- $expr => $rule\n";
|
|
|
|
}
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
## @method void exportVar ( string key, string val )
|
|
|
|
# export a variable
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub exportVar {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $key, $val ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ( $key and $val ) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
$self->{conf}->{exportedVars}->{$key} = $val;
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->{confModified} = 1;
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2014-01-17 23:14:30 +01:00
|
|
|
## @method void unexportVar ( string key )
|
2013-11-26 08:54:10 +01:00
|
|
|
# unexport a variable
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub unexportVar {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $key ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ($key) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
if ( not defined( $self->{conf}->{exportedVars}->{$key} ) ) {
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->setError("There is no exported variables named $key");
|
2013-11-26 08:54:10 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
delete $self->{conf}->{exportedVars}->{$key};
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->{confModified} = 1;
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2014-01-17 23:14:30 +01:00
|
|
|
## @method void getExportedVars ()
|
2013-11-26 08:54:10 +01:00
|
|
|
# print the exported variables of the configuration
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub getExportedVars {
|
|
|
|
my $self = shift;
|
|
|
|
while ( my ( $key, $val ) = each %{ $self->{conf}->{exportedVars} } ) {
|
|
|
|
print "$key = $val\n";
|
|
|
|
}
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2014-01-17 23:14:30 +01:00
|
|
|
## @method void exportHeader (string $vhost, string $header, string $expr )
|
2013-11-26 08:54:10 +01:00
|
|
|
# Export a header for the given vhost
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub exportHeader {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $vhost, $header, $expr ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ( $vhost and $header and $expr ) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
if ( not defined( $self->{conf}->{exportedHeaders}->{$vhost} ) ) {
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->setError( "$vhost: "
|
2013-11-26 10:19:28 +01:00
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
|
|
|
. ": There is no virtual host $vhost\n" );
|
2013-11-26 08:54:10 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
$self->{conf}->{exportedHeaders}->{$vhost}->{$header} = $expr;
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->{confModified} = 1;
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2014-01-17 23:14:30 +01:00
|
|
|
## @method void unexportHeader ( string $vhost, string $header )
|
2013-11-26 08:54:10 +01:00
|
|
|
# Unexport the given header
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub unexportHeader {
|
2014-01-17 23:14:30 +01:00
|
|
|
my ( $self, $vhost, $header ) = @_;
|
|
|
|
unless ( $vhost and $header ) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
if ( not defined( $self->{conf}->{exportedHeaders}->{$vhost} ) ) {
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->setError( "$vhost: "
|
2013-11-26 10:19:28 +01:00
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
|
|
|
. ": There is no virtual host $vhost\n" );
|
2013-11-26 08:54:10 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 10:19:28 +01:00
|
|
|
if ( not defined( $self->{conf}->{exportedHeaders}->{$vhost}->{$header} ) )
|
|
|
|
{
|
|
|
|
$self->setError( "$_: "
|
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
|
|
|
. ": There is no header named $header exported for virtual host $vhost\n"
|
|
|
|
);
|
2013-11-26 08:54:10 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
delete $self->{conf}->{exportedHeaders}->{$vhost}->{$header};
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->{confModified} = 1;
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2014-01-17 23:14:30 +01:00
|
|
|
## @method void getExportedHeaders ( string vhost )
|
2013-11-26 08:54:10 +01:00
|
|
|
# Give the exported headers for the given vhost
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub getExportedHeaders {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $vhost ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ($vhost) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
if ( not defined( $self->{conf}->{exportedHeaders}->{$vhost} ) ) {
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->setError( "$vhost: "
|
2013-11-26 10:19:28 +01:00
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
|
|
|
. ": There is no virtual host $vhost\n" );
|
2013-11-26 08:54:10 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 10:19:28 +01:00
|
|
|
while ( my ( $header, $expr ) =
|
|
|
|
each %{ $self->{conf}->{exportedHeaders}->{$vhost} } )
|
|
|
|
{
|
2013-11-26 08:54:10 +01:00
|
|
|
print "$header : $expr\n";
|
|
|
|
}
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
## @method void vhostAdd ( string vhost )
|
2013-11-26 10:19:28 +01:00
|
|
|
# Add a new vhost
|
2013-11-26 08:54:10 +01:00
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub vhostAdd {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $vhost ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ($vhost) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 10:19:28 +01:00
|
|
|
|
|
|
|
if ( defined( $self->{conf}->{vhostOptions}->{$vhost} )
|
|
|
|
or defined( $self->{conf}->{locationRules}->{$vhost} )
|
|
|
|
or defined( $self->{conf}->{exportedHeaders}->{$vhost} ) )
|
|
|
|
{
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->setError( "$vhost: "
|
2013-11-26 10:19:28 +01:00
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
|
|
|
. ": Virtual host $vhost already exist" );
|
2013-11-26 08:54:10 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2014-02-19 18:04:24 +01:00
|
|
|
$self->{conf}->{vhostOptions}->{$vhost} =
|
|
|
|
$self->{subAttributes}->vhostOptions;
|
|
|
|
$self->{conf}->{locationRules}->{$vhost} =
|
|
|
|
$self->{subAttributes}->locationRules;
|
|
|
|
$self->{conf}->{exportedHeaders}->{$vhost} =
|
|
|
|
$self->{subAttributes}->exportedHeaders;
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2014-02-19 18:04:24 +01:00
|
|
|
$self->{confModified} = 1;
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
## @method void vhostDel ( string vhost )
|
2013-11-26 10:19:28 +01:00
|
|
|
# Drop a vhost
|
2013-11-26 08:54:10 +01:00
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub vhostDel {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $vhost ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ($vhost) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
my $error = "No virtual host in: ";
|
|
|
|
my $nerror = 0;
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
if ( not defined( $self->{conf}->{vhostOptions}->{$vhost} ) ) {
|
|
|
|
$nerror++;
|
|
|
|
$error .= "vhostOptions ";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
delete $self->{conf}->{vhostOptions}->{$vhost};
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
if ( not defined( $self->{conf}->{locationRules}->{$vhost} ) ) {
|
|
|
|
$nerror++;
|
|
|
|
$error .= "locationRules ";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
delete $self->{conf}->{locationRules}->{$vhost};
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
if ( not defined( $self->{conf}->{exportedHeaders}->{$vhost} ) ) {
|
|
|
|
$nerror++;
|
|
|
|
$error .= "exportedHeaders ";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
delete $self->{conf}->{exportedHeaders}->{$vhost};
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
if ( $nerror == 3 ) {
|
2014-01-17 23:14:30 +01:00
|
|
|
$error .= ". aborting...";
|
|
|
|
$self->setError(
|
|
|
|
"$vhost: " . $ERRORS->{CONFIG_WRITE_ERROR} . ": $error" );
|
2013-11-26 08:54:10 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
elsif ( $nerror != 0 ) {
|
|
|
|
$error .= ". ignoring...";
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->setError(
|
|
|
|
"$vhost: " . $ERRORS->{CONFIG_WRITE_ERROR} . ": $error" );
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2014-02-19 17:32:29 +01:00
|
|
|
$self->{confModified} = 1;
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2014-01-17 23:14:30 +01:00
|
|
|
## @method void vhostSetPort ( string vhost, int port )
|
2013-11-26 08:54:10 +01:00
|
|
|
# Set given vhost's port
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub vhostSetPort {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $vhost, $port ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ( $vhost and $port ) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
|
|
|
|
if ( not defined( $self->{conf}->{vhostOptions}->{$vhost} ) ) {
|
2013-11-26 10:19:28 +01:00
|
|
|
if ( not defined( $self->{conf}->{locationRules}->{$vhost} )
|
|
|
|
and not defined( $self->{conf}->{exportedHeaders}->{$vhost} ) )
|
|
|
|
{
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->setError( "$vhost: "
|
2013-11-26 10:19:28 +01:00
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
|
|
|
. ": There is no virtual host $vhost" );
|
2013-11-26 08:54:10 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$self->{conf}->{vhostOptions}->{$vhost} = {
|
|
|
|
vhostPort => $port,
|
2014-02-19 18:04:24 +01:00
|
|
|
vhostHttps => $self->{subAttributes}->vhostHttps,
|
|
|
|
vhostMaintenance => $self->{subAttributes}->vhostMaintenance,
|
|
|
|
vhostAliases => $self->{subAttributes}->vhostAliases,
|
2013-03-10 15:39:41 +01:00
|
|
|
};
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$self->{conf}->{vhostOptions}->{$vhost}->{vhostPort} = $port;
|
|
|
|
}
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->{confModified} = 1;
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2014-01-17 23:14:30 +01:00
|
|
|
## @method vhostSetHttps ( string vhost, int https )
|
2013-11-26 08:54:10 +01:00
|
|
|
# Set the https parameter on the given vhost
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub vhostSetHttps {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $vhost, $https ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ( $vhost and $https ) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
if ( not defined( $self->{conf}->{vhostOptions}->{$vhost} ) ) {
|
2013-11-26 10:19:28 +01:00
|
|
|
if ( not defined( $self->{conf}->{locationRules}->{$vhost} )
|
|
|
|
and not defined( $self->{conf}->{exportedHeaders}->{$vhost} ) )
|
|
|
|
{
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->setError( "$vhost: "
|
2013-11-26 10:19:28 +01:00
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
|
|
|
. ": There is no virtual host $vhost" );
|
2013-11-26 08:54:10 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$self->{conf}->{vhostOptions}->{$vhost} = {
|
2014-02-19 18:04:24 +01:00
|
|
|
vhostPort => $self->{subAttributes}->vhostPort,
|
2013-11-26 08:54:10 +01:00
|
|
|
vhostHttps => $https,
|
2014-02-19 18:04:24 +01:00
|
|
|
vhostMaintenance => $self->{subAttributes}->vhostMaintenance,
|
|
|
|
vhostAliases => $self->{subAttributes}->vhostAliases,
|
2013-03-10 15:39:41 +01:00
|
|
|
};
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$self->{conf}->{vhostOptions}->{$vhost}->{vhostHttps} = $https;
|
|
|
|
}
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->{confModified} = 1;
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2014-01-17 23:14:30 +01:00
|
|
|
## @method vhostSetMaintenance ( string vhost, int off )
|
2013-11-26 08:54:10 +01:00
|
|
|
# Set the maintenance flag on a vhost
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub vhostSetMaintenance {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $vhost, $off ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ( $vhost and $off ) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-11-26 10:19:28 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
if ( not defined( $self->{conf}->{vhostOptions}->{$vhost} ) ) {
|
2013-11-26 10:19:28 +01:00
|
|
|
if ( not defined( $self->{conf}->{locationRules}->{$vhost} )
|
|
|
|
and not defined( $self->{conf}->{exportedHeaders}->{$vhost} ) )
|
|
|
|
{
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->setError( "$vhost: "
|
2013-11-26 10:19:28 +01:00
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
|
|
|
. ": There is no virtual host $vhost" );
|
2013-11-26 08:54:10 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$self->{conf}->{vhostOptions}->{$vhost} = {
|
2014-02-19 18:04:24 +01:00
|
|
|
vhostPort => $self->{subAttributes}->vhostPort,
|
|
|
|
vhostHttps => $self->{subAttributes}->vhostHttps,
|
|
|
|
vhostMaintenance => $off,
|
|
|
|
vhostAliases => $self->{subAttributes}->vhostAliases,
|
2013-03-10 15:39:41 +01:00
|
|
|
};
|
|
|
|
}
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$self->{conf}->{vhostOptions}->{$vhost}->{vhostMaintenance} = $off;
|
2013-11-26 10:19:28 +01:00
|
|
|
}
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->{confModified} = 1;
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2014-01-17 23:14:30 +01:00
|
|
|
## @method void vhostList ()
|
2014-01-23 12:03:36 +01:00
|
|
|
# list all vhosts
|
2013-11-26 08:54:10 +01:00
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub vhostList {
|
2014-01-23 12:03:36 +01:00
|
|
|
my ($self) = @_;
|
2013-11-26 08:54:10 +01:00
|
|
|
|
2014-01-23 12:03:36 +01:00
|
|
|
foreach my $vhost ( sort keys %{ $self->{conf}->{locationRules} } ) {
|
|
|
|
print "- $vhost\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
## @method void vhostListOptions ( string vhost )
|
|
|
|
# list all options of each vhosts
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub vhostListOptions {
|
|
|
|
my ( $self, $vhost ) = @_;
|
|
|
|
|
|
|
|
unless ($vhost) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $vhostoptions = $self->{conf}->{vhostOptions}->{$vhost};
|
|
|
|
if ($vhostoptions) {
|
|
|
|
print "- Maintenance: $vhostoptions->{vhostMaintenance}\n";
|
|
|
|
print "- Port: $vhostoptions->{vhostPort}\n";
|
|
|
|
print "- HTTPS: $vhostoptions->{vhostHttps}\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print "No options defined for $vhost\n";
|
2013-11-26 08:54:10 +01:00
|
|
|
}
|
|
|
|
}
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2014-01-17 23:14:30 +01:00
|
|
|
## @method reloadUrls ()
|
2013-11-26 08:54:10 +01:00
|
|
|
# Print reloads urls by vhost
|
2013-03-10 15:39:41 +01:00
|
|
|
#
|
2013-11-26 08:54:10 +01:00
|
|
|
# @return nothing
|
|
|
|
sub reloadUrls {
|
|
|
|
my ($self) = shift;
|
2013-03-10 15:39:41 +01:00
|
|
|
|
2013-11-26 10:19:28 +01:00
|
|
|
while ( my ( $vhost, $url ) = each %{ $self->{conf}->{reloadUrls} } ) {
|
2013-11-26 08:54:10 +01:00
|
|
|
print "- $vhost => $url\n";
|
2013-03-10 15:39:41 +01:00
|
|
|
}
|
|
|
|
}
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2014-01-17 23:14:30 +01:00
|
|
|
## @method void reloadUrlAdd ( string vhost, string url)
|
2013-11-26 08:54:10 +01:00
|
|
|
# Add a new reload url for the given vhost
|
2013-03-10 15:39:41 +01:00
|
|
|
#
|
2013-11-26 08:54:10 +01:00
|
|
|
# @return nothing
|
|
|
|
sub reloadUrlAdd {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $vhost, $url ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ( $vhost and $url ) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
$self->{conf}->{reloadUrls}->{$vhost} = $url;
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->{confModified} = 1;
|
2013-03-10 15:39:41 +01:00
|
|
|
}
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2014-01-17 23:14:30 +01:00
|
|
|
## @method void reloadUrlDel ( string vhost )
|
2013-11-26 08:54:10 +01:00
|
|
|
# Delete the given vhost's reload url
|
2013-03-10 15:39:41 +01:00
|
|
|
#
|
2014-01-17 23:14:30 +01:00
|
|
|
# @return nothing
|
2013-11-26 08:54:10 +01:00
|
|
|
sub reloadUrlDel {
|
2013-11-26 10:19:28 +01:00
|
|
|
my ( $self, $vhost ) = @_;
|
2014-01-17 23:14:30 +01:00
|
|
|
unless ($vhost) {
|
|
|
|
$self->setError( $ERRORS->{TOO_FEW_ARGUMENTS} );
|
|
|
|
return 0;
|
|
|
|
}
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
if ( not defined( $self->{conf}->{reloadUrls}->{$vhost} ) ) {
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->setError( "$vhost: "
|
2013-11-26 10:19:28 +01:00
|
|
|
. $ERRORS->{CONFIG_WRITE_ERROR}
|
|
|
|
. ": There is no reload URLs setted for $vhost" );
|
2013-11-26 08:54:10 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-11-26 10:19:28 +01:00
|
|
|
delete $self->{conf}->{reloadUrls}->{$vhost};
|
2014-01-17 23:14:30 +01:00
|
|
|
$self->{confModified} = 1;
|
2013-03-10 15:39:41 +01:00
|
|
|
}
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2014-01-23 14:32:46 +01:00
|
|
|
## @method info ()
|
|
|
|
# print information on configuration
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub info {
|
|
|
|
|
|
|
|
my ($self) = @_;
|
|
|
|
|
|
|
|
print "Information on current configuration:\n";
|
|
|
|
print "Number: " . $self->{conf}->{cfgNum} . "\n";
|
|
|
|
print "Date: "
|
|
|
|
. strftime( "%Y/%m/%d %Hh%M", localtime( $self->{conf}->{cfgDate} ) )
|
|
|
|
. "\n"
|
|
|
|
if defined $self->{conf}->{cfgDate};
|
|
|
|
print "Author: " . $self->{conf}->{cfgAuthor} . "\n"
|
|
|
|
if defined $self->{conf}->{cfgAuthor};
|
|
|
|
print "Author IP: " . $self->{conf}->{cfgAuthorIP} . "\n"
|
|
|
|
if defined $self->{conf}->{cfgAuthorIP};
|
|
|
|
}
|
|
|
|
|
2013-11-26 21:09:00 +01:00
|
|
|
## @method void help ()
|
2013-11-26 08:54:10 +01:00
|
|
|
# print help message
|
|
|
|
#
|
|
|
|
# @return nothing
|
|
|
|
sub help {
|
2013-03-10 15:39:41 +01:00
|
|
|
my ($self) = @_;
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-03-10 15:39:41 +01:00
|
|
|
print STDERR "
|
2014-01-23 11:13:35 +01:00
|
|
|
|
2014-01-23 14:32:46 +01:00
|
|
|
Global actions
|
|
|
|
==============
|
|
|
|
|
|
|
|
lemonldap-ng-cli help - display this message
|
|
|
|
lemonldap-ng-cli info - show current configuration information
|
2014-01-23 16:00:40 +01:00
|
|
|
lemonldap-ng-cli update-cache - reload current configuration into cache
|
2014-01-23 15:05:18 +01:00
|
|
|
lemonldap-ng-cli increment - save current configuration into a new one
|
2014-01-23 14:32:46 +01:00
|
|
|
|
2014-01-23 16:00:40 +01:00
|
|
|
Scalar parameters (key/value form)
|
2014-01-23 11:13:35 +01:00
|
|
|
==================================
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-03-10 15:39:41 +01:00
|
|
|
lemonldap-ng-cli set <variable> <value>
|
|
|
|
lemonldap-ng-cli unset <variable>
|
|
|
|
lemonldap-ng-cli get <variable>
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2014-01-23 16:00:40 +01:00
|
|
|
Hash parameters
|
|
|
|
===============
|
|
|
|
|
|
|
|
lemonldap-ng-cli set-hash <variable> <key> <value>
|
|
|
|
lemonldap-ng-cli unset-hash <variable> <key>
|
|
|
|
lemonldap-ng-cli get-hash <variable>
|
|
|
|
|
2014-01-23 11:13:35 +01:00
|
|
|
Variables
|
|
|
|
=========
|
|
|
|
|
|
|
|
Exported variables
|
|
|
|
------------------
|
|
|
|
|
|
|
|
lemonldap-ng-cli export-var <key> <value>
|
|
|
|
lemonldap-ng-cli unexport-var <key>
|
|
|
|
lemonldap-ng-cli get-exported-vars
|
|
|
|
|
|
|
|
Macros
|
|
|
|
------
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-03-10 15:39:41 +01:00
|
|
|
lemonldap-ng-cli set-macro <macro name> <perl expression>
|
|
|
|
lemonldap-ng-cli unset-macro <macro name>
|
|
|
|
lemonldap-ng-cli get-macro <macro name>
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2014-01-23 11:13:35 +01:00
|
|
|
Application menu
|
|
|
|
================
|
|
|
|
|
|
|
|
Categories
|
|
|
|
----------
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-03-10 15:39:41 +01:00
|
|
|
lemonldap-ng-cli apps-set-cat <cat id> <cat name>
|
|
|
|
lemonldap-ng-cli apps-get-cat <cat id>
|
|
|
|
|
2014-01-23 11:13:35 +01:00
|
|
|
Applications
|
|
|
|
------------
|
|
|
|
|
2013-03-10 15:39:41 +01:00
|
|
|
lemonldap-ng-cli apps-add <app id> <cat id>
|
|
|
|
lemonldap-ng-cli apps-set-uri <app id> <app uri>
|
|
|
|
lemonldap-ng-cli apps-set-name <app id> <app name>
|
|
|
|
lemonldap-ng-cli apps-set-desc <app id> <app description>
|
|
|
|
lemonldap-ng-cli apps-set-logo <app id> <logo>
|
|
|
|
lemonldap-ng-cli apps-set-display <app id> <app display>
|
|
|
|
|
|
|
|
lemonldap-ng-cli apps-get <app id>
|
|
|
|
lemonldap-ng-cli apps-rm <app id>
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2014-01-23 11:13:35 +01:00
|
|
|
Virtual hosts
|
|
|
|
=============
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2014-01-23 11:13:35 +01:00
|
|
|
lemonldap-ng-cli vhost-add <virtual host uri>
|
|
|
|
lemonldap-ng-cli vhost-del <virtual host>
|
|
|
|
lemonldap-ng-cli vhost-list
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2014-01-23 11:13:35 +01:00
|
|
|
Exported headers
|
|
|
|
----------------
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-03-10 15:39:41 +01:00
|
|
|
lemonldap-ng-cli export-header <virtual host> <HTTP header> <perl expression>
|
|
|
|
lemonldap-ng-cli unexport-header <virtual host> <HTTP header>
|
|
|
|
lemonldap-ng-cli get-exported-headers <virtual host>
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2014-01-23 11:13:35 +01:00
|
|
|
Rules
|
|
|
|
-----
|
|
|
|
|
|
|
|
lemonldap-ng-cli rules-set <virtual host> <expr> <rule>
|
|
|
|
lemonldap-ng-cli rules-unset <virtual host> <expr>
|
|
|
|
lemonldap-ng-cli rules-get <virtual host>
|
|
|
|
|
|
|
|
Options
|
|
|
|
-------
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-03-10 15:39:41 +01:00
|
|
|
lemonldap-ng-cli vhost-set-port <virtual host> <port>
|
|
|
|
lemonldap-ng-cli vhost-set-https <virtual host> <value>
|
|
|
|
lemonldap-ng-cli vhost-set-maintenance <virtual host> <value>
|
2014-01-23 12:03:36 +01:00
|
|
|
lemonldap-ng-cli vhost-list-options <virtual host>
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2014-01-23 11:13:35 +01:00
|
|
|
Reload URLs
|
|
|
|
===========
|
2013-03-10 15:39:41 +01:00
|
|
|
|
|
|
|
lemonldap-ng-cli reload-urls
|
|
|
|
lemonldap-ng-cli reload-url-add <vhost> <url>
|
|
|
|
lemonldap-ng-cli reload-url-del <vhost>
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-03-10 15:39:41 +01:00
|
|
|
";
|
2013-03-07 18:37:22 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|
|
|
|
__END__
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
=encoding utf8
|
|
|
|
|
|
|
|
Lemonldap::NG::Manager::Cli - Command Line Interface to edit LemonLDAP::NG configuration.
|
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
use Lemonldap::NG::Manager::Cli;
|
2013-03-07 18:37:22 +01:00
|
|
|
|
2013-11-26 08:54:10 +01:00
|
|
|
$cli = new Lemonldap::NG::Manager::Cli;
|
|
|
|
$action = shift(@ARGV);
|
|
|
|
$method = $cli->determineMethod($action);
|
|
|
|
$cli->run($method, @ARGV);
|
|
|
|
$ret = $cli->saveConf();
|
2013-03-07 18:37:22 +01:00
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
2014-01-23 14:32:46 +01:00
|
|
|
Lemonldap::NG::Manager::Cli allow user to edit the configuration of LemonLDAP::NG via the
|
2013-03-07 18:37:22 +01:00
|
|
|
command line.
|
|
|
|
|
|
|
|
=head1 SEE ALSO
|
|
|
|
|
|
|
|
L<Lemonldap::NG>, L<Lemonldap::NG::Common::Conf>
|
|
|
|
|
|
|
|
=head1 AUTHOR
|
|
|
|
|
|
|
|
David Delassus E<lt>david.jose.delassus@gmail.comE<gt>
|
2013-03-10 15:39:41 +01:00
|
|
|
Clement Oudot E<lt>clem.oudot@gmail.comE<gt>
|
2013-11-26 08:54:10 +01:00
|
|
|
Sandro Cazzaniga E<lt>cazzaniga.sandro@gmail.comE<gt>
|
2013-03-07 18:37:22 +01:00
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE
|
|
|
|
|
|
|
|
Copyright (C) 2012, by David Delassus
|
2013-11-26 08:54:10 +01:00
|
|
|
Copyright (C) 2013, by Clement Oudot, Sandro Cazzaniga
|
2013-03-07 18:37:22 +01:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.10.0 or,
|
|
|
|
at your option, any later version of Perl 5 you may have available.
|
|
|
|
|
|
|
|
=cut
|