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