From 52854b630fc80cf894d358ba54d269902854e9e4 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 24 Apr 2012 15:00:35 +0200 Subject: [PATCH] Initial commit --- createlinks | 8 ++++ ipasserelle-telephony.spec | 54 ++++++++++++++++++++++ .../migrate/LemonLDAPSOAPAccessFreePBX | 19 ++++++++ .../etc/lemonldap-ng/lemonldap-ng-fpbx.ini | 4 ++ .../httpd.conf/UserManagerVirtualHost/51FreePBX | 2 + .../fpbx-conf/httpd.conf/20LoadModule80mod_perl | 8 ++++ .../httpd/fpbx-conf/httpd.conf/25LemonLDAPHandler | 19 ++++++++ .../etc/httpd/fpbx-conf/httpd.conf/95FreePBXsso | 28 +++++++++++ .../etc/lemonldap-ng/lemonldap-ng-fpbx.ini/05All | 9 ++++ root/var/lib/lemonldap-ng/handler/MyFpbxHandler.pm | 11 +++++ 10 files changed, 162 insertions(+) create mode 100644 createlinks create mode 100644 ipasserelle-telephony.spec create mode 100644 root/etc/e-smith/db/configuration/migrate/LemonLDAPSOAPAccessFreePBX create mode 100644 root/etc/e-smith/templates.metadata/etc/lemonldap-ng/lemonldap-ng-fpbx.ini create mode 100644 root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/UserManagerVirtualHost/51FreePBX create mode 100644 root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/20LoadModule80mod_perl create mode 100644 root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/25LemonLDAPHandler create mode 100644 root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/95FreePBXsso create mode 100644 root/etc/e-smith/templates/etc/lemonldap-ng/lemonldap-ng-fpbx.ini/05All create mode 100644 root/var/lib/lemonldap-ng/handler/MyFpbxHandler.pm diff --git a/createlinks b/createlinks new file mode 100644 index 0000000..2cda3ba --- /dev/null +++ b/createlinks @@ -0,0 +1,8 @@ +#!/usr/bin/perl -w + +use esmith::Build::CreateLinks qw(:all); + +foreach my $event (qw/bootstrap-console-save webapps-update ipasserelle-update/){ + templates2events("/etc/lemonldap-ng/lemonldap-ng-fpbx.ini", "$event"); +} + diff --git a/ipasserelle-telephony.spec b/ipasserelle-telephony.spec new file mode 100644 index 0000000..8204478 --- /dev/null +++ b/ipasserelle-telephony.spec @@ -0,0 +1,54 @@ +%define version 0.2.0 +%define release 1 +%define name ipasserelle-telephony + + +Summary: Meta-Package to add Toip services to your iPasserelle +Name: %{name} +Version: %{version} +Release: %{release}%{?dist} +License: GPL +Group: Networking/Daemons +Source: %{name}-%{version}.tar.gz + +BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot +BuildArchitectures: noarch +BuildRequires: e-smith-devtools + +Obsoletes: smeserver-ejabberd +Provides: smeserver-ejabberd + +Requires: ipasserelle-base +Requires: smeserver-freepbx >= 0.1-32 +Requires: ipasserelle-userpanel + +%description +Meta package to configure Toip services +on your iPasserelle. + +* Thu Oct 20 2011 Daniel Berteaud 0.2.0 +- initial release + + +%prep +%setup -q -n %{name}-%{version} + +%build +perl createlinks + +%install +/bin/rm -rf $RPM_BUILD_ROOT +(cd root ; /usr/bin/find . -depth -print | /bin/cpio -dump $RPM_BUILD_ROOT) +/bin/rm -f %{name}-%{version}-filelist +/sbin/e-smith/genfilelist $RPM_BUILD_ROOT \ + > %{name}-%{version}-filelist + +%files -f %{name}-%{version}-filelist +%defattr(-,root,root) + +%clean +rm -rf $RPM_BUILD_ROOT + +%post +%preun + diff --git a/root/etc/e-smith/db/configuration/migrate/LemonLDAPSOAPAccessFreePBX b/root/etc/e-smith/db/configuration/migrate/LemonLDAPSOAPAccessFreePBX new file mode 100644 index 0000000..4542c22 --- /dev/null +++ b/root/etc/e-smith/db/configuration/migrate/LemonLDAPSOAPAccessFreePBX @@ -0,0 +1,19 @@ +{ + +my $llng = $DB->get("lemonldap") || + $DB->new_record("lemonldap", { type => "service" }); + +my @soapaccess = split(/[;,]/, ($llng->prop('SoapAllowFrom') || '')); +my $internal = $DB->get('InternalInterface')->prop('IPAddress'); +push @soapaccess, $internal if (!grep {$internal eq $_} @soapaccess); +$llng->set_prop('SoapAllowFrom', join(',',@soapaccess)); + +# httpd-fpbx handler +my @reload = split(/[;,]/, ($llng->prop('Reload') || '')); +my $reloadurl = 'localhost:960=http://localhost:960/lm-reload'; +push @reload, $reloadurl if (!grep {$reloadurl eq $_} @reload); + +$llng->set_prop('Reload', join(',',@reload)); + +} + diff --git a/root/etc/e-smith/templates.metadata/etc/lemonldap-ng/lemonldap-ng-fpbx.ini b/root/etc/e-smith/templates.metadata/etc/lemonldap-ng/lemonldap-ng-fpbx.ini new file mode 100644 index 0000000..f74c5cc --- /dev/null +++ b/root/etc/e-smith/templates.metadata/etc/lemonldap-ng/lemonldap-ng-fpbx.ini @@ -0,0 +1,4 @@ +PERMS=0640 +UID="root" +GID="asterisk" + diff --git a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/UserManagerVirtualHost/51FreePBX b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/UserManagerVirtualHost/51FreePBX new file mode 100644 index 0000000..d6cde52 --- /dev/null +++ b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/UserManagerVirtualHost/51FreePBX @@ -0,0 +1,2 @@ + RewriteRule ^/freepbx(sso)?(/.*)$ http://localhost:960/freepbxsso$2 [P,L] + diff --git a/root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/20LoadModule80mod_perl b/root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/20LoadModule80mod_perl new file mode 100644 index 0000000..1484ba6 --- /dev/null +++ b/root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/20LoadModule80mod_perl @@ -0,0 +1,8 @@ +{ + my $status = $modPerl{status}; + + return "# modPerl disabled" unless ($status and $status eq "enabled"); + + return "LoadModule perl_module modules/mod_perl.so"; +} + diff --git a/root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/25LemonLDAPHandler b/root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/25LemonLDAPHandler new file mode 100644 index 0000000..93b48c5 --- /dev/null +++ b/root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/25LemonLDAPHandler @@ -0,0 +1,19 @@ +# Load LemonLDAP::NG Handler +PerlOptions +GlobalRequest +PerlRequire /var/lib/lemonldap-ng/handler/MyFpbxHandler.pm + +# Common error page and security parameters +ErrorDocument 403 http://auth.{$DomainName}/?lmError=403 +ErrorDocument 500 http://auth.{$DomainName}/?lmError=500 + + +# Configuration reload mechanism (only 1 per physical server is +# needed): choose your URL to avoid restarting Apache when +# configuration change + + Order deny,allow + Deny from all + Allow from localhost + PerlHeaderParserHandler My::Package->refresh + + diff --git a/root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/95FreePBXsso b/root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/95FreePBXsso new file mode 100644 index 0000000..7871511 --- /dev/null +++ b/root/etc/e-smith/templates/etc/httpd/fpbx-conf/httpd.conf/95FreePBXsso @@ -0,0 +1,28 @@ +Alias /freepbxsso /opt/freepbx + + + PerlHeaderParserHandler My::Package +{ +my @users = split(/\s/, getUsersList("freepbx")); +foreach my $u (@users){ + $OUT .= " SetEnvIf Auth-User \"$u\" allow_freepbx\n"; +} +} + order deny,allow + deny from all + allow from env=allow_freepbx + + + + PerlHeaderParserHandler My::Package +{ +my @users = split(/\s/, getUsersList("fop")); +foreach my $u (@users){ + $OUT .= " SetEnvIf Auth-User \"$u\" allow_fop\n"; +} +} + order deny,allow + deny from all + allow from env=allow_fop + + diff --git a/root/etc/e-smith/templates/etc/lemonldap-ng/lemonldap-ng-fpbx.ini/05All b/root/etc/e-smith/templates/etc/lemonldap-ng/lemonldap-ng-fpbx.ini/05All new file mode 100644 index 0000000..62c0508 --- /dev/null +++ b/root/etc/e-smith/templates/etc/lemonldap-ng/lemonldap-ng-fpbx.ini/05All @@ -0,0 +1,9 @@ +[all] + +[configuration] +type = SOAP +proxy = https://lemonsoap:{$lemonldap{'SoapPassword'};}@soapsso.{$DomainName}/index.pl/config +proxyOptions = \{ timeout => 5 \} +localStorage=Cache::FileCache +localStorageOptions=\{ 'namespace' => 'LemonLDAPngFpbx', 'default_expires_in' => 600, 'directory_umask' => '007', 'cache_root' => '/tmp', 'cache_depth' => 5, \} + diff --git a/root/var/lib/lemonldap-ng/handler/MyFpbxHandler.pm b/root/var/lib/lemonldap-ng/handler/MyFpbxHandler.pm new file mode 100644 index 0000000..dde0c07 --- /dev/null +++ b/root/var/lib/lemonldap-ng/handler/MyFpbxHandler.pm @@ -0,0 +1,11 @@ +package My::Package; +use Lemonldap::NG::Handler::SharedConf; +@ISA = qw(Lemonldap::NG::Handler::SharedConf); + +__PACKAGE__->init( + { + configStorage => { confFile => '/etc/lemonldap-ng/lemonldap-ng-fpbx.ini' }, + } +); +1; +