diff --git a/conf/settings.php b/conf/settings.php index 60a1441..20660a8 100644 --- a/conf/settings.php +++ b/conf/settings.php @@ -12,7 +12,7 @@ $port = 3306; $encoding = "utf8"; @date_default_timezone_set($_SESSION['settings']['timezone']); -@define('SECUREPATH', '__PATH_SK_FILE__'); -if (file_exists("__PATH_SK_FILE__sk.php")) { - require_once "__PATH_SK_FILE__sk.php"; +@define('SECUREPATH', '/etc/__APP__/'); +if (file_exists("/etc/__APP__/sk.php")) { + require_once "/etc/__APP__/sk.php"; } diff --git a/scripts/install b/scripts/install index 030761f..bb0e5e9 100644 --- a/scripts/install +++ b/scripts/install @@ -158,9 +158,6 @@ echo ");" >> $tp_config_file #================================================= ynh_script_progression --message="Adding a configuration file..." -path_sk_file=/etc/$app/ -mkdir $path_sk_file - ynh_add_config --template="../conf/settings.php" --destination="$final_path/includes/config/settings.php" #================================================= @@ -169,15 +166,15 @@ ynh_add_config --template="../conf/settings.php" --destination="$final_path/incl ynh_script_progression --message="Creating a saltkey..." saltkey=$(ynh_string_random --length=32) -ynh_replace_string "__SALTKEY__" "$saltkey" ../conf/sk.php -ynh_add_config --template="../conf/sk.php" --destination="$path_sk_file/sk.php" +mkdir /etc/$app/ +ynh_add_config --template="../conf/sk.php" --destination="/etc/$app/sk.php" +chown -R $app /etc/$app/ +chmod 750 /etc/$app/ #================================================= -# COPY THE FILES +# CREATE CSRFP #================================================= - -chown -R $app $path_sk_file -chmod 750 $path_sk_file +ynh_script_progression --message="Creating a csrfp..." cp $final_path/includes/libraries/csrfp/libs/csrfp.config.sample.php $final_path/includes/libraries/csrfp/libs/csrfp.config.php # Créer le fichier de config de csrfp ynh_replace_string "CSRFP_TOKEN\" => \"" "&$(head -n40 /dev/urandom | tr -c -d 'a-f0-9' | head -c50)" $final_path/includes/libraries/csrfp/libs/csrfp.config.php # Renseigne un token, valide en hexadécimal @@ -213,7 +210,6 @@ ynh_replace_string "jsUrl\" => \"" "&includes/libraries/csrfp/js/csrfprotector.j ynh_script_progression --message="Creating a cron file for an automatic backup..." echo "0 0 * * 0 $app cd $final_path/backups && php script.backup.php" > /etc/cron.d/$app -# Add also a clean of old backup. #================================================= # SECURING FILES AND DIRECTORIES diff --git a/scripts/upgrade b/scripts/upgrade index 35008c9..5e46afd 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -87,9 +87,8 @@ then # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" - # Delete the install directory. - # Keep it for the manual upgrade process... -# ynh_secure_remove "$final_path/install" + # Do not delete the install directory. Keep it for the manual upgrade process... + # ynh_secure_remove "$final_path/install" fi chmod 750 "$final_path" @@ -103,6 +102,7 @@ ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # NGINX CONFIGURATION @@ -133,18 +133,13 @@ do done <<< "$(ynh_mysql_execute_as_root "SELECT intitule, valeur FROM teampass_misc" $app)" echo ");" >> $tp_config_file -#================================================= -# CREATE A CRON FILE FOR AUTOMATIC BACKUP -#================================================= -ynh_script_progression --message="Creating a cron file for an automatic backup..." - -echo "0 0 * * 0 $app cd $final_path/backups && php script.backup.php" > /etc/cron.d/$app - #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Updating a configuration file..." +ynh_add_config --template="../conf/settings.php" --destination="$final_path/includes/config/settings.php" + if [ "$upgrade_type" == "UPGRADE_APP" ] then # Move settings.php from old teampass version @@ -173,12 +168,11 @@ then fi #================================================= -# UPDATE SETTINGS.PHP +# CREATE A CRON FILE FOR AN AUTOMATIC BACKUP #================================================= +ynh_script_progression --message="Creating a cron file for an automatic backup..." -path_sk_file="/etc/$app/" - -ynh_add_config --template="../conf/settings.php" --destination="$final_path/includes/config/settings.php" +echo "0 0 * * 0 $app cd $final_path/backups && php script.backup.php" > /etc/cron.d/$app #================================================= # SECURING FILES AND DIRECTORIES