Merge apply.conf in lemonldap-ng.ini

This commit is contained in:
Clément Oudot 2009-12-03 09:56:45 +00:00
parent 0ea44c2389
commit 4c1574e034
8 changed files with 44 additions and 46 deletions

View File

@ -271,12 +271,7 @@ install_manager_site: install_conf_dir
rm -rf ${RMANAGERDIR}/imgs; \
ln -s $$(echo ${MANAGERDATADIR} | sed -e 's/\/$$//') ${RMANAGERDIR}/imgs; \
fi
# apply.conf install if erase configuration is wanted
@if [ "$(ERASECONFIG)" -eq "1" ]; then \
mv -f ${RMANAGERDIR}/apply.conf "$(RCONFDIR)"; \
fi
@perl -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RCONFDIR)/apply.conf
@perl -i -pe 's#__APPLYCONFFILE__#$(CONFDIR)/apply.conf#' ${RMANAGERDIR}/index.pl
@perl -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(RCONFDIR)/$(CONFFILENAME)
# Sessions explorer install
@if [ "${MANAGERDIR}" != "$(SESSIONSEXPLORERDIR)" ]; then mv -f ${RMANAGERDIR}/sessions.pl $(RSESSIONSEXPLORERDIR); fi
@if [ "${MANAGERDIR}/images/" != "${SESSIONSEXPLORERDATADIR}/" ]; then \
@ -353,8 +348,6 @@ install_examples_site:
$(REXAMPLESDIR)/manager/images \
@rm -rf $$(find $(REXAMPLESDIR) -type d -name .svn)
@perl -i -pe 's#__DIR__#$(LASPPORTALDIR)#g' $(REXAMPLESDIR)/portal/AuthLA/index.pl
@perl -i -pe 's/__DNSDOMAIN__/$(DNSDOMAIN)/g' $(REXAMPLESDIR)/manager/apply.conf
@perl -i -pe 's#__APPLYCONFFILE__#$(CONFDIR)/apply.conf#' $(REXAMPLESDIR)/manager/*.pl
@perl -i -pe 's#__SKINDIR__#$(PORTALDIR)/skins#; \
s#__APPSXMLFILE__#$(CONFDIR)/apps-list.xml#; \
s#__SESSIONDIR__#$(APACHESESSIONFILEDIR)/#g;' $(REXAMPLESDIR)/portal/*.pl

View File

@ -5,8 +5,15 @@
# You can set here configuration parameters that will be used only by
# local LemonLDAP::NG elements
#
# Parameters of section "all" are always read
# Section "all" is always read first before "portal", "handler"
# and "manager"
#
# Section "configuration" is used to load global configuration and set cache
# (replace old storage.conf file)
#
# Section "apply" is read by Manager to reload handlers
# (replace old apply.conf file)
#
# Other section are only read by the specific LemonLDAP::NG component
#==============================================================================
@ -32,3 +39,5 @@ https = 0
dhtmlXTreeImageLocation = /imgs/
;protection = authenticate
[apply]
test1.__DNSDOMAIN__ = http://test1.__DNSDOMAIN__/reload

View File

@ -19,6 +19,7 @@ use constant CONFSECTION => "configuration";
use constant PORTALSECTION => "portal";
use constant HANDLERSECTION => "handler";
use constant MANAGERSECTION => "manager";
use constant APPLYSECTION => "apply";
our %EXPORT_TAGS = ( 'all' => [ qw(
CONFIG_WAS_CHANGED
@ -32,6 +33,7 @@ our %EXPORT_TAGS = ( 'all' => [ qw(
PORTALSECTION
HANDLERSECTION
MANAGERSECTION
APPLYSECTION
) ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );

View File

@ -1,3 +0,0 @@
test1.__DNSDOMAIN__ http://test1.__DNSDOMAIN__/reload
test2.__DNSDOMAIN__ http://test2.__DNSDOMAIN__/reload

View File

@ -6,7 +6,6 @@ my $h = new Lemonldap::NG::Manager::Experimental(
{
jqueryUri => '/javascript/jquery/jquery.js',
imagePath => '/images/',
applyConfFile => '/etc/lemonldap-ng//apply.conf',
cssFile => 'theme/default.css',
textareaW => 50,
textareaH => 2,

View File

@ -6,7 +6,6 @@ my $h = new Lemonldap::NG::Manager(
{
# REQUIRED PARAMETERS
dhtmlXTreeImageLocation => "/imgs/",
applyConfFile => '__APPLYCONFFILE__',
cssFile => 'theme/default.css',
textareaW => 50,
textareaH => 2,

View File

@ -779,47 +779,57 @@ sub checkConf {
}
# Apply subroutines
# TODO: Credentials in applyConfFile
# TODO: Credentials in APPLYSECTION
## @method void print_apply()
# Call all Lemonldap::NG handlers declared in $self->{applyConfFile} file to
# Call all Lemonldap::NG handlers declared in local ini file to
# ask them to reload Lemonldap::NG configuration.
sub print_apply {
my $self = shift;
# Read APPLYSECTION from local ini file
my $applyconf = $self->config->getLocalConf( APPLYSECTION, "", 0 );
# Test if section was read
print $self->header( -type => "text/html; charset=utf8" );
unless ( -r $self->{applyConfFile} ) {
unless ( ref $applyconf ) {
print "<h3>" . &txt_canNotReadApplyConfFile . "</h3>";
return;
}
# Call all reload routines on configured handlers
print '<h3>' . &txt_result . ' : </h3><ul>';
open F, $self->{applyConfFile};
# Initiate User Agent
my $ua = new LWP::UserAgent( requests_redirectable => [] );
$ua->timeout(10);
while (<F>) {
local $| = 1;
# pass blank lines and comments
next if ( /^$/ or /^\s*#/ );
chomp;
s/\r//;
# Loop on defined handlers in APPLYSECTION
foreach my $host ( keys %$applyconf ) {
# Request must be like method://vhost/uri/
my $request = $applyconf->{$host};
# each line must be like:
# host http(s)://vhost/request/
my ( $host, $request ) = (/^\s*([^\s]+)\s+([^\s]+)$/);
unless ( $host and $request ) {
print "<li> " . &txt_invalidLine . ": $_</li>";
next;
}
my ( $method, $vhost, $uri ) =
( $request =~ /^(https?):\/\/([^\/]+)(.*)$/ );
# If no vhost value, set
# - method to http
# - vhost to host
# - uri to request
unless ($vhost) {
$vhost = $host;
$uri = $request;
$method = "http";
$vhost = $host;
$uri = $request;
}
print "<li>$host ... ";
# GET HTTP request on handlers
print "<li>$host ... ";
my $r =
HTTP::Request->new( 'GET', "$method://$host$uri",
HTTP::Headers->new( Host => $vhost ) );
# Display responses
my $response = $ua->request($r);
if ( $response->code != 200 ) {
print join( ' ',
@ -937,15 +947,6 @@ error logs.
=item * B<jsFile> (optional): the path to the file C<lemonldap-ng-manager.js>.
It is required only if this file is not in the same directory than your script.
=item * B<applyConfFile> (optional): the path to a file containing parameters
to make configuration reloaded by handlers. See C<reload> function in
L<Lemonldap::NG::Handler>. The configuration file must contains lines like:
# Comments if wanted
host http://virtual-host/reload-path
When this parameter is set, an "apply" button is added to the manager menu.
=back
=item * B<doall>: subroutine that provide headers and the full html code. Il

View File

@ -223,9 +223,7 @@ function onNodeSelect(nodeId) {
+button('$text{lastConf}','lastConf',nodeId)
+button('$text{deleteConf}','deleteConf',nodeId);
#;
if ( $self->{applyConfFile} ) {
print "but+=button('$text{applyConf}','applyConf',nodeId);";
}
print "but+=button('$text{applyConf}','applyConf',nodeId);";
print qq#
document.getElementById('buttons').innerHTML = but;
}