1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/dotclear2_ynh.git synced 2024-09-03 18:26:29 +02:00

Add_config

This commit is contained in:
ericgaspar 2021-07-19 15:44:24 +02:00
parent 4840a385e3
commit edaeb5df7e
No known key found for this signature in database
GPG key ID: 574F281483054D44
5 changed files with 104 additions and 36 deletions

93
conf/config.php.in Normal file
View file

@ -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);
//}

View file

@ -14,7 +14,7 @@
"email": "pierre@kayou.io"
},
"requirements": {
"yunohost": ">= 3.7.1"
"yunohost": ">= 4.2.0"
},
"multi_instance": true,
"services": [

View file

@ -4,6 +4,8 @@
# COMMON VARIABLES
#=================================================
YNH_PHP_VERSION="7.3"
#=================================================
# PERSONAL HELPERS
#=================================================

View file

@ -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

View file

@ -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