From 061496458c89b5c0f5afc0b02b9ebf6797d07ef9 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 9 Apr 2021 22:50:44 +0200 Subject: [PATCH] Apply example_ynh --- README.md | 4 ++-- check_process | 5 ----- manifest.json | 12 ------------ scripts/change_url | 20 ++++++++++---------- scripts/install | 38 +++++++++++++++++++------------------- scripts/remove | 10 +++++----- scripts/restore | 23 ++++++++++------------- scripts/upgrade | 42 +++++++++++++----------------------------- 8 files changed, 59 insertions(+), 95 deletions(-) diff --git a/README.md b/README.md index 14ebafe..cd686d6 100644 --- a/README.md +++ b/README.md @@ -82,8 +82,8 @@ The app can be used by multiple users. #### Supported architectures -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/pleroma%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/pleroma/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/pleroma%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/pleroma/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/pleroma.svg)](https://ci-apps.yunohost.org/ci/apps/pleroma/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/pleroma.svg)](https://ci-apps-arm.yunohost.org/ci/apps/pleroma/) ## Links diff --git a/check_process b/check_process index 690f3ea..143f08d 100644 --- a/check_process +++ b/check_process @@ -1,8 +1,3 @@ -# See here for more informations -# https://github.com/YunoHost/package_check#syntax-check_process-file - -# Move this file from check_process.default to check_process when you have filled it. - ;; Test complet ; Manifest domain="domain.tld" (DOMAIN) diff --git a/manifest.json b/manifest.json index c7a901a..60d90ac 100644 --- a/manifest.json +++ b/manifest.json @@ -29,28 +29,16 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain name for Pleroma", - "fr": "Choisissez un nom de domaine pour Pleroma" - }, "example": "example.com" }, { "name": "admin", "type": "user", - "ask": { - "en": "Choose an admin user", - "fr": "Choisissez l'administrateur" - }, "example": "johndoe" }, { "name": "is_public", "type": "boolean", - "ask": { - "en": "Is it a public application?", - "fr": "Est-ce une application publique ?" - }, "default": true }, { diff --git a/scripts/change_url b/scripts/change_url index d1bcc13..6935e26 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -35,9 +35,9 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -45,7 +45,7 @@ ynh_clean_setup () { # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - # 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 @@ -81,23 +81,23 @@ pkill -u $app #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating nginx web server configuration..." +ynh_script_progression --message="Updating NGINX web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf -# Change the path in the nginx config file +# Change the path in the NGINX config file if [ $change_path -eq 1 ] then - # Make a backup of the original nginx config file if modified + # Make a backup of the original NGINX config file if modified ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for nginx helper + # Set global variables for NGINX helper domain="$old_domain" path_url="$new_path" - # Create a dedicated nginx config + # Create a dedicated NGINX config ynh_add_nginx_config fi -# Change the domain for nginx +# Change the domain for NGINX if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location @@ -136,7 +136,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/install b/scripts/install index 421635b..1f4d515 100755 --- a/scripts/install +++ b/scripts/install @@ -89,6 +89,14 @@ ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # CREATE A POSTGRESQL DATABASE #================================================= @@ -116,12 +124,16 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path architecture=$(ynh_detect_arch) ynh_setup_source --dest_dir="$final_path/$app" --source_id=$architecture +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." +ynh_script_progression --message="Configuring NGINX web server..." -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config if [ $cache -eq 1 ] @@ -134,14 +146,6 @@ then ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf" fi -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." - -# Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # SPECIFIC SETUP #================================================= @@ -163,6 +167,10 @@ chown -R "$app":"$app" "$datadir" ynh_app_setting_set --app=$app --key=datadir --value="$datadir" +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R root:$app "$datadir" + #================================================= # CREATE THE CONFIG DIRECTORY #================================================= @@ -238,14 +246,6 @@ ynh_store_file_checksum --file="$config" #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." - -# Set permissions to app files -chown -R "$app":"$app" "$final_path" - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= @@ -271,7 +271,7 @@ ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --aut #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/remove b/scripts/remove index c246e00..3408bba 100755 --- a/scripts/remove +++ b/scripts/remove @@ -29,7 +29,7 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir) # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -# Remove the service from the list of services known by Yunohost (added from `yunohost service add`) +# 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 integration..." @@ -80,9 +80,9 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." +ynh_script_progression --message="Removing NGINX web server configuration..." -# Remove the dedicated nginx config +# Remove the dedicated NGINX config ynh_remove_nginx_config ynh_secure_remove --file="/etc/nginx/conf.d/$app-cache.conf" @@ -99,9 +99,9 @@ fi #================================================= # SPECIFIC REMOVE #================================================= -# REMOVE DIRECTORIES +# REMOVE CONFIGURATION #================================================= -ynh_script_progression --message="Removing directories..." +ynh_script_progression --message="Removing configuration..." # Remove the config directory securely ynh_secure_remove --file="/etc/$app" diff --git a/scripts/restore b/scripts/restore index 44d0e13..535ea61 100755 --- a/scripts/restore +++ b/scripts/restore @@ -61,13 +61,6 @@ then ynh_restore_file --origin_path="/etc/nginx/conf.d/$app-cache.conf" fi -#================================================= -# RESTORE THE APP MAIN DIR -#================================================= -ynh_script_progression --message="Restoring the app main directory..." - -ynh_restore_file --origin_path="$final_path" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -77,12 +70,15 @@ ynh_script_progression --message="Recreating the dedicated system user..." ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= -# RESTORE USER RIGHTS +# RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring user rights..." +ynh_script_progression --message="Restoring the app main directory..." -# Restore permissions on app files -chown -R "$app":"$app" "$final_path" +ynh_restore_file --origin_path="$final_path" + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" #================================================= # SPECIFIC RESTORATION @@ -100,8 +96,9 @@ mkdir -p "$datadir/uploads/" mkdir -p "$datadir/static/" mkdir -p "$datadir/static/emoji/" -# Give permission to the datadir -chown -R "$app":"$app" "$datadir" +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R root:$app "$datadir" #================================================= # RESTORE THE CONFIG FILE diff --git a/scripts/upgrade b/scripts/upgrade index c874369..6e71462 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -95,23 +95,15 @@ abort_if_up_to_date previous_version="${version}" #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." -# Inform the backup/restore process that it should not save the data directory -# Use only for the previous backup script that doesn't set 'is_big' -ynh_app_setting_set --app=$app --key=backup_core_only --value=1 - # Backup the current version of the app ynh_backup_before_upgrade - -# Remove the option backup_core_only after the backup. -ynh_app_setting_delete --app=$app --key=backup_core_only - ynh_clean_setup () { ynh_clean_check_starting - # 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 @@ -130,6 +122,14 @@ if ynh_version_gt "${previous_version}" "1.1.1~ynh1" ; then pkill -u $app fi +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # UPGRADE TO OTP RELEASE #================================================= @@ -192,9 +192,9 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." +ynh_script_progression --message="Upgrading NGINX web server configuration..." -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config ynh_secure_remove --file="/etc/nginx/conf.d/$app-cache.conf" @@ -215,14 +215,6 @@ ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # SPECIFIC UPGRADE #================================================= @@ -264,14 +256,6 @@ ynh_add_systemd_config #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." - -# Set permissions on app files -chown -R "$app":"$app" "$final_path" - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= @@ -292,7 +276,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload