From a9bd21abce952c41d92ae44deea834607ac46eb6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 12 Apr 2019 16:58:46 +0200 Subject: [PATCH] Add ynh_clean_check_starting --- manifest.json | 26 +++++++++++++------------- scripts/backup | 3 +++ scripts/install | 3 +++ scripts/remove | 3 +++ scripts/restore | 26 +++++++++++++++----------- scripts/upgrade | 5 +++-- 6 files changed, 40 insertions(+), 26 deletions(-) diff --git a/manifest.json b/manifest.json index efce3c5..cf3bdc5 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "A modern, convivial and free music server" }, - "version": "0.18.3~ynh1", + "version": "0.18.3~ynh2", "url": "https://funkwhale.audio", "license": "AGPL-3.0-or-later", "maintainer": { @@ -13,7 +13,7 @@ "email": "jean-baptiste@holcroft.fr" }, "requirements": { - "yunohost": ">= 3.3.0" + "yunohost": ">= 3.5" }, "multi_instance": true, "services": [ @@ -25,25 +25,25 @@ "name": "domain", "type": "domain", "ask": { - "en": "Choose a domain" + "en": "Choose a domain for funkwhale" }, - "example": "domain.fr" - }, - { - "name": "is_public", - "type": "boolean", - "ask": { - "en": "Should Funkwhale be publicly accessible?" - }, - "default": "0" + "example": "example.com" }, { "name": "admin", "type": "user", "ask": { - "en": "Choose an admin user for Funkwhale" + "en": "Choose an admin user" }, "example": "jibec" + }, + { + "name": "is_public", + "type": "boolean", + "ask": { + "en": "Is it a public application?" + }, + "default": true } ] } diff --git a/scripts/backup b/scripts/backup index f0b3ddb..2ed9f47 100644 --- a/scripts/backup +++ b/scripts/backup @@ -14,6 +14,9 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ynh_clean_check_starting +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors diff --git a/scripts/install b/scripts/install index 45a7b57..63b54d2 100644 --- a/scripts/install +++ b/scripts/install @@ -13,6 +13,9 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ynh_clean_check_starting +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors diff --git a/scripts/remove b/scripts/remove index 771ad7b..9ee1929 100644 --- a/scripts/remove +++ b/scripts/remove @@ -69,6 +69,9 @@ ynh_secure_remove "/etc/systemd/system/$app.target" #================================================= ynh_print_info "Removing the PostgreSQL database" +ynh_psql_execute_as_root "\connect $db_name +SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$db_name';" + # Remove a database if it exists, along with the associated user ynh_psql_remove_db --db_name="$db_name" --db_user="$app" diff --git a/scripts/restore b/scripts/restore index b9da64a..b193bbb 100644 --- a/scripts/restore +++ b/scripts/restore @@ -14,6 +14,9 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ynh_clean_check_starting +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -88,6 +91,17 @@ ynh_print_info "Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create "$app" +#================================================= +# RESTORE USER RIGHTS +#================================================= + +# Restore permissions on app files +chown -R "$app": "$final_path" +chmod -R 755 "$final_path/code/front/dist/" + +mkdir -p "/var/log/$app" +chown -R "$app": "/var/log/$app" + #================================================= # SPECIFIC RESTORATION #================================================= @@ -95,6 +109,7 @@ ynh_system_user_create "$app" #================================================= ynh_print_info "Reinstalling dependencies..." +# Define and install dependencies ynh_install_app_dependencies $pkg_dependencies #================================================= @@ -106,17 +121,6 @@ ynh_psql_test_if_first_run ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd" ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" -#================================================= -# RESTORE USER RIGHTS -#================================================= - -# Restore permissions on app files -chown -R "$app": "$final_path" -chmod -R 755 "$final_path/code/front/dist/" - -mkdir -p "/var/log/$app" -chown -R "$app": "/var/log/$app" - #================================================= # RESTORE SYSTEMD #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 3ad265a..f53dcce 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -64,6 +64,7 @@ ynh_app_setting_set "$app" backup_core_only 1 ynh_backup_before_upgrade ynh_clean_setup () { # restore it if the upgrade fails + ynh_clean_check_starting ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script @@ -138,7 +139,7 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= ynh_print_info "Making sure dedicated system user exists..." -# Create a system user +# Create a dedicated user (if not existing) ynh_system_user_create "$app" #================================================= @@ -271,7 +272,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Upgrading SSOwat configuration..." +ynh_print_info "Reloading nginx web server..." systemctl reload nginx