Commit 0835ae98 authored by Yadd's avatar Yadd
Browse files

LEMONLDAP::NG : Better Debian structure and debconf management

parent cd0cf7e8
debian/tmp/usr/share/perl5/Lemonldap/NG/Portal*
debian/tmp/usr/share/perl5/auto/Lemonldap/NG/Portal
debian/tmp/usr/share/man/man3/Lemonldap::NG::Portal*
debian/portal-apache*.conf /etc/lemonldap-ng
#!/bin/bash
# Maintainer: #DEBHELPER#
. /usr/share/debconf/confmodule
EXAMPLEPORTALFILE=/usr/share/doc/liblemonldap-ng-portal-perl/examples/index.pl
PORTALFILE=/var/lib/lemonldap-ng/portal/index.pl
EXAMPLECLEANERFILE=/usr/share/doc/liblemonldap-ng-portal-perl/examples/scripts/purgeCentralCache
CLEANERFILE=/usr/share/lemonldap-ng/bin/purgeCentralCache
SESSIONSDIR=/var/lib/lemonldap-ng/sessions
if [ "$1" == "configure" ]
then
[ -e $PORTALFILE ] || \
perl -000 -pe 's/(configStorage\s*=>\s*){[^}]+}/$1\$Lemonldap::NG::Conf::configStorage/;
s#^use#\nrequire "/usr/share/lemonldap-ng/configStorage.pm";\nuse#m;' \
$EXAMPLEPORTALFILE >$PORTALFILE
[ -e $CLEANERFILE ] || \
perl -000 -pe 's/(configStorage\s*=>\s*){[^}]+}/$1\$Lemonldap::NG::Conf::configStorage/;
s#^use#\nrequire "/usr/share/lemonldap-ng/configStorage.pm";\nuse#m;' \
$EXAMPLECLEANERFILE >$CLEANERFILE
chmod +x $PORTALFILE
chmod +x $CLEANERFILE
chmod 770 $SESSIONSDIR;
chown www-data.www-data $SESSIONSDIR;
fi
<VirtualHost *>
ServerName manager.example.com
# DocumentRoot
DocumentRoot /var/lib/lemonldap-ng/manager
<Directory /var/lib/lemonldap-ng/manager>
Order deny,allow
Deny from all
Allow from 127.0.0.0/8
Options +ExecCGI
</Directory>
# Manager must be interpreted by Perl
<Files *.pl>
SetHandler perl-script
PerlHandler Apache::Registry
</Files>
<IfModule mod_dir.c>
DirectoryIndex index.pl index.html
</IfModule>
</VirtualHost>
<VirtualHost *>
ServerName manager.example.com
# DocumentRoot
DocumentRoot /var/lib/lemonldap-ng/manager
<Directory /var/lib/lemonldap-ng/manager>
Order deny,allow
Deny from all
Allow from 127.0.0.0/8
Options +ExecCGI
</Directory>
# Manager must be interpreted by Perl
<Files *.pl>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
</Files>
<IfModule mod_dir.c>
DirectoryIndex index.pl index.html
</IfModule>
</VirtualHost>
<VirtualHost *>
ServerName auth.example.com
# DocumentRoot
DocumentRoot /var/lib/lemonldap-ng/portal
<Directory /var/lib/lemonldap-ng/portal>
Order allow,deny
Allow from all
Options +ExecCGI
</Directory>
# Portal must be interpreted by Perl
<Files *.pl>
SetHandler perl-script
PerlHandler Apache::Registry
</Files>
<IfModule mod_dir.c>
DirectoryIndex index.pl index.html
</IfModule>
</VirtualHost>
<VirtualHost *>
ServerName auth.example.com
# DocumentRoot
DocumentRoot /var/lib/lemonldap-ng/portal
<Directory /var/lib/lemonldap-ng/portal>
Order allow,deny
Allow from all
Options +ExecCGI
</Directory>
# Portal must be interpreted by Perl
<Files *.pl>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
</Files>
<IfModule mod_dir.c>
DirectoryIndex index.pl index.html
</IfModule>
</VirtualHost>
......@@ -49,8 +49,12 @@ install: build
# Add here commands to install the package into debian/lemonldap-ng.
$(MAKE) test
$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp PREFIX=/usr
$(MAKE) example EXAMPLEDIR=/usr/share/doc/lemonldap-ng/examples/ EXAMPLECONFDIR=/var/lib/lemonldap-ng/conf
$(MAKE) example EXAMPLEDIRBUILD=debian/tmp/var/lib/lemonldap-ng EXAMPLEDIR=/var/lib/lemonldap-ng/ EXAMPLECONFDIR=/var/lib/lemonldap-ng/conf
cp debian/tmp/var/lib/lemonldap-ng/handler/MyHandler.pm debian/tmp/var/lib/lemonldap-ng/handler/MyHandler-Debian.pm
mv debian/tmp/var/lib/lemonldap-ng/index.pl debian/tmp/var/lib/lemonldap-ng/test.pl
perl -000 -i -pe 's/(new\s*\(\s*){[^}]+}/$$1\$$Lemonldap::NG::Conf::configStorage/; s#^use#\nrequire "/usr/share/lemonldap-ng/configStorage.pm";\nuse#m;' \
debian/tmp/var/lib/lemonldap-ng/manager/scripts/lmConfigEditor \
debian/tmp/var/lib/lemonldap-ng/handler/MyHandler-Debian.pm
# Build architecture-independent files here.
binary-indep: build install
......@@ -62,7 +66,12 @@ binary-arch: build install
dh_testroot
dh_installchangelogs
dh_installdocs
mkdir debian/tmp/var/lib/lemonldap-ng/protected
cp _example/index.pl debian/tmp/var/lib/lemonldap-ng/protected
find debian/tmp/var/lib/lemonldap-ng -type f -perm /111 -exec chmod -x {} \;
chmod +x debian/tmp/var/lib/lemonldap-ng/manager/scripts/lmConfigEditor
dh_installexamples
find debian/lemonldap-ng -type f -exec perl -i -pe 's#__DIR__/?#'/var/lib/lemonldap-ng'#g;s#__CONFDIR__/?#'/var/lib/lemonldap-ng/conf'#g;' {} \;
dh_install
# dh_installmenu
dh_installdebconf
......@@ -72,13 +81,12 @@ binary-arch: build install
# dh_installmime
# dh_python
# dh_installinit
# dh_installcron
dh_installcron
# dh_installinfo
dh_installman
dh_link
dh_strip
dh_compress
gunzip $(CURDIR)/debian/lemonldap-ng/usr/share/doc/lemonldap-ng/examples/manager/lemonldap-ng-manager.js.gz
dh_fixperms
# dh_perl
# dh_makeshlibs
......
#
# This file contains parameters used by Lemonldap::NG to find its configuration
#
#
# 1 - Type
#
# You can use one of the following:
# * File: you have to set 'dirName' parameter. Example:
# type = File
# dirName = /var/lib/lemonldap-ng/conf
#
# * DBI : you have to set 'dbiChain' (required) and 'dbiUser' and 'dbiPassword'
# if needed. Example:
# type = DBI
# dbiChain = DBI:mysql:database=lemonldap-ng,host=1.2.3.4
# dbiUser = lemonldap
# dbiPassword = password
#
# * SOAP: SOAP configuration access is a sort of proxy: the SOAP server that
# runs Lemonldap::NG::Manager::SOAPServer is configured to use the real
# session storage type (DBI or File for example).
# You have to set 'proxy' parameter. Example
# type = SOAP
# proxy = https://manager.example.com/soapmanager.pl
# proxyOptions = { timeout => 5 }
type = File
dirName = /var/lib/lemonldap-ng/conf
......@@ -7,6 +7,9 @@ __PACKAGE__->init ( {
localStorageOptions => {
'namespace' => 'MyNamespace',
'default_expires_in' => 600,
'directory_umask' => '007',
'cache_root' => '/tmp',
'cache_depth' => 5,
},
configStorage => {
......
......@@ -44,16 +44,16 @@ example/imgs/plus5.gif
example/imgs/plus_ar.gif
example/imgs/tombs.gif
example/imgs/tombs_mag.gif
example/index.pl
example/lemonldap-ng-manager.js
example/lmConfig.mysql
example/index.pl
example/scripts/lmSessionDump
example/scripts/lmConfigEditor
example/scripts/lmSessionDump
example/soapserver.pl
lib/Lemonldap/NG/Manager.pm
lib/Lemonldap/NG/Manager/Apache/Session/SOAP.pm
lib/Lemonldap/NG/Manager/_HTML.pm
lib/Lemonldap/NG/Manager/_i18n.pm
lib/Lemonldap/NG/Manager/Apache/Session/SOAP.pm
lib/Lemonldap/NG/Manager/Base.pm
lib/Lemonldap/NG/Manager/Conf.pm
lib/Lemonldap/NG/Manager/Conf/Constants.pm
......@@ -68,11 +68,11 @@ MANIFEST
META.yml Module meta-data (added by MakeMaker)
README
scripts/lmConfig_File2MySQL
TODO
t/Lemonldap-NG-Manager.t
t/Lemonldap-NG-Manager_en.t
t/Lemonldap-NG-Manager_fr.t
t/Lemonldap-NG-Manager-Conf.t
t/Lemonldap-NG-Manager-Conf-DBI.t
t/Lemonldap-NG-Manager-Conf-File.t
t/Lemonldap-NG-Manager-Conf-SOAP.t
t/Lemonldap-NG-Manager-Conf.t
t/Lemonldap-NG-Manager.t
t/Lemonldap-NG-Manager_en.t
t/Lemonldap-NG-Manager_fr.t
TODO
Changes
example/index.pl
example/scripts/purgeCentralCache
example/scripts/purgeCentralCache.cron.d
example/slavePortal.pl
lib/Lemonldap/NG/Portal.pm
lib/Lemonldap/NG/Portal/_i18n.pm
......
#!/usr/bin/perl
# Cleaner for Lemonldap::NG : removes old sessions from Apache::Session
#
# This module is written to be used by cron to clean old sessions from
# Apache::Session.
#
# WARNING: only Apache::Session::File and Apache::Session::MySQL can be used
# here
BEGIN {
sub Apache::Session::get_all_sessions {
return 0;
}
sub Apache::Session::MySQL::get_all_sessions {
my $class = shift;
my $args = shift;
my $dbh =
DBI->connect( $args->{DataSource}, $args->{UserName},
$args->{Password} )
or die("$!$@");
my $sth = $dbh->prepare('SELECT id from sessions');
$sth->execute;
my @res;
while ( my @row = $sth->fetchrow_array ) {
push @res, @row;
}
return @res;
}
sub Apache::Session::File::get_all_sessions {
my $class = shift;
my $args = shift;
$args->{Directory} ||= '/tmp';
unless ( opendir DIR, $args->{Directory} ) {
die "Cannot open directory $args->{Directory}\n";
}
my @t =
grep { -f "$args->{Directory}/$_" and /^[A-Za-z0-9@\-]+$/ }
readdir(DIR);
closedir DIR;
return @t;
}
}
use Lemonldap::NG::Manager::Conf;
use Lemonldap::NG::Manager::Conf::Constants;
use strict;
use DBI;
my $lmconf = Lemonldap::NG::Manager::Conf->new(
{
type => 'File',
dirName => '__CONFDIR__',
}
);
my $conf = $lmconf->getConf or die "Unable to get configuration ($!)";
my $tmp = $conf->{globalStorage};
eval "use $tmp";
die $@ if ($@);
$conf->{globalStorageOptions}->{timeout} ||= 7200;
my @t = $tmp->get_all_sessions( $conf->{globalStorageOptions} );
for my $id (@t) {
my %h;
eval { tie %h, $tmp, $id, $conf->{globalStorageOptions} };
if ($@) {
next;
}
else {
if ( time - $h{_utime} > $conf->{globalStorageOptions}->{timeout} ) {
tied(%h)->delete;
}
else {
untie %h;
}
}
}
1;
#
# Regular cron jobs for the Lemonldap::NG portal
#
*/10 * * * * www-data test -x /usr/share/lemonldap-ng/bin/purgeCentralCache
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment