From 1fafc841988d34900bb80648d8cb06f0544f19df Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 7 Nov 2013 17:01:52 +0100 Subject: [PATCH] initial commit --- .../e-smith/db/accounts/defaults/limesurvey/type | 1 + .../db/configuration/defaults/limesurvey/DbName | 1 + .../db/configuration/defaults/limesurvey/DbUser | 1 + .../db/configuration/defaults/limesurvey/status | 1 + .../db/configuration/defaults/limesurvey/type | 1 + .../db/configuration/migrate/limesurvey-database | 27 +++++++++ .../etc/httpd/conf/httpd.conf/98LimeSurvey | 64 ++++++++++++++++++++++ .../conf/httpd.conf/VirtualHosts/60LimeSurveySSL | 12 ++++ smeserver-limesurvey.spec | 49 +++++++++++++++++ 9 files changed, 157 insertions(+) create mode 100644 root/etc/e-smith/db/accounts/defaults/limesurvey/type create mode 100644 root/etc/e-smith/db/configuration/defaults/limesurvey/DbName create mode 100644 root/etc/e-smith/db/configuration/defaults/limesurvey/DbUser create mode 100644 root/etc/e-smith/db/configuration/defaults/limesurvey/status create mode 100644 root/etc/e-smith/db/configuration/defaults/limesurvey/type create mode 100644 root/etc/e-smith/db/configuration/migrate/limesurvey-database create mode 100644 root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98LimeSurvey create mode 100644 root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/60LimeSurveySSL create mode 100644 smeserver-limesurvey.spec diff --git a/root/etc/e-smith/db/accounts/defaults/limesurvey/type b/root/etc/e-smith/db/accounts/defaults/limesurvey/type new file mode 100644 index 0000000..96cdd3b --- /dev/null +++ b/root/etc/e-smith/db/accounts/defaults/limesurvey/type @@ -0,0 +1 @@ +url diff --git a/root/etc/e-smith/db/configuration/defaults/limesurvey/DbName b/root/etc/e-smith/db/configuration/defaults/limesurvey/DbName new file mode 100644 index 0000000..20d3733 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/limesurvey/DbName @@ -0,0 +1 @@ +limesurvey diff --git a/root/etc/e-smith/db/configuration/defaults/limesurvey/DbUser b/root/etc/e-smith/db/configuration/defaults/limesurvey/DbUser new file mode 100644 index 0000000..20d3733 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/limesurvey/DbUser @@ -0,0 +1 @@ +limesurvey diff --git a/root/etc/e-smith/db/configuration/defaults/limesurvey/status b/root/etc/e-smith/db/configuration/defaults/limesurvey/status new file mode 100644 index 0000000..86981e6 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/limesurvey/status @@ -0,0 +1 @@ +enabled diff --git a/root/etc/e-smith/db/configuration/defaults/limesurvey/type b/root/etc/e-smith/db/configuration/defaults/limesurvey/type new file mode 100644 index 0000000..1b93c9e --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/limesurvey/type @@ -0,0 +1 @@ +webapp diff --git a/root/etc/e-smith/db/configuration/migrate/limesurvey-database b/root/etc/e-smith/db/configuration/migrate/limesurvey-database new file mode 100644 index 0000000..93aab39 --- /dev/null +++ b/root/etc/e-smith/db/configuration/migrate/limesurvey-database @@ -0,0 +1,27 @@ +{ + my $rec = $DB->get('limesurvey') + || $DB->new_record('limesurvey', {type => 'webapp'}); + my $pw = $rec->prop('DbPassword'); + if (not $pw or length($pw) < 57){ + use MIME::Base64 qw(encode_base64); + + $pw = "not set due to error"; + if ( open( RANDOM, "/dev/urandom" ) ){ + my $buf; + # 57 bytes is a full line of Base64 coding, and contains + # 456 bits of randomness - given a perfectly random /dev/random + if ( read( RANDOM, $buf, 57 ) != 57 ){ + warn("Short read from /dev/random: $!"); + } + else{ + $pw = encode_base64($buf); + chomp $pw; + } + close RANDOM; + } + else{ + warn "Could not open /dev/urandom: $!"; + } + $rec->set_prop('DbPassword', $pw); + } +} diff --git a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98LimeSurvey b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98LimeSurvey new file mode 100644 index 0000000..e348d81 --- /dev/null +++ b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98LimeSurvey @@ -0,0 +1,64 @@ +{ +my $access = $limesurvey{'access'} || 'private'; +my $allow = ($access eq 'public')?'all':"$localAccess $externalSSLAccess"; + +my $alias = (($limesurvey{'AliasOnPrimary'} || 'enabled') eq 'enabled') ? + '':"Alias /limesurvey/tmp /var/lib/limesurvey/tmp\n" . + "Alias /limesurvey/upload /var/lib/limesurvey/upload\n" . + "Alias /limesurvey /usr/share/limesurvey"; + +if ($limesurvey{'status'} eq 'enabled'){ + +$OUT .=<<"END" + +# LimeSurvey Configuration +$alias + + + AllowOverride None + SSLRequireSSL on + AddType application/x-httpd-php .php + php_admin_value open_basedir /usr/share/limesurvey:/var/lib/limesurvey + php_admin_flag file_uploads On + php_admin_flag magic_quotes Off + php_admin_flag magic_quotes_gpc Off + php_admin_value upload_max_filesize 10M + php_admin_value post_max_size 12M + php_admin_value memory_limit 100M + php_admin_value max_execution_time 120 + php_admin_value upload_tmp_dir /var/lib/limesurvey/tmp + php_admin_value session.save_path /var/lib/limesurvey/sessions + order deny,allow + deny from all + allow from $allow + Satisfy all + + + AllowOverride None + SSLRequireSSL on + AddType application/x-httpd-php .php + php_admin_value open_basedir /usr/share/limesurvey:/var/lib/limesurvey + php_admin_flag file_uploads On + php_admin_flag magic_quotes Off + php_admin_flag magic_quotes_gpc Off + php_admin_value upload_max_filesize 10M + php_admin_value post_max_size 12M + php_admin_value memory_limit 100M + php_admin_value max_execution_time 120 + php_admin_value upload_tmp_dir /var/lib/limesurvey/tmp + php_admin_value session.save_path /var/lib/limesurvey/sessions + order deny,allow + deny from all + allow from $allow + Satisfy all + + + Deny from all + + +END +} +else{ + $OUT .= "# LimeSurvey is disabled\n"; +} +} diff --git a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/60LimeSurveySSL b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/60LimeSurveySSL new file mode 100644 index 0000000..e6e79b9 --- /dev/null +++ b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/60LimeSurveySSL @@ -0,0 +1,12 @@ +{ +my $sslport = $modSSL{'TCPPort'} || '443'; +my $status = $limesurvey{'status'} || 'enabled'; +my $alias = $limesurvey{'AliasOnPrimary'} || 'enabled'; + +if (($port ne $sslport) && ($status eq 'enabled') && ($alias eq 'enabled')){ + + ## Redirect Web Address to Secure Address + $OUT .= " RewriteRule ^/limesurvey(/.*|\$) https://%{HTTP_HOST}/limesurvey\$1 \[L,R\]\n"; + +} +} diff --git a/smeserver-limesurvey.spec b/smeserver-limesurvey.spec new file mode 100644 index 0000000..2c9224a --- /dev/null +++ b/smeserver-limesurvey.spec @@ -0,0 +1,49 @@ +%define name smeserver-limesurvey +%define version 0.1.0 +%define release 1.beta0 +Summary: SME server integration of limesurvey +Name: %{name} +Version: %{version} +Release: %{release}%{?dist} +License: GNU GPL version 2 +URL: http://www.limesurvey.org +Group: SMEserver/addon +Source: %{name}-%{version}.tar.gz + +BuildArchitectures: noarch +BuildRequires: e-smith-devtools +BuildRoot: /var/tmp/%{name}-%{version} +Requires: e-smith-base +Requires: limesurvey +Requires: smeserver-webapps-common +AutoReqProv: no + +%description +Integration of LimeSUrvey on SME Server + +%changelog +* Thu Nov 7 2013 Daniel Berteaud 0.1.0-1.sme +- First release + +%prep +%setup + +%build +#perl ./createlinks + +%install +rm -rf $RPM_BUILD_ROOT +(cd root ; find . -depth -print | cpio -dump $RPM_BUILD_ROOT) +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 + + +%postun +