mirror of
https://github.com/YunoHost-Apps/limesurvey_ynh.git
synced 2024-09-03 19:36:32 +02:00
[fix] https://github.com/YunoHost-Apps/limesurvey_ynh/issues/24 using config.php
[fix] partially https://github.com/YunoHost-Apps/limesurvey_ynh/issues/25 using an alt user for super-super-admin [dev] Add a activatePlugin (to manage ls via a ynh plugin (when i done it) [dev] Little fix on installer (warning when testing files in patch directory) [dev] Using LimeSurvey install command for installing
This commit is contained in:
parent
d065dbbb32
commit
b02660cf9d
5 changed files with 21 additions and 127 deletions
|
@ -56,7 +56,12 @@ return array(
|
|||
// LimeSurvey developers: Set this to 2 to additionally display STRICT PHP error messages and get full access to standard templates
|
||||
'debug'=>0,
|
||||
'debugsql'=>0, // Set this to 1 to enanble sql logging, only active when debug = 2
|
||||
'enableLdap'=>true
|
||||
/* yunohost part */
|
||||
'auth_webserver_user_map' => array( '{{ admin }}'=>'ynh_admin'),// Primary user as ynh admin
|
||||
'auth_webserver_autocreate_user'=>1,
|
||||
'auth_webserver_autocreate_permissions'=>array(
|
||||
'superadmin' => array('create'=>true,'read'=>true,'update'=>true,'delete'=>true),
|
||||
),
|
||||
)
|
||||
);
|
||||
/* End of file config.php */
|
||||
|
|
|
@ -6,13 +6,7 @@ INSERT INTO `lime_plugins` (`id`, `name`, `active`) VALUES
|
|||
(6,'extendedStartPage',0),
|
||||
(7,'ExportSTATAxml',0),
|
||||
(8,'QuickMenu',0),
|
||||
(9,'AuthLDAP',0);
|
||||
|
||||
INSERT INTO `lime_permissions` (`id`, `entity`, `entity_id`, `uid`, `permission`, `create_p`, `read_p`, `update_p`, `delete_p`, `import_p`, `export_p`) VALUES
|
||||
(1,'global',0,1,'superadmin',0,1,0,0,0,0),
|
||||
(2,'global',0,2,'auth_ldap',0,1,0,0,0,0),
|
||||
(3,'global',0,2,'surveys',1,0,0,0,0,0);
|
||||
|
||||
(9,'AuthLDAP',1);
|
||||
|
||||
INSERT INTO `lime_plugin_settings` (`id`, `plugin_id`, `model`, `model_id`, `key`, `value`) VALUES
|
||||
(1,9,NULL,NULL,'server','\"ldap:\\/\\/localhost\"'),
|
||||
|
@ -41,7 +35,12 @@ INSERT INTO `lime_plugin_settings` (`id`, `plugin_id`, `model`, `model_id`, `key
|
|||
|
||||
INSERT INTO `lime_settings_global` VALUES ('defaultlang','{{ language }}'),('AssetsVersion','2620');
|
||||
|
||||
INSERT INTO `lime_users` VALUES (1,'{{ admin }}','9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08','Administrator',0,'{{ language }}','','default','default','default',NULL,1,'2017-02-02 01:03:08',NULL);
|
||||
INSERT INTO `lime_users` VALUES (2,'{{ admin }}','9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08','Administrator',0,'{{ language }}','','default','default','default',NULL,1,'2017-02-02 01:03:08',NULL);
|
||||
|
||||
INSERT INTO `lime_permissions` (`id`, `entity`, `entity_id`, `uid`, `permission`, `create_p`, `read_p`, `update_p`, `delete_p`, `import_p`, `export_p`) VALUES
|
||||
(2,'global',0,2,'superadmin',0,1,0,0,0,0),
|
||||
(3,'global',0,2,'auth_ldap',0,1,0,0,0,0),
|
||||
(4,'global',0,2,'auth_webserver',0,1,0,0,0,0);
|
||||
|
||||
{% if is_public == "1" %}
|
||||
UPDATE `lime_plugin_settings` SET value='\"0\"' WHERE `id`=21;
|
||||
|
|
|
@ -1,106 +0,0 @@
|
|||
From 7ca49326dafe4d9896e67aebe414edcd3ce8c1af Mon Sep 17 00:00:00 2001
|
||||
From: Denis Chenu <denis@sondages.pro>
|
||||
Date: Thu, 19 Jan 2017 00:02:45 +0100
|
||||
Subject: [PATCH] [feature] Allow update via PHP cli
|
||||
|
||||
---
|
||||
application/commands/UpdateCommand.php | 90 ++++++++++++++++++++++++++++++++++
|
||||
1 files changed, 90 insertions(+)
|
||||
create mode 100644 application/commands/UpdateCommand.php
|
||||
|
||||
diff --git a/application/commands/UpdateCommand.php b/application/commands/UpdateCommand.php
|
||||
new file mode 100644
|
||||
index 0000000..41ef107
|
||||
--- /dev/null
|
||||
+++ b/application/commands/UpdateCommand.php
|
||||
@@ -0,0 +1,90 @@
|
||||
+<?php
|
||||
+ /*
|
||||
+ * @author Denis Chenu <denis@sondages.pro>
|
||||
+ * @license GPL v3
|
||||
+ * @version 0.1
|
||||
+ *
|
||||
+ * Copyright (C) 2017 Denis Chenu
|
||||
+ * This program is free software: you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU Affero General Public License as published by
|
||||
+ * the Free Software Foundation, either version 3 of the License, or
|
||||
+ * (at your option) any later version.
|
||||
+ *
|
||||
+ * This program is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+ * GNU General Public License for more details.
|
||||
+ *
|
||||
+ */
|
||||
+class UpdateCommand extends CConsoleCommand
|
||||
+{
|
||||
+ public function run(){
|
||||
+ $this->_setConfigs();
|
||||
+ $newDbVersion = (float)Yii::app()->getConfig('dbversionnumber');
|
||||
+ $currentDbVersion = (float)Yii::app()->getConfig('DBVersion');
|
||||
+ if($newDbVersion > $currentDbVersion){
|
||||
+ echo "Update ".Yii::app()->db->connectionString.", prefix :".Yii::app()->db->tablePrefix." from {$currentDbVersion} to {$newDbVersion}\n";
|
||||
+ Yii::import('application.helpers.common_helper', true);
|
||||
+ Yii::import('application.helpers.update.updatedb_helper', true);
|
||||
+ $result=db_upgrade_all($currentDbVersion);/* @todo : fix bad echoing here */
|
||||
+ if ($result) {
|
||||
+ //printf(gT("Database has been successfully upgraded to version %s"),$dbversionnumber)."\n";
|
||||
+ echo "Database has been successfully upgraded to version $newDbVersion \n";
|
||||
+ } else {
|
||||
+ //echo gT("Please fix this error in your database and try again")."\n";
|
||||
+ echo "Please fix this error in your database and try again\n";
|
||||
+ }
|
||||
+ } else {
|
||||
+ echo "no need update ".$newDbVersion ." ". $currentDbVersion ."\n";
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Fonction to set all needed (and unneeded) config
|
||||
+ * @return void
|
||||
+ */
|
||||
+ private function _setConfigs(){
|
||||
+ /* default config */
|
||||
+ $aDefaultConfigs = require(Yii::app()->basePath. DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config-defaults.php');
|
||||
+ foreach($aDefaultConfigs as $sConfig=>$defaultConfig){
|
||||
+ Yii::app()->setConfig($sConfig,$defaultConfig);
|
||||
+ }
|
||||
+ /* Fix for badly set rootdir */
|
||||
+ $sRootDir=realpath(Yii::app()->basePath. DIRECTORY_SEPARATOR . "..") ;
|
||||
+ Yii::app()->setConfig('rootdir',$sRootDir);
|
||||
+ Yii::app()->setConfig('publicdir',$sRootDir);
|
||||
+ Yii::app()->setConfig('homedir',$sRootDir);
|
||||
+ Yii::app()->setConfig('tempdir',$sRootDir.DIRECTORY_SEPARATOR."tmp");
|
||||
+ Yii::app()->setConfig('imagedir',$sRootDir.DIRECTORY_SEPARATOR."images");
|
||||
+ Yii::app()->setConfig('uploaddir',$sRootDir.DIRECTORY_SEPARATOR."upload");
|
||||
+ Yii::app()->setConfig('standardtemplaterootdir',$sRootDir.DIRECTORY_SEPARATOR."templates");
|
||||
+ Yii::app()->setConfig('usertemplaterootdir',$sRootDir.DIRECTORY_SEPARATOR."upload".DIRECTORY_SEPARATOR."templates");
|
||||
+ Yii::app()->setConfig('styledir',$sRootDir.DIRECTORY_SEPARATOR."styledir");
|
||||
+ /* version */
|
||||
+ $aVersionConfigs = require(Yii::app()->basePath. DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'version.php');
|
||||
+ foreach($aVersionConfigs as $sConfig=>$versionConfig){
|
||||
+ Yii::app()->setConfig($sConfig,$versionConfig);
|
||||
+ }
|
||||
+ /* LS 3 version */
|
||||
+ Yii::app()->setConfig('runtimedir',$sRootDir.DIRECTORY_SEPARATOR."tmp".DIRECTORY_SEPARATOR."runtime");
|
||||
+ if(file_exists(Yii::app()->basePath. DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'))
|
||||
+ {
|
||||
+ $config = require(Yii::app()->basePath. DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php');
|
||||
+ if(is_array($config['config']) && !empty($config['config']))
|
||||
+ {
|
||||
+ foreach($config['config'] as $key=>$value)
|
||||
+ Yii::app()->setConfig($key,$value);
|
||||
+ }
|
||||
+ }
|
||||
+ $oSettings=SettingGlobal::model()->findAll();
|
||||
+ if (count($oSettings) > 0)
|
||||
+ {
|
||||
+ foreach ($oSettings as $oSetting)
|
||||
+ {
|
||||
+ Yii::app()->setConfig($oSetting->getAttribute('stg_name'), $oSetting->getAttribute('stg_value'));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
+?>
|
|
@ -178,7 +178,7 @@ ynh_setup_source () {
|
|||
fi
|
||||
|
||||
# Apply patches
|
||||
if [ -f ${PKG_DIR}/patches/$SOURCE_ID-*.patch ]; then
|
||||
if [ $(find ${PKG_DIR}/patches/ -type f -name "$SOURCE_ID-*.patch" | wc -l) ]; then
|
||||
(cd "$DEST" \
|
||||
&& for p in ${PKG_DIR}/patches/$SOURCE_ID-*.patch; do \
|
||||
ynh_exec_as "$AS_USER" patch -p1 < $p; done) \
|
||||
|
|
|
@ -37,18 +37,14 @@ ynh_setup_source "$local_path" "$user"
|
|||
|
||||
ynh_configure config.php "$local_path/application/config/config.php"
|
||||
|
||||
# Fill LimeSurvey database @todo replace by command action from limesurvey
|
||||
sed "s/\`prefix_/\`$prefix/g" $local_path/installer/sql/create-mysql.sql > ./structure.sql
|
||||
mysql -u $db_user -p$db_pwd $db_user < ./structure.sql
|
||||
ynh_configure data.sql ./data.sql
|
||||
mysql -u $db_user -p$db_pwd $db_user < ./data.sql
|
||||
|
||||
# Randomize Password user
|
||||
ls_cli=$local_path/application/commands/console.php
|
||||
set +x
|
||||
ynh_exec_as "$user" php $ls_cli resetpassword "$admin" "$(ynh_string_random 24)"
|
||||
ynh_exec_as "$user" php $ls_cli install "ynh_admin" "$(ynh_string_random 24)" "Administrator" "$admin@$domain"
|
||||
set -x
|
||||
|
||||
# Setup^extra DB part (@todo : replace by a plugin system)
|
||||
ynh_configure data.sql ./data.sql
|
||||
mysql -u $db_user -p$db_pwd $db_user < ./data.sql
|
||||
# Set permissions
|
||||
ynh_set_default_perm $local_path
|
||||
sudo chmod -R u+w $local_path/tmp
|
||||
|
|
Loading…
Add table
Reference in a new issue