From 51d079571cc3a589439b9518cb9980581f404007 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 7 Feb 2021 11:01:22 +0100 Subject: [PATCH] Fix --- scripts/install | 23 +++++++++++------------ scripts/upgrade | 47 +++++++++++++++++++++++------------------------ 2 files changed, 34 insertions(+), 36 deletions(-) diff --git a/scripts/install b/scripts/install index dcf1d1b..5a2b8f4 100644 --- a/scripts/install +++ b/scripts/install @@ -50,31 +50,30 @@ admin_pwd=$(openssl passwd -1 -salt xyz $password) #================================================= ynh_script_progression --message="Storing installation settings..." -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app path $path_url -ynh_app_setting_set $app admin $admin -ynh_app_setting_set $app is_public $is_public -ynh_app_setting_set $app language $language +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=admin --value=$admin +ynh_app_setting_set --app=$app --key=is_public --value=$is_public +ynh_app_setting_set --app=$app --key=language --value=$language #================================================= # CREATE A MYSQL DATABASE #================================================= ynh_script_progression --message="Creating a MySQL database..." -db_name=$(ynh_sanitize_dbid $app) -ynh_app_setting_set $app db_name $db_name -ynh_mysql_setup_db $db_name $db_name +db_name=$(ynh_sanitize_dbid --db_name=$app) +db_user=$db_name +ynh_app_setting_set --app=$app --key=db_name --value=$db_name +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." -ynh_app_setting_set $app final_path $final_path +ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" -#Copy config.php to the final path -cp -r ../conf/config.php $final_path +ynh_setup_source --dest_dir="$final_path" #================================================= # NGINX CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index f1d8c35..4feed9c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,6 +24,12 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#================================================= +# CHECK VERSION +#================================================= + +upgrade_type=$(ynh_check_app_version_changed) + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -77,36 +83,28 @@ ynh_abort_if_errors # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -# Download, check integrity, uncompress and patch the source from app.src -# Create a temporary directory -tmpdir="$(ynh_smart_mktemp 300)" +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Upgrading source files..." --weight=1 -# Backup the config file in the temp dir -cp -a "$final_path/config.php" "$tmpdir/config.php" + # Create a temporary directory + tmpdir="$(mktemp -d)" -# Remove the app directory securely -ynh_secure_remove "$final_path" + # Backup the config file in the temp dir + cp -a "$final_path/config.php" "$tmpdir/config.php" -# If final_path doesn't exist, create it -if [ -z $final_path ]; then - final_path=/var/www/$app - ynh_app_setting_set $app final_path $final_path -fi + # Remove the app directory securely + ynh_secure_remove --file="$final_path" -#================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE -#================================================= -ynh_script_progression --message="Upgrading source files..." + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" + #copy cofig.php from tmp to final_path + cp -a "$tmpdir/config.php" "$final_path/config.php" - -#copy cofig.php from tmp to final_path -cp -a "$tmpdir/config.php" "$final_path" - -#remove tmp dir -ynh_secure_remove "$tmpdir" + # Remove the tmp directory securely + ynh_secure_remove --file="$tmpdir" +fi #================================================= # NGINX CONFIGURATION @@ -137,6 +135,7 @@ ynh_add_fpm_config #================================================= ynh_backup_if_checksum_is_different "$final_path/conf.php" + # Recalculate and store the config file checksum into the app settings ynh_store_file_checksum "$final_path/config.php"