From 688dd2adf2c301603921ccccf6ef65215031d5e9 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Fri, 8 Nov 2013 10:51:54 +0100 Subject: [PATCH] Fix and add a lot of templates --- createlinks | 11 +++++ .../etc/e-smith/sql/init/limesurvey | 1 + .../share/limesurvey/application/config/config.php | 3 ++ .../templates/etc/e-smith/sql/init/limesurvey | 47 +++++++++++++++++++++ .../etc/httpd/conf/httpd.conf/98LimeSurvey | 35 ++++++---------- .../conf/httpd.conf/VirtualHosts/60LimeSurveySSL | 2 +- .../application/config/config.php/10BasePath | 1 + .../application/config/config.php/20Conf | 39 ++++++++++++++++++ .../application/config/config.php/25ProfileHook | 48 ++++++++++++++++++++++ 9 files changed, 164 insertions(+), 23 deletions(-) create mode 100644 createlinks create mode 100644 root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/limesurvey create mode 100644 root/etc/e-smith/templates.metadata/usr/share/limesurvey/application/config/config.php create mode 100644 root/etc/e-smith/templates/etc/e-smith/sql/init/limesurvey create mode 100644 root/etc/e-smith/templates/usr/share/limesurvey/application/config/config.php/10BasePath create mode 100644 root/etc/e-smith/templates/usr/share/limesurvey/application/config/config.php/20Conf create mode 100644 root/etc/e-smith/templates/usr/share/limesurvey/application/config/config.php/25ProfileHook diff --git a/createlinks b/createlinks new file mode 100644 index 0000000..8f7306b --- /dev/null +++ b/createlinks @@ -0,0 +1,11 @@ +#!/usr/bin/perl -w + +use esmith::Build::CreateLinks qw(:all); + +# Templates to expand +templates2events("/etc/e-smith/sql/init/opensondage", qw(bootstrap-console-save webapps-update)); +templates2events("/usr/share/limesurvey/application/config/config.php", qw(bootstrap-console-save webapps-update)); + +safe_symlink("/etc/e-smith/templates-default/template-begin-php", "root/etc/e-smith/templates/usr/share/limesurvey/application/config/config.php/template-begin"); +safe_symlink("/etc/e-smith/templates-default/template-end-php", "root/etc/e-smith/templates/usr/share/limesurvey/application/config/config.php/template-end"); + diff --git a/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/limesurvey b/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/limesurvey new file mode 100644 index 0000000..6bbf39b --- /dev/null +++ b/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/limesurvey @@ -0,0 +1 @@ +PERMS=0755 diff --git a/root/etc/e-smith/templates.metadata/usr/share/limesurvey/application/config/config.php b/root/etc/e-smith/templates.metadata/usr/share/limesurvey/application/config/config.php new file mode 100644 index 0000000..6f387e7 --- /dev/null +++ b/root/etc/e-smith/templates.metadata/usr/share/limesurvey/application/config/config.php @@ -0,0 +1,3 @@ +PERMS=0660 +UID="root" +GID="www" diff --git a/root/etc/e-smith/templates/etc/e-smith/sql/init/limesurvey b/root/etc/e-smith/templates/etc/e-smith/sql/init/limesurvey new file mode 100644 index 0000000..55c43d1 --- /dev/null +++ b/root/etc/e-smith/templates/etc/e-smith/sql/init/limesurvey @@ -0,0 +1,47 @@ +{ +my $db = ${'limesurvey'}{'DbName'} || 'limesurvey'; +my $user = ${'limesurvey'}{'DbUser'} || 'limesurvey'; +my $pass = ${'limesurvey'}{'DbPassword'} || 'secret'; + +my $schema = "/usr/share/limesurvey/installer/sql/create-mysql.sql"; + +$OUT .= <<"END"; +#! /bin/sh +if [ ! -d /var/lib/mysql/$db ]; then + /usr/bin/mysql -e 'create database $db' + cat $schema | perl -pe 's/prefix_//g' | /usr/bin/mysql $db +fi + + +/usr/bin/mysql < - AllowOverride None + + Options None + Options +FollowSymLinks + AllowOverride All SSLRequireSSL on AddType application/x-httpd-php .php php_admin_value open_basedir /usr/share/limesurvey:/var/lib/limesurvey @@ -33,28 +39,13 @@ $alias 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 + $auth - + Deny from all - + END } 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 index e6e79b9..8df56bb 100644 --- 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 @@ -6,7 +6,7 @@ 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"; + $OUT .= " RewriteRule ^/limesurvey/admin(/.*|\$) https://%{HTTP_HOST}/limesurvey/admin\$1 \[L,R\]\n"; } } diff --git a/root/etc/e-smith/templates/usr/share/limesurvey/application/config/config.php/10BasePath b/root/etc/e-smith/templates/usr/share/limesurvey/application/config/config.php/10BasePath new file mode 100644 index 0000000..183fa38 --- /dev/null +++ b/root/etc/e-smith/templates/usr/share/limesurvey/application/config/config.php/10BasePath @@ -0,0 +1 @@ +if (!defined('BASEPATH')) exit('No direct script access allowed'); diff --git a/root/etc/e-smith/templates/usr/share/limesurvey/application/config/config.php/20Conf b/root/etc/e-smith/templates/usr/share/limesurvey/application/config/config.php/20Conf new file mode 100644 index 0000000..bff5057 --- /dev/null +++ b/root/etc/e-smith/templates/usr/share/limesurvey/application/config/config.php/20Conf @@ -0,0 +1,39 @@ +return array( + 'basePath' => dirname(dirname(__FILE__)), + 'runtimePath' => dirname(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.'runtime', + 'name' => 'LimeSurvey', + 'defaultController' => 'survey', + 'import' => array( + 'application.core.*', + 'application.models.*', + 'application.controllers.*', + 'application.modules.*', + ), + 'components' => array( + 'db' => array( + 'connectionString' => 'mysql:unix_socket=/var/lib/mysql/mysql.sock;dbname={$limesurevey{'DbName'} || 'limesurvey'};', + 'emulatePrepare' => true, + 'username' => '{$limesurevey{'DbUser'} || 'limesurvey'}', + 'password' => '{$limesurevey{'DbPassword'} || 'limesurvey'}', + 'charset' => 'utf8', + 'tablePrefix' => '', + ), + 'urlManager' => array( + 'urlFormat' => 'path', + 'rules' => require('routes.php'), + 'showScriptName' => true, + ), + + ), + 'config'=>array( + 'debug'=>0, + 'debugsql'=>0, + 'auth_webserver' => true, + 'auth_webserver_autocreate_user' => true, + 'siteadminemail' => 'admin@'.{$DomainName}, + 'emailmethod' => 'smtp', + 'protocol' => 'smtp', + 'emailsmtphost' => 'localhost', + ) +); + diff --git a/root/etc/e-smith/templates/usr/share/limesurvey/application/config/config.php/25ProfileHook b/root/etc/e-smith/templates/usr/share/limesurvey/application/config/config.php/25ProfileHook new file mode 100644 index 0000000..160f5c4 --- /dev/null +++ b/root/etc/e-smith/templates/usr/share/limesurvey/application/config/config.php/25ProfileHook @@ -0,0 +1,48 @@ +{ + +my $lang = $sysconfig{'Language'} || 'en_US'; +$lang = substr $lang, 0, 2; + +$OUT .=<<"EOF"; + +function hook_get_auth_webserver_profile(\$user_name) { + if (!isset(\$_SERVER['REMOTE_USER'])){ + return false; + } + \$login = \$_SERVER['REMOTE_USER']; + if (isset(\$_SERVER['HTTP_USER_NAME'])){ + \$name = \$_SERVER['HTTP_USER_NAME']; + } + else{ + \$name = \$login; + } + if (isset(\$_SERVER['HTTP_USER_EMAIL'])){ + \$email = \$_SERVER['HTTP_USER_EMAIL']; + } + else{ + \$email = \$login . '\@$DomainName'; + } + if (isset(\$_SERVER['HTTP_USER_GROUPS']) && in_array('admins', preg_split("/; /", \$_SERVER['HTTP_USER_GROUPS']))){ + \$admin = 1; + } + else{ + \$admin = 0; + } + return Array( + 'full_name' => \$name, + 'email' => \$email, + 'lang' => '$lang', + 'htmleditormode' => 'inline', + 'templatelist' => 'default,basic,MyOrgTemplate', + 'create_survey' => 1, + 'create_user' => \$admin, + 'delete_user' => \$admin, + 'superadmin' => \$admin, + 'configurator' => \$admin, + 'manage_template' => \$admin, + 'manage_label' => \$admin + ); +} + +EOF +}