From edaeb5df7e0214bbc9d22d563a363fa5fd10b10e Mon Sep 17 00:00:00 2001 From: ericgaspar <junk.eg@free.fr> Date: Mon, 19 Jul 2021 15:44:24 +0200 Subject: [PATCH] Add_config --- conf/config.php.in | 93 ++++++++++++++++++++++++++++++++++++++++++++++ manifest.json | 2 +- scripts/_common.sh | 2 + scripts/install | 20 ++-------- scripts/upgrade | 23 ++---------- 5 files changed, 104 insertions(+), 36 deletions(-) create mode 100644 conf/config.php.in diff --git a/conf/config.php.in b/conf/config.php.in new file mode 100644 index 0000000..ee7b65a --- /dev/null +++ b/conf/config.php.in @@ -0,0 +1,93 @@ +<?php +/** + * @package Dotclear + * + * @copyright Olivier Meunier & Association Dotclear + * @copyright GPL-2.0-only + */ + +if (!defined('DC_RC_PATH')) {return;} + +// Database driver (mysql (deprecated, disabled in PHP7), mysqli, mysqlimb4 (full UTF-8), pgsql, sqlite) +define('DC_DBDRIVER', 'mysqli'); + +// Database hostname (usually "localhost") +define('DC_DBHOST', 'localhost'); + +// Database user +define('DC_DBUSER', '__DB_USER__'); + +// Database password +define('DC_DBPASSWORD', '__DB_PASSWORD__'); + +// Database name +define('DC_DBNAME', '__DB_NAME__'); + +// Tables' prefix +define('DC_DBPREFIX', 'dc_'); + +// Persistent database connection +define('DC_DBPERSIST', false); + +// Crypt key (password storage) +define('DC_MASTER_KEY', '__MASTER_KEY__'); + +// Admin URL. You need to set it for some features. +define('DC_ADMIN_URL', 'https://__DOMAIN____ADMIN_URL__'); + +// Admin mail from address. For password recovery and such. +define('DC_ADMIN_MAILFROM', '__EMAIL__'); + +// Cookie's name +define('DC_SESSION_NAME', 'dcxd'); + +// Session TTL +//define('DC_SESSION_TTL','120 seconds'); + +// Plugins root +define('DC_PLUGINS_ROOT', dirname(__FILE__) . '/../plugins'); + +// Template cache directory +define('DC_TPL_CACHE', path::real(dirname(__FILE__) . '/..') . '/cache'); + +// Var directory +define('DC_VAR', path::real(dirname(__FILE__) . '/..') . '/var'); + +// Cryptographic algorithm +define('DC_CRYPT_ALGO', 'sha512'); + +// Vendor name +//define('DC_VENDOR_NAME', 'Dotclear'); + +// Do not check for update +//define('DC_NOT_UPDATE', false); + +// Update URL +//define('DC_UPDATE_URL','https://download.dotclear.org/versions.xml'); + +// Update channel (stable, unstable, testing) +//define('DC_UPDATE_VERSION', 'stable'); + +// Proxy config +//define('HTTP_PROXY_HOST','127.0.0.1'); +//define('HTTP_PROXY_PORT','8080'); + +// Reverse Proxy +//define('DC_REVERSE_PROXY',false); + +// Show hidden media dirs +//define('DC_SHOW_HIDDEN_DIRS', false); + +// If you have PATH_INFO issue, uncomment following lines +//if (!isset($_SERVER['ORIG_PATH_INFO'])) { +// $_SERVER['ORIG_PATH_INFO'] = ''; +//} +//$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; + +// If you have mail problems, uncomment following lines and adapt it to your hosting configuration +// For more information about this setting, please refer to http://doc.dotclear.net/2.0/admin/install/custom-sendmail +//function _mail($to, $subject, $message, $headers) +//{ +// socketMail::$smtp_relay = 'my.smtp.relay.org'; +// socketMail::mail($to, $subject, $message, $headers); +//} diff --git a/manifest.json b/manifest.json index 3b0e5eb..aa0dcfd 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "email": "pierre@kayou.io" }, "requirements": { - "yunohost": ">= 3.7.1" + "yunohost": ">= 4.2.0" }, "multi_instance": true, "services": [ diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..d7614e9 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,6 +4,8 @@ # COMMON VARIABLES #================================================= +YNH_PHP_VERSION="7.3" + #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index a143271..3899bf4 100755 --- a/scripts/install +++ b/scripts/install @@ -113,25 +113,15 @@ php_config=$final_path/inc/config.php master_key=$(ynh_string_random --length=30) ynh_app_setting_set --app=$app --key=master_key --value=$master_key -cp $php_config.in $php_config - admin_url="${path_url%/}/admin/index.php" - +file=__FILE__ email=$(ynh_user_get_info --username=$admin --key=mail) # Config as if we called in admin/install/wizard.php -ynh_replace_string --match_string="'DC_DBDRIVER', ''" --replace_string="'DC_DBDRIVER', 'mysqli'" --target_file=$php_config -ynh_replace_string --match_string="'DC_DBHOST', ''" --replace_string="'DC_DBHOST', 'localhost'" --target_file=$php_config -ynh_replace_string --match_string="'DC_DBUSER', ''" --replace_string="'DC_DBUSER', '$db_user'" --target_file=$php_config -ynh_replace_string --match_string="'DC_DBPASSWORD', ''" --replace_string="'DC_DBPASSWORD', '$db_pwd'" --target_file=$php_config -ynh_replace_string --match_string="'DC_DBNAME', ''" --replace_string="'DC_DBNAME', '$db_name'" --target_file=$php_config -ynh_replace_string --match_string="'DC_MASTER_KEY', ''" --replace_string="'DC_MASTER_KEY', '$master_key'" --target_file=$php_config -ynh_replace_string --match_string="'DC_ADMIN_URL', ''" --replace_string="'DC_ADMIN_URL', 'https://$domain$admin_url'" --target_file=$php_config -ynh_replace_string --match_string="'DC_ADMIN_MAILFROM', ''" --replace_string="'DC_ADMIN_MAILFROM', '$email'" --target_file=$php_config +ynh_add_config --template="../conf/config.php.in" --destination="$php_config" # Adding LDAP login -cp ../conf/class.auth.ldap.php $final_path/inc/class.auth.ldap.php -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$final_path/inc/class.auth.ldap.php" +ynh_add_config --template="../conf/class.auth.ldap.php" --destination="$final_path/inc/class.auth.ldap.php" cat << EOF >> $php_config @@ -139,10 +129,8 @@ cat << EOF >> $php_config define('DC_AUTH_CLASS','ldapDcAuth'); EOF -ynh_store_file_checksum --file=$php_config - chmod 400 "$php_config" -chown $app:$app "$php_config" +chown $app "$php_config" #================================================= # SETUP APPLICATION WITH CURL diff --git a/scripts/upgrade b/scripts/upgrade index e334b50..3889ee0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -143,27 +143,15 @@ ynh_script_progression --message="Updating a configuration file..." php_config=$final_path/inc/config.php -ynh_backup_if_checksum_is_different --file=$php_config - -cp $php_config.in $php_config - admin_url="${path_url%/}/admin/index.php" - +file=__FILE__ email=$(ynh_user_get_info --username=$admin --key=mail) # Config as if we called in admin/install/wizard.php -ynh_replace_string --match_string="'DC_DBDRIVER', ''" --replace_string="'DC_DBDRIVER', 'mysqli'" --target_file=$php_config -ynh_replace_string --match_string="'DC_DBHOST', ''" --replace_string="'DC_DBHOST', 'localhost'" --target_file=$php_config -ynh_replace_string --match_string="'DC_DBUSER', ''" --replace_string="'DC_DBUSER', '$db_user'" --target_file=$php_config -ynh_replace_string --match_string="'DC_DBPASSWORD', ''" --replace_string="'DC_DBPASSWORD', '$db_pwd'" --target_file=$php_config -ynh_replace_string --match_string="'DC_DBNAME', ''" --replace_string="'DC_DBNAME', '$db_name'" --target_file=$php_config -ynh_replace_string --match_string="'DC_MASTER_KEY', ''" --replace_string="'DC_MASTER_KEY', '$master_key'" --target_file=$php_config -ynh_replace_string --match_string="'DC_ADMIN_URL', ''" --replace_string="'DC_ADMIN_URL', 'https://$domain$admin_url'" --target_file=$php_config -ynh_replace_string --match_string="'DC_ADMIN_MAILFROM', ''" --replace_string="'DC_ADMIN_MAILFROM', '$email'" --target_file=$php_config +ynh_add_config --template="../conf/config.php.in" --destination="$php_config" # Adding LDAP login -cp ../conf/class.auth.ldap.php $final_path/inc/class.auth.ldap.php -ynh_replace_string "__APP__" "$app" $final_path/inc/class.auth.ldap.php +ynh_add_config --template="../conf/class.auth.ldap.php" --destination="$final_path/inc/class.auth.ldap.php" cat << EOF >> $php_config @@ -171,11 +159,8 @@ cat << EOF >> $php_config define('DC_AUTH_CLASS','ldapDcAuth'); EOF -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file=$php_config - chmod 400 "$php_config" -chown $app:$app "$php_config" +chown $app "$php_config" #================================================= # UPDATING DATABASE