From af8d2020a51ef835ff72670a57cb297da0c2906d Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 3 Dec 2020 11:19:43 +0100 Subject: [PATCH 1/5] Fix linter --- README.md | 3 +-- README_fr.md | 3 +-- check_process | 5 ----- manifest.json | 1 + scripts/backup | 9 ++++----- scripts/install | 19 +++++++++---------- scripts/remove | 22 +++++++++------------- scripts/restore | 25 ++++++++++++++----------- scripts/upgrade | 6 ++++++ 9 files changed, 45 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index d41894f..c7a9414 100644 --- a/README.md +++ b/README.md @@ -75,8 +75,7 @@ How to configure this app: by SSH --- -Developers info ----------------- +## Developers info Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/minetest_ynh/tree/testing). diff --git a/README_fr.md b/README_fr.md index 01ab4db..55b3ba1 100644 --- a/README_fr.md +++ b/README_fr.md @@ -74,8 +74,7 @@ Comment configurer cette application : par SSH --- -Informations pour les développeurs ----------------- +## Informations pour les développeurs Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/minetest_ynh/tree/testing). diff --git a/check_process b/check_process index 6621596..d1f6fdb 100644 --- a/check_process +++ b/check_process @@ -52,11 +52,6 @@ incorrect_path=0 port_already_use=1 change_url=0 - - -;;; 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 dc6db00..43e2b8f 100644 --- a/manifest.json +++ b/manifest.json @@ -48,6 +48,7 @@ }, { "name": "game", + "type": "string", "ask": { "en": "Choose a game for your server", "fr": "Choissisez un jeu pour votre serveur" diff --git a/scripts/backup b/scripts/backup index 0ad4138..a211def 100755 --- a/scripts/backup +++ b/scripts/backup @@ -32,18 +32,19 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) home_path=$(ynh_app_setting_get --app=$app --key=home_path) #================================================= -# STANDARD BACKUP STEPS +# DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +ynh_print_info --message="Declaring files to be backed up..." + #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_print_info --message="Backing up the main app directory..." ynh_backup --src_path="$final_path" #================================================= # BACKUP THE HOME DIR #================================================= -ynh_print_info --message="Backing up Minetest data..." ynh_backup --src_path="$home_path" @@ -52,14 +53,12 @@ ynh_backup --src_path="$home_path" #================================================= # BACKUP LOGROTATE #================================================= -ynh_print_info --message="Backing up logrotate configuration..." ynh_backup --src_path="/etc/logrotate.d/$app" #================================================= # BACKUP SYSTEMD #================================================= -ynh_print_info --message="Backing up systemd configuration..." ynh_backup --src_path="/etc/systemd/system/$app.service" diff --git a/scripts/install b/scripts/install index bf208f1..865dfb7 100755 --- a/scripts/install +++ b/scripts/install @@ -38,7 +38,7 @@ path_url="/" #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_print_info --message="Validating installation parameters..." +ynh_script_progression --message="Validating installation parameters..." final_path=/opt/yunohost/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -46,7 +46,7 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder" #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_print_info --message="Storing installation settings..." +ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=server_domain --value=$server_domain ynh_app_setting_set --app=$app --key=path --value=$path_url @@ -62,7 +62,7 @@ ynh_app_setting_set --app=$app --key=servername --value=$servername #================================================= # FIND AND OPEN A PORT #================================================= -ynh_print_info --message="Configuring firewall..." +ynh_script_progression --message="Configuring firewall..." # Find a free port port=$(ynh_find_port 30000) @@ -73,14 +73,14 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_print_info --message="Installing dependencies..." +ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info --message="Setting up source files..." +ynh_script_progression --message="Setting up source files..." ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src @@ -89,7 +89,7 @@ ynh_setup_source --dest_dir="$final_path" #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info --message="Configuring system user..." +ynh_script_progression --message="Configuring system user..." home_path=/home/yunohost.app/$app ynh_app_setting_set --app=$app --key=home_path --value=$home_path @@ -107,7 +107,7 @@ cp -a ../conf/minetest.conf $home_path/.minetest/ #================================================= # SETUP SYSTEMD #================================================= -ynh_print_info --message="Configuring a systemd service..." +ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_add_systemd_config @@ -149,7 +149,6 @@ ynh_replace_string --match_string="__PVP__" --replace_string="$pvp" --target_fil ynh_replace_string --match_string="__CREATIVE__" --replace_string="$creative" --target_file="$home_path/.minetest/minetest.conf" ynh_replace_string --match_string="__DAMAGE__" --replace_string="$damage" --target_file="$home_path/.minetest/minetest.conf" - #================================================= # CREATE WORLD #================================================= @@ -179,7 +178,7 @@ chown -R $app: $home_path #================================================= # SETUP LOGROTATE #================================================= -ynh_print_info --message="Configuring log rotation..." +ynh_script_progression --message="Configuring log rotation..." # Use logrotate to manage application logfile(s) ynh_use_logrotate @@ -188,7 +187,7 @@ ynh_use_logrotate # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -yunohost service add $app --log "/var/log/$app/minetest.log" +yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/minetest.log" --needs_exposed_ports #================================================= # RELOAD MINETEST diff --git a/scripts/remove b/scripts/remove index 07abc5b..f67f958 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -29,14 +29,14 @@ home_path=$(ynh_app_setting_get --app=$app --key=home_path) # Remove a service from the admin panel, added by `yunohost service add` if yunohost service status $app >/dev/null 2>&1 then - ynh_print_info --message="Removing $app service" + ynh_script_progression --message="Removing $app service" yunohost service remove $app fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_print_info --message="Stopping and removing the systemd service" +ynh_script_progression --message="Stopping and removing the systemd service" # Remove the dedicated systemd config ynh_remove_systemd_config @@ -44,7 +44,7 @@ ynh_remove_systemd_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_print_info --message="Removing dependencies" +ynh_script_progression --message="Removing dependencies" # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -52,7 +52,7 @@ ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_print_info --message="Removing app main directory" +ynh_script_progression --message="Removing app main directory" # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -64,7 +64,7 @@ ynh_secure_remove "/var/log/$app" #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_print_info --message="Removing logrotate configuration" +ynh_script_progression --message="Removing logrotate configuration" # Remove the app-specific logrotate config ynh_remove_logrotate @@ -75,20 +75,16 @@ ynh_remove_logrotate if yunohost firewall list | grep -q "\- $port$" then - ynh_print_info --message="Closing port $port" + ynh_script_progression --message="Closing port $port" ynh_exec_warn_less yunohost firewall disallow UDP $port fi -#================================================= -# SPECIFIC REMOVE -#================================================= - #================================================= # GENERIC FINALIZATION #================================================= # REMOVE DEDICATED USER #================================================= -ynh_print_info --message="Removing the dedicated system user" +ynh_script_progression --message="Removing the dedicated system user" # Delete a system user ynh_system_user_delete --username=$app @@ -97,4 +93,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_print_info --message="Removal of $app completed" +ynh_script_progression --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 02aef87..0f8b921 100755 --- a/scripts/restore +++ b/scripts/restore @@ -24,7 +24,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading settings..." +ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME @@ -34,19 +34,17 @@ home_path=$(ynh_app_setting_get --app=$app --key=home_path) #================================================= # STANDARD RESTORATION STEPS -#================================================= - #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_print_info --message="Restoring the app main directory..." +ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_print_info --message="Recreating the dedicated system user..." +ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir=$home_path --use_shell @@ -67,7 +65,7 @@ chown -R $app: $home_path #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_print_info --message="Reinstalling dependencies..." +ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies @@ -75,10 +73,10 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE SYSTEMD #================================================= -ynh_print_info --message="Restoring the systemd configuration..." +ynh_script_progression --message="Restoring the systemd configuration..." ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service +systemctl enable $app.service --quiet #================================================= # ADVERTISE SERVICE IN ADMIN PANEL @@ -87,7 +85,12 @@ systemctl enable $app.service mkdir /var/log/$app -p chown -R $app: /var/log/$app -yunohost service add $app --log "/var/log/$app/minetest.log" +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 + +yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/$app.log" #================================================= # RESTORE THE LOGROTATE CONFIGURATION @@ -100,7 +103,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # RELOAD MINETEST #================================================= -ynh_print_info --message="Reloading minetest..." +ynh_script_progression --message="Reloading minetest..." ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/minetest.log" --line_match="listening on" @@ -108,4 +111,4 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap # END OF SCRIPT #================================================= -ynh_print_info --message="Restoration completed for $app" +ynh_script_progression --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 1f159b7..135e3ab 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -185,6 +185,12 @@ ynh_use_logrotate --non-append chown -R root: $final_path chown -R $app: $home_path +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/minetest.log" + #================================================= # RELOAD MINETEST #================================================= From 42f21586afef74d31bc1305b150d74529210d301 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 3 Dec 2020 11:24:32 +0100 Subject: [PATCH 2/5] Fix --- scripts/restore | 4 ++-- scripts/upgrade | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/restore b/scripts/restore index 0f8b921..d29f3bc 100755 --- a/scripts/restore +++ b/scripts/restore @@ -88,9 +88,9 @@ chown -R $app: /var/log/$app #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/$app.log" --needs_exposed_ports #================================================= # RESTORE THE LOGROTATE CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 135e3ab..d4a5ec6 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -189,7 +189,7 @@ chown -R $app: $home_path # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/minetest.log" +yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/$app.log" --needs_exposed_ports #================================================= # RELOAD MINETEST From e9bb6f0b641d961224e87ffc2993f0c9dc31ce8b Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 3 Dec 2020 11:28:43 +0100 Subject: [PATCH 3/5] Add argument --- manifest.json | 2 +- scripts/install | 2 +- scripts/restore | 3 ++- scripts/upgrade | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index 43e2b8f..8951e91 100644 --- a/manifest.json +++ b/manifest.json @@ -20,7 +20,7 @@ "url": "https://framasoft.org" }, "requirements": { - "yunohost": ">= 3.5" + "yunohost": ">= 3.8.1" }, "multi_instance": true, "services": [ diff --git a/scripts/install b/scripts/install index 865dfb7..c21e57a 100755 --- a/scripts/install +++ b/scripts/install @@ -187,7 +187,7 @@ ynh_use_logrotate # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/minetest.log" --needs_exposed_ports +yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/minetest.log" --needs_exposed_ports="$port" #================================================= # RELOAD MINETEST diff --git a/scripts/restore b/scripts/restore index d29f3bc..50123d7 100755 --- a/scripts/restore +++ b/scripts/restore @@ -31,6 +31,7 @@ app=$YNH_APP_INSTANCE_NAME path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) home_path=$(ynh_app_setting_get --app=$app --key=home_path) +port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # STANDARD RESTORATION STEPS @@ -90,7 +91,7 @@ chown -R $app: /var/log/$app #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/$app.log" --needs_exposed_ports +yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port" #================================================= # RESTORE THE LOGROTATE CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index d4a5ec6..27952e8 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -189,7 +189,7 @@ chown -R $app: $home_path # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/$app.log" --needs_exposed_ports +yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port" #================================================= # RELOAD MINETEST From cb211c9a8827154cf4b66571028a89d55d6a9cc6 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 3 Dec 2020 11:33:58 +0100 Subject: [PATCH 4/5] Fix --- scripts/install | 2 +- scripts/upgrade | 26 +++++++++++--------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/scripts/install b/scripts/install index c21e57a..0f2c388 100755 --- a/scripts/install +++ b/scripts/install @@ -187,7 +187,7 @@ ynh_use_logrotate # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/minetest.log" --needs_exposed_ports="$port" +yunohost service add $app --description="Voxel game engine and game" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port" #================================================= # RELOAD MINETEST diff --git a/scripts/upgrade b/scripts/upgrade index 27952e8..61d0887 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -27,11 +27,10 @@ creative=$(ynh_app_setting_get --app=$app --key=creative) damage=$(ynh_app_setting_get --app=$app --key=damage) servername=$(ynh_app_setting_get --app=$app --key=servername) - #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_print_info --message="Checking version..." +ynh_script_progression --message="Checking version..." version=ynh_app_upstream_version if [ "$version" = "0.01" ]; then @@ -39,7 +38,7 @@ ynh_die --message="You can't upgrade to this version with simple upgrade. Please fi -ynh_print_info --message="Ensuring downward compatibility..." +ynh_script_progression --message="Ensuring downward compatibility..." # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then @@ -59,7 +58,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_print_info --message="Backing up the app before upgrading (may take a while)..." +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -77,7 +76,7 @@ ynh_abort_if_errors #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info --message="Upgrading source files..." +ynh_script_progression --message="Upgrading source files..." # Remove old install ynh_secure_remove --file="$final_path" @@ -88,14 +87,14 @@ ynh_setup_source --dest_dir="$final_path" #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_print_info --message="Upgrading dependencies..." +ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info --message="Making sure dedicated system user exists..." +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=$home_path --use_shell @@ -103,7 +102,7 @@ ynh_system_user_create --username=$app --home_dir=$home_path --use_shell #================================================= # SETUP SYSTEMD #================================================= -ynh_print_info --message="Upgrading systemd configuration..." +ynh_script_progression --message="Upgrading systemd configuration..." # Create a dedicated systemd config ynh_add_systemd_config @@ -152,9 +151,6 @@ ynh_backup_if_checksum_is_different --file="$home_path/.minetest/minetest.conf" cp ../conf/minetest.conf $home_path/.minetest/minetest.conf -### `ynh_replace_string` is used to replace a string in a file. -### (It's compatible with sed regular expressions syntax) - ynh_replace_string --match_string="__GAME__" --replace_string="$game" --target_file="$home_path/.minetest/minetest.conf" ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$home_path/.minetest/minetest.conf" ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$home_path/.minetest/minetest.conf" @@ -170,7 +166,7 @@ ynh_store_file_checksum --file="$home_path/.minetest/minetest.conf" #================================================= # SETUP LOGROTATE #================================================= -ynh_print_info --message="Upgrading logrotate configuration..." +ynh_script_progression --message="Upgrading logrotate configuration..." # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append @@ -194,7 +190,7 @@ yunohost service add $app --description="Voxel game engine and game" --log="/var #================================================= # RELOAD MINETEST #================================================= -ynh_print_info --message="Restarting Minetest..." +ynh_script_progression --message="Restarting Minetest..." ynh_systemd_action --service_name=$app --action="restart" --log_path="/var/log/$app/minetest.log" --line_match="listening on" @@ -202,4 +198,4 @@ ynh_systemd_action --service_name=$app --action="restart" --log_path="/var/log/$ # END OF SCRIPT #================================================= -ynh_print_info --message="Upgrade of $app completed" +ynh_script_progression --message="Upgrade of $app completed" From 2219d7b2e202ca41d36d31f99820611fea76ca1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 20 Dec 2020 09:17:00 +0100 Subject: [PATCH 5/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c7a9414..1d20b8b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Minetest for YunoHost [![Integration level](https://dash.yunohost.org/integration/minetest.svg)](https://dash.yunohost.org/appci/app/minetest) ![](https://ci-apps.yunohost.org/ci/badges/minetest.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/minetest.maintain.svg) -[![Install Minetest with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=minetest) +[![Install Minetest with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=minetest) *[Lire ce readme en français.](./README_fr.md)*