From e77fa51fba5f2a54698642effdc3d7b6e5e7acc7 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 9 Oct 2012 18:22:17 +0200 Subject: [PATCH] premier commit --- createlinks | 13 +++++ ipasserelle-phpmyadmin.spec | 57 ++++++++++++++++++++++ .../db/configuration/defaults/phpmyadmin/access | 1 + .../db/configuration/defaults/phpmyadmin/status | 1 + .../db/configuration/defaults/phpmyadmin/type | 1 + .../events/actions/ipasserelle-pma-init-domain | 29 +++++++++++ .../etc/phpMyAdmin/config.inc.php | 3 ++ .../etc/httpd/conf/httpd.conf/98phpMyAdmin | 28 +++++++++++ .../templates/etc/phpMyAdmin/config.inc.php/10All | 31 ++++++++++++ .../var/lib/lemonldap-ng/conf/lmConf/075phpMyadmin | 28 +++++++++++ 10 files changed, 192 insertions(+) create mode 100644 createlinks create mode 100644 ipasserelle-phpmyadmin.spec create mode 100644 root/etc/e-smith/db/configuration/defaults/phpmyadmin/access create mode 100644 root/etc/e-smith/db/configuration/defaults/phpmyadmin/status create mode 100644 root/etc/e-smith/db/configuration/defaults/phpmyadmin/type create mode 100644 root/etc/e-smith/events/actions/ipasserelle-pma-init-domain create mode 100644 root/etc/e-smith/templates.metadata/etc/phpMyAdmin/config.inc.php create mode 100644 root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98phpMyAdmin create mode 100644 root/etc/e-smith/templates/etc/phpMyAdmin/config.inc.php/10All create mode 100644 root/etc/e-smith/templates/var/lib/lemonldap-ng/conf/lmConf/075phpMyadmin diff --git a/createlinks b/createlinks new file mode 100644 index 0000000..7e44eb6 --- /dev/null +++ b/createlinks @@ -0,0 +1,13 @@ +#!/usr/bin/perl -w + +use esmith::Build::CreateLinks qw(:all); + +foreach my $event (qw/bootstrap-console-save webapps-update ipasserelle-update/){ + templates2events("/etc/phpMyAdmin/config.inc.php", $event); + event_link("ipasserelle-pma-init-domain", "$event", "25"); +} + +# PHP header and footer +safe_symlink("/etc/e-smith/templates-default/template-begin-php", "root/etc/e-smith/templates/etc/phpMyAdmin/config.inc.php/template-begin"); +safe_symlink("/etc/e-smith/templates-default/template-end-php", "root/etc/e-smith/templates/etc/phpMyAdmin/config.inc.php/template-end"); + diff --git a/ipasserelle-phpmyadmin.spec b/ipasserelle-phpmyadmin.spec new file mode 100644 index 0000000..659a907 --- /dev/null +++ b/ipasserelle-phpmyadmin.spec @@ -0,0 +1,57 @@ +%define version 0.1.0 +%define release 1 +%define name ipasserelle-phpmyadmin + +Name: %{name} +Version: %{version} +Release: %{release}%{?dist} +Summary: phpMyAdmin for iPasserelle +Group: System Environment/Applications +License: GPLv3+ +URL: http://www.ipasserelle.com +Source0: %{name}-%{version}.tar.gz + +BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot +BuildArch: noarch + +BuildRequires: e-smith-devtools + +Requires: ipasserelle-base +Requires: smeserver-webapps-common >= 0.2.7 +Requires: smeserver-lemonldap-ng >= 0.2.3 +Requires: phpMyAdmin3 + +Obsoletes: phpmyadmin +Obsoletes: smeserver-phpmyadmin + +%description +phpMyAdmin integration for iPasserelle + +%changelog +* Tue Oct 9 2012 Daniel Berteaud - 0.1.0-1.sme +- Initial release + +%prep +%setup -q + +%build +perl ./createlinks + +%install +rm -rf $RPM_BUILD_ROOT +rm -f %{name}-%{version}-filelist +(cd root ; /usr/bin/find . -depth -print | /bin/cpio -dump $RPM_BUILD_ROOT) +/sbin/e-smith/genfilelist \ + $RPM_BUILD_ROOT > %{name}-%{version}-%{release}-filelist +echo "%doc CHANGELOG.git" >> %{name}-%{version}-%{release}-filelist + +%files -f %{name}-%{version}-%{release}-filelist + +%clean +rm -rf $RPM_BUILD_ROOT + +%post + +%postun + + diff --git a/root/etc/e-smith/db/configuration/defaults/phpmyadmin/access b/root/etc/e-smith/db/configuration/defaults/phpmyadmin/access new file mode 100644 index 0000000..3e18ebf --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/phpmyadmin/access @@ -0,0 +1 @@ +private diff --git a/root/etc/e-smith/db/configuration/defaults/phpmyadmin/status b/root/etc/e-smith/db/configuration/defaults/phpmyadmin/status new file mode 100644 index 0000000..86981e6 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/phpmyadmin/status @@ -0,0 +1 @@ +enabled diff --git a/root/etc/e-smith/db/configuration/defaults/phpmyadmin/type b/root/etc/e-smith/db/configuration/defaults/phpmyadmin/type new file mode 100644 index 0000000..1b93c9e --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/phpmyadmin/type @@ -0,0 +1 @@ +webapp diff --git a/root/etc/e-smith/events/actions/ipasserelle-pma-init-domain b/root/etc/e-smith/events/actions/ipasserelle-pma-init-domain new file mode 100644 index 0000000..711afdd --- /dev/null +++ b/root/etc/e-smith/events/actions/ipasserelle-pma-init-domain @@ -0,0 +1,29 @@ +#!/usr/bin/perl -w + +use strict; +use warnings; +use esmith::DomainsDB; +use esmith::ConfigDB; + +my $d = esmith::DomainsDB->open or die "Couldn't open DomainsDB\n"; +my $c = esmith::ConfigDB->open_ro() or die "Couldn't open ConfigDB\n"; + +my $domain = $c->get('DomainName')->value; + +my $vhost = $d->get("sql.$domain"); + +exit(0) if ($vhost); + + +$d->new_record("sql.$domain",{ + type => 'domain', + Description => 'phpMyAdmin', + Content => 'Primary', + TemplatePath => 'WebAppVirtualHost', + DocumentRoot => '/usr/share/phpMyAdmin', + Authentication => 'LemonLDAP', + RequireSSL => 'yes' +}); + +die "Failed to create domain sql.$domain\n" + unless ( system("/sbin/e-smith/signal-event", "domain-create" , "sql.$domain") == 0 ); diff --git a/root/etc/e-smith/templates.metadata/etc/phpMyAdmin/config.inc.php b/root/etc/e-smith/templates.metadata/etc/phpMyAdmin/config.inc.php new file mode 100644 index 0000000..b916d35 --- /dev/null +++ b/root/etc/e-smith/templates.metadata/etc/phpMyAdmin/config.inc.php @@ -0,0 +1,3 @@ +UID="root" +GID="www" +PERMS=0640 diff --git a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98phpMyAdmin b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98phpMyAdmin new file mode 100644 index 0000000..1f8a3fa --- /dev/null +++ b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98phpMyAdmin @@ -0,0 +1,28 @@ +{ + +my $status = $phpmyadmin{'status'} || 'disabled'; + +if ($status eq 'enabled'){ + + my $access = (($phpmyadmin{'access'} || 'private') eq 'public') ? 'all':"$localAccess $externalSSLAccess"; + +$OUT .=<<"END"; + + + SSLRequireSSL + Options -Indexes + AllowOverride None + order deny,allow + deny from all + allow from $access + AddType application/x-httpd-php .php .php3 + php_admin_value openbase_dir /usr/share/phpMyAdmin:/etc/phpMyAdmin:/var/lib/phpMyAdmin + + +END +} +else { + $OUT .= "# phpmyadmin is disabled"; +} + +} diff --git a/root/etc/e-smith/templates/etc/phpMyAdmin/config.inc.php/10All b/root/etc/e-smith/templates/etc/phpMyAdmin/config.inc.php/10All new file mode 100644 index 0000000..f6bab91 --- /dev/null +++ b/root/etc/e-smith/templates/etc/phpMyAdmin/config.inc.php/10All @@ -0,0 +1,31 @@ +{ +use esmith::util; + +# MySQL uses the same password as LDAP +our $pw = esmith::util::LdapPassword(); + +$OUT .= ''; + +} + +/* Servers configuration */ +$i = 0; + +/* Server: iPasserelle [1] */ +$i++; +$cfg['Servers'][$i]['verbose'] = 'iPasserelle'; +$cfg['Servers'][$i]['host'] = 'localhost'; +$cfg['Servers'][$i]['port'] = ''; +$cfg['Servers'][$i]['socket'] = '/var/lib/mysql/mysql.sock'; +$cfg['Servers'][$i]['connect_type'] = 'socket'; +$cfg['Servers'][$i]['extension'] = 'mysqli'; +$cfg['Servers'][$i]['auth_type'] = 'config'; +$cfg['Servers'][$i]['user'] = 'root'; +$cfg['Servers'][$i]['password'] = '{$pw}'; + +/* End of servers configuration */ + +$cfg['DefaultLang'] = 'fr'; +$cfg['ServerDefault'] = 1; +$cfg['UploadDir'] = '/var/lib/phpMyAdmin/upload'; +$cfg['SaveDir'] = '/var/lib/phpMyAdmin/save'; diff --git a/root/etc/e-smith/templates/var/lib/lemonldap-ng/conf/lmConf/075phpMyadmin b/root/etc/e-smith/templates/var/lib/lemonldap-ng/conf/lmConf/075phpMyadmin new file mode 100644 index 0000000..b996223 --- /dev/null +++ b/root/etc/e-smith/templates/var/lib/lemonldap-ng/conf/lmConf/075phpMyadmin @@ -0,0 +1,28 @@ +{ + +$conf->{'exportedHeaders'}->{"sql.$domain"} = { + 'Auth-User' => '$uid', +} unless ($conf->{'exportedHeaders'}->{"sql.$domain"}); + + +$conf->{'locationRules'}->{"sql.$domain"} = { + 'default' => '$groups =~ /\\badmins\\b/', +} unless ($conf->{'locationRules'}->{"sql.$domain"}); + + +$conf->{'applicationList'}->{'030admin'}->{'phpmyadmin'} = { + 'options' => { + 'logo' => 'database.png', + 'name' => 'Gestionnaire de base de donnée', + 'description' => 'phpMyAdmin', + 'uri' => "https://sql.$domain", + 'display' => 'auto' + }, + 'type' => 'application' +} unless ($conf->{'applicationList'}->{'030admin'}->{'phpmyadmin'}); + + +$OUT = ''; + +} +