From ef4b78862b32efcae443db4b8dabb39ecdffe83c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 6 Aug 2021 13:54:47 +0200 Subject: [PATCH] Apply last example_ynh (#62) --- manifest.json | 2 +- scripts/backup | 17 +++++++++-------- scripts/change_url | 2 +- scripts/install | 12 +++++++----- scripts/remove | 24 +++++++++++++----------- scripts/restore | 11 ++++++----- scripts/upgrade | 6 +++--- 7 files changed, 40 insertions(+), 34 deletions(-) diff --git a/manifest.json b/manifest.json index 7e501ea..4fe5122 100644 --- a/manifest.json +++ b/manifest.json @@ -32,7 +32,7 @@ { "name": "domain", "type": "domain", - "example": "domain.org" + "example": "example.com" }, { "name": "path", diff --git a/scripts/backup b/scripts/backup index ca6fc22..425d53f 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -14,7 +15,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ynh_clean_check_starting + true } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -40,12 +41,6 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$final_path" -#================================================= -# BACKUP THE APP CONFIG DIR -#================================================= - -ynh_backup --src_path="/var/lib/$app" - #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= @@ -60,8 +55,14 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/systemd/system/$app.service" +#================================================= +# BACKUP VARIOUS FILES +#================================================= + +ynh_backup --src_path="/var/lib/$app" + #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for Navidrome. (YunoHost will then actually copy those files to the archive)." +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index ffaeb28..c1ba790 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -135,4 +135,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for Navidrome" --last +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index b8348d8..68f0473 100644 --- a/scripts/install +++ b/scripts/install @@ -82,11 +82,11 @@ ynh_script_progression --message="Setting up source files..." --weight=4 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 --dest_dir=$final_path --source_id="$architecture" +ynh_setup_source --dest_dir="$final_path" --source_id="$architecture" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chown -R $app:$app "$final_path" #================================================= # NGINX CONFIGURATION @@ -96,6 +96,8 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=3 # Create a dedicated NGINX config ynh_add_nginx_config +#================================================= +# SPECIFIC SETUP #================================================= # YUNOHOST MULTIMEDIA INTEGRATION #================================================= @@ -104,9 +106,9 @@ ynh_script_progression --message="Adding multimedia directories..." --weight=2 ynh_multimedia_build_main_dir #================================================= -# MODIFY A CONFIG FILE +# ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Modifying a config file..." --weight=1 +ynh_script_progression --message="Adding a configuration file..." --weight=1 config_path="/var/lib/$app" mkdir -p "$config_path" @@ -115,7 +117,7 @@ mkdir -p "$config_path" ynh_add_config --template="../conf/navidrome.toml" --destination="$config_path/navidrome.toml" chmod 600 "$config_path/navidrome.toml" -chown -R $app "$config_path" +chown -R $app:$app "$config_path" #================================================= # SETUP SYSTEMD diff --git a/scripts/remove b/scripts/remove index ba538dc..39c8c8d 100644 --- a/scripts/remove +++ b/scripts/remove @@ -29,7 +29,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status $app >/dev/null then - ynh_script_progression --message="Removing $app service..." --weight=1 + ynh_script_progression --message="Removing $app service integration..." --weight=1 yunohost service remove $app fi @@ -52,19 +52,11 @@ ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing Navidrome main directory..." --weight=6 +ynh_script_progression --message="Removing app main directory..." --weight=6 # Remove the app directory securely ynh_secure_remove --file="$final_path" -#================================================= -# REMOVE APP CONFIG DIR -#================================================= -ynh_script_progression --message="Removing Navidrome config directory..." --weight=6 - -# Remove the config directory securely -ynh_secure_remove --file="/var/lib/$app" - #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -73,6 +65,16 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated NGINX config ynh_remove_nginx_config +#================================================= +# SPECIFIC REMOVE +#================================================= +# REMOVE VARIOUS FILES +#================================================= +ynh_script_progression --message="Removing various files..." --weight=6 + +# Remove the config directory securely +ynh_secure_remove --file="/var/lib/$app" + #================================================= # GENERIC FINALIZATION #================================================= @@ -87,4 +89,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of Navidrome completed" --last +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index 51128ca..300e178 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -22,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -45,7 +46,7 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the NGINX configuration..." +ynh_script_progression --message="Restoring the NGINX web server configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -60,13 +61,13 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring Navidrome main directory..." --weight=4 +ynh_script_progression --message="Restoring the app main directory..." --weight=4 ynh_restore_file --origin_path="$final_path" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chown -R $app:$app "$final_path" #================================================= # SPECIFIC RESTORATION @@ -123,4 +124,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for Navidrome" --last +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index 69c534d..d102875 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -84,12 +84,12 @@ then ynh_secure_remove --file=$final_path # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir=$final_path --source_id="$architecture" + ynh_setup_source --dest_dir="$final_path" --source_id="$architecture" fi chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chown -R $app:$app "$final_path" #================================================= # NGINX CONFIGURATION @@ -117,7 +117,7 @@ config_path="/var/lib/$app" #ynh_add_config --template="../conf/navidrome.toml" --destination="$config_path/navidrome.toml" chmod 600 "$config_path/navidrome.toml" -chown -R $app "$config_path" +chown -R $app:$app "$config_path" #================================================= # SETUP SYSTEMD