From 495932cd938eba1454742a4af9523f1484c1e5e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Thu, 20 Jun 2024 23:46:10 +0200 Subject: [PATCH] Coding style, apply template --- manifest.toml | 6 ++++-- scripts/backup | 4 ++++ scripts/install | 19 ++++--------------- scripts/remove | 16 +++------------- scripts/restore | 9 +++------ scripts/upgrade | 19 +++++-------------- 6 files changed, 23 insertions(+), 50 deletions(-) diff --git a/manifest.toml b/manifest.toml index 096996b..6fd3b8c 100644 --- a/manifest.toml +++ b/manifest.toml @@ -1,3 +1,5 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + packaging_format = 2 id = "watchdog" @@ -16,7 +18,7 @@ license = "GPL-2.0-or-later" code = "https://sourceforge.net/projects/watchdog/" [integration] -yunohost = ">= 11.2" +yunohost = ">=11.2" architectures = "all" multi_instance = false ldap = "not_relevant" @@ -30,4 +32,4 @@ ram.runtime = "50M" [resources] [resources.apt] - packages = "watchdog" + packages = ["watchdog"] diff --git a/scripts/backup b/scripts/backup index a1475cf..e8a9540 100644 --- a/scripts/backup +++ b/scripts/backup @@ -18,6 +18,10 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="/etc/watchdog.conf" +# Remove other various files specific to the app... such as : + +ynh_backup --src_path="/var/log/$app" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index e3d9a9e..1727c9a 100644 --- a/scripts/install +++ b/scripts/install @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -28,28 +26,19 @@ if [[ $(grep -ic "Raspberry Pi" /proc/cpuinfo) -ge 1 && $(grep -ic "dtparam=watc echo "dtparam=watchdog=on" >> /boot/config.txt fi -yunohost service add $app - -#================================================= -# APP INITIAL CONFIGURATION -#================================================= -# ADD A CONFIGURATION -#================================================= -ynh_script_progression --message="Adding app's configuration file..." - ynh_add_config --template="watchdog.conf" --destination="/etc/watchdog.conf" - chmod 400 "/etc/watchdog.conf" chown root: "/etc/watchdog.conf" +systemctl enable "$app.service" --quiet +yunohost service add "$app" + #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting app's systemd service..." -# Enable and start a systemd service -systemctl enable $app.service --quiet -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 97ae1b9..3c95663 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,37 +1,27 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers -#================================================= -# REMOVE SYSTEM CONFIGURATIONS #================================================= # REMOVE SYSTEMD SERVICE #================================================= ynh_script_progression --message="Removing system configurations related to $app..." # 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..." - yunohost service remove $app +if ynh_exec_warn_less yunohost service status $app >/dev/null; then + yunohost service remove "$app" fi ynh_remove_systemd_config ynh_remove_nginx_config -# Remove other various files specific to the app... such as : - -ynh_secure_remove --file="/var/log/$app" - #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last \ No newline at end of file +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index 0cc8d0e..1e15539 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -17,12 +15,11 @@ ynh_script_progression --message="Restoring system configurations related to $ap ynh_restore_file --origin_path="/etc/watchdog.conf" -systemctl enable $app.service --quiet +systemctl enable "$app.service" --quiet +yunohost service add "$app" -yunohost service add $app +ynh_restore_file --origin_path="/var/log/$app" -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 00352c1..434b54a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -21,26 +19,19 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" #================================================= ynh_script_progression --message="Upgrading system configurations related to $app..." -yunohost service add $app - -#================================================= -# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...) -#================================================= -# UPDATE A CONFIG FILE -#================================================= -ynh_script_progression --message="Updating a configuration file..." - ynh_add_config --template="watchdog.conf" --destination="/etc/watchdog.conf" - chmod 400 "/etc/watchdog.conf" chown root: "/etc/watchdog.conf" +systemctl enable "$app.service" --quiet +yunohost service add "$app" + #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting $app's systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" #================================================= # END OF SCRIPT