From 544df05439f01e761d5882e79c682777bb82be96 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 7 Feb 2021 11:53:00 +0100 Subject: [PATCH] Fix linter warnings --- check_process | 7 ------ manifest.json | 14 ++++++------ scripts/backup | 23 ++++---------------- scripts/change_url | 21 +++++++----------- scripts/install | 14 ++++++------ scripts/remove | 12 +---------- scripts/restore | 9 ++++---- scripts/upgrade | 54 +++++++--------------------------------------- 8 files changed, 39 insertions(+), 115 deletions(-) diff --git a/check_process b/check_process index daeb9ff..8fe078c 100644 --- a/check_process +++ b/check_process @@ -1,8 +1,6 @@ # See here for more information # 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) @@ -19,13 +17,8 @@ upgrade=1 from_commit=d2e712af6ed33c1afeed4b60fcd8902409f8c2a8 backup_restore=1 multi_instance=1 - # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. - # incorrect_path=1 port_already_use=0 change_url=1 -;;; Levels - # If the level 5 (Package linter) is forced to 1. Please add justifications here. - Level 5=auto ;;; Options Email= Notification=none diff --git a/manifest.json b/manifest.json index 5396997..f73a767 100644 --- a/manifest.json +++ b/manifest.json @@ -3,8 +3,8 @@ "id": "cowyo", "packaging_format": 1, "description": { - "en": "A feature-rich wiki webserver for minimalists.", - "fr": "Un serveur de wiki minimaliste mais riche en fonctionnalités." + "en": "Feature-rich wiki webserver for minimalists", + "fr": "Serveur de wiki minimaliste mais riche en fonctionnalités." }, "version": "2.12.0~ynh4", "url": "https://github.com/schollz/cowyo", @@ -14,7 +14,7 @@ "email": "tituspijean@outlook.com" }, "requirements": { - "yunohost": ">= 3.7" + "yunohost": ">= 3.8.2" }, "multi_instance": true, "services": [ @@ -25,8 +25,8 @@ "name": "domain", "type": "domain", "ask": { - "en": "Choose a domain name dedicated to cowyo.", - "fr": "Choisissez un nom de domaine dédié à cowyo." + "en": "Choose a domain name dedicated to Cowyo", + "fr": "Choisissez un nom de domaine dédié à Cowyo" }, "example": "example.com" }, @@ -38,8 +38,8 @@ "fr": "Est-ce une application publique ?" }, "help": { - "en": "If public, anyone will be able to create pages in cowyo.", - "fr": "Si publique, quiconque pourra créer des pages dans cowyo." + "en": "If public, anyone will be able to create pages in Cowyo", + "fr": "Si publique, quiconque pourra créer des pages dans Cowyo" }, "default": true } diff --git a/scripts/backup b/scripts/backup index 55019ca..d532e37 100644 --- a/scripts/backup +++ b/scripts/backup @@ -24,7 +24,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -32,25 +32,19 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= -# STANDARD BACKUP STEPS +# DECLARE DATA AND CONF FILES TO BACKUP #================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=2 - -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_print_info --message="Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_script_progression --message="Backing up the main app directory..." --weight=1 ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Backing up nginx web server configuration..." --weight=1 ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -59,26 +53,17 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP LOGROTATE #================================================= -ynh_script_progression --message="Backing up logrotate configuration..." --weight=1 ynh_backup --src_path="/etc/logrotate.d/$app" #================================================= # BACKUP SYSTEMD #================================================= -ynh_script_progression --message="Backing up systemd configuration..." --weight=1 ynh_backup --src_path="/etc/systemd/system/$app.service" -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 - -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" - #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last +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 f71fc77..6f84bcf 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -28,10 +28,6 @@ app=$YNH_APP_INSTANCE_NAME # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get $app final_path) -# Add settings here as needed by your application -#db_name=$(ynh_app_setting_get "$app" db_name) -#db_pwd=$(ynh_app_setting_get $app db_pwd) - #================================================= # CHECK THE SYNTAX OF THE PATHS #================================================= @@ -87,16 +83,15 @@ then ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" fi -#================================================= -# SPECIFIC MODIFICATIONS -#================================================= -# ... -#================================================= - -#================================================= -# GENERIC FINALISATION #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reloading NGINX web server..." -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index fc549ce..84599f7 100644 --- a/scripts/install +++ b/scripts/install @@ -46,8 +46,8 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= ynh_script_progression --message="Storing installation settings..." --weight=1 -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app path $path_url +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url #================================================= # STANDARD MODIFICATIONS @@ -73,7 +73,7 @@ chmod +x "$final_path/cowyo" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." --weight=1 +ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated nginx config ynh_add_nginx_config @@ -118,7 +118,7 @@ ynh_use_logrotate # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -yunohost service add ${app} --log "/var/log/${app}.log" +yunohost service add $app --description="wiki webserver" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE @@ -126,7 +126,7 @@ yunohost service add ${app} --log "/var/log/${app}.log" ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app" +ynh_systemd_action --service_name=$app --action=start --log_path="/var/log/$app/$app" #================================================= # SETUP PERMISSIONS @@ -138,13 +138,13 @@ if [ $is_public -eq 1 ] then # Everyone can access the app. # The "main" permission is automatically created before the install script. - ynh_permission_update --permission "main" --add "visitors" + ynh_permission_update --permission="main" --add="visitors" fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/remove b/scripts/remove index 6a465dd..a651274 100644 --- a/scripts/remove +++ b/scripts/remove @@ -52,7 +52,7 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." --weight=1 +ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 # Remove the dedicated nginx config ynh_remove_nginx_config @@ -65,16 +65,6 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight= # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - ynh_script_progression --message="Closing port $port..." - ynh_exec_warn_less yunohost firewall disallow TCP $port -fi - #================================================= # SPECIFIC REMOVE #================================================= diff --git a/scripts/restore b/scripts/restore index 90f0a06..aefe339 100644 --- a/scripts/restore +++ b/scripts/restore @@ -78,20 +78,20 @@ chown -R $app: $final_path ynh_script_progression --message="Restoring the systemd configuration..." --weight=2 ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service +systemctl enable $app.service --quiet #================================================= # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -yunohost service add $app --log "/var/log/$app/$app.log" +yunohost service add $app --description="wiki webserver" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action=start --log_path="/var/log/$app/$app.log" #================================================= # RESTORE THE LOGROTATE CONFIGURATION @@ -104,9 +104,8 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading nginx web server and php-fpm..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=php7.0-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index bb86351..5c603fb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,12 +25,6 @@ port=$(ynh_app_setting_get --app=$app --key=port) # CHECK VERSION #================================================= -### This helper will compare the version of the currently installed app and the version of the upstream package. -### $upgrade_type can have 2 different values -### - UPGRADE_APP if the upstream app version has changed -### - UPGRADE_PACKAGE if only the YunoHost package has changed -### ynh_check_app_version_changed will stop the upgrade if the app is up to date. -### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. upgrade_type=$(ynh_check_app_version_changed) #================================================= @@ -45,31 +39,12 @@ if [ -z "$final_path" ]; then fi # Cleaning legacy permissions -is_public=$(ynh_app_setting_get --app=$app --key=is_public) -skipped_uris=$(ynh_app_setting_get --app=$app --key=skipped_uris) -unprotected_uris=$(ynh_app_setting_get --app=$app --key=unprotected_uris) -protected_uris=$(ynh_app_setting_get --app=$app --key=protected_uris) +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all -# Remove is_public if exists -if [ ! -z "$is_public" ]; then ynh_app_setting_delete --app=$app --key=is_public fi -# Remove skipped_uris if exists -if [ ! -z "$skipped_uris" ]; then - ynh_app_setting_delete --app=$app --key=skipped_uris -fi - -# Remove unprotected_uris if exists -if [ ! -z "$unprotected_uris" ]; then - ynh_app_setting_delete --app=$app --key=unprotected_uris -fi - -# Remove protected_uris if exists -if [ ! -z "$protected_uris" ]; then - ynh_app_setting_delete --app=$app --key=protected_uris -fi - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -84,18 +59,6 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors -#================================================= -# CHECK THE PATH -#================================================= - -# Normalize the URL path syntax -# N.B. : this is for app installations before YunoHost 2.7 -# where this value might be something like /foo/ or foo/ -# instead of /foo .... -# If nobody installed your app before 2.7, then you may -# safely remove this line -path_url=$(ynh_normalize_url_path --path_url=$path_url) - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -103,7 +66,7 @@ path_url=$(ynh_normalize_url_path --path_url=$path_url) #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$app.log" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -122,7 +85,7 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=1 +ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 # Create a dedicated nginx config ynh_add_nginx_config @@ -164,23 +127,22 @@ ynh_add_systemd_config chown -R $app: $final_path #================================================= -# SETUP PERMISSIONS +# ADVERTISE SERVICE IN ADMIN PANEL #================================================= -#ynh_script_progression --message="Upgrading permissions configuration..." --weight=1 - +yunohost service add $app --description="wiki webserver" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action=start --log_path="/var/log/$app/$app.log" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload