diff --git a/scripts/_common.sh b/scripts/_common.sh index 41497ad..22182d5 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,7 +8,7 @@ pkg_dependencies="cmake imagemagick ghostscript curl libmagickwand-dev git libpq-dev redis-server postgresql" build_pkg_dependencies="libffi-dev libgdbm-dev libncurses5-dev libyaml-dev pkg-config sqlite3 libgmp-dev libssl-dev" -ruby_version=2.6.6 +ruby_version=2.7 nodejs_version=14 bundler_version=2.1.4 diff --git a/scripts/upgrade b/scripts/upgrade index c284833..cc09b42 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -42,7 +42,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { - # Restore it if the upgrade fails + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script @@ -101,6 +101,8 @@ if ! [ -d "$final_path/live" ]; then chown -R $app:www-data "$final_path" fi +ynh_secure_remove "$final_path/Experimental_helpers" + #================================================= # CREATE DEDICATED USER #================================================= @@ -112,10 +114,23 @@ ynh_system_user_create --username=$app --home_dir="$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/live" --keep="config/diaspora.yml config/database.yml" +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Upgrading source files..." --weight=1 + + tmpdir="$(mktemp -d)" + cp "$final_path/live/config/diaspora.yml" "$tmpdir/diaspora.yml" + cp "$final_path/live/config/database.yml" "$tmpdir/database.yml" + ynh_secure_remove --file="$final_path/live" + + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path/live" --keep="config/diaspora.yml config/database.yml" + + cp "$tmpdir/diaspora.yml" "$final_path/live/config/diaspora.yml" + cp "$tmpdir/database.yml" "$final_path/live/config/database.yml" + ynh_secure_remove --file="$tmpdir" +fi chmod 750 "$final_path" chmod -R o-rwx "$final_path" @@ -140,6 +155,19 @@ ynh_add_nginx_config #================================================= # SPECIFIC UPGRADE +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a configuration file..." --weight=1 + +ynh_add_config --template="../conf/diaspora.yml" --destination="$final_path/live/config/diaspora.yml" +chmod 400 "$final_path/live/config/diaspora.yml" +chown $app:$app "$final_path/live/config/diaspora.yml" + +ynh_add_config --template="../conf/database.yml" --destination="$final_path/live/config/database.yml" +chmod 400 "$final_path/live/config/database.yml" +chown $app:$app "$final_path/live/config/database.yml" + #================================================= # BUILD APP #================================================= @@ -158,14 +186,6 @@ popd ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_package_autoremove -#================================================= -# UPDATE A CONFIG FILE -#================================================= -ynh_script_progression --message="Updating a configuration file..." --weight=1 - -ynh_add_config --template="../conf/diaspora.yml" --destination="$final_path/live/config/diaspora.yml" -ynh_add_config --template="../conf/database.yml" --destination="$final_path/live/config/database.yml" - #================================================= # SETUP SYSTEMD #=================================================