From 91365a4c12900005f3f2115525a6188027cb2f43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sun, 4 Feb 2024 18:47:11 +0100 Subject: [PATCH] Some small cleanup --- manifest.toml | 10 +++++---- scripts/change_url | 4 ++-- scripts/install | 8 +++---- scripts/remove | 11 ++++------ scripts/restore | 19 ++++++---------- scripts/upgrade | 54 ++++++++++++++++++++-------------------------- tests.toml | 4 +++- 7 files changed, 49 insertions(+), 61 deletions(-) diff --git a/manifest.toml b/manifest.toml index 907f1e2..88d1ae5 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 = "netdata" @@ -47,10 +49,10 @@ ram.runtime = "50M" [resources] [resources.sources] - [resources.sources.main] - url = "https://github.com/netdata/netdata/releases/download/v1.44.1/netdata-v1.44.1.tar.gz" - sha256 = "77e94acf7085c23ab20b2d0d2d4d2bc5a289f121fc7aac5d0daffb960041fd95" - autoupdate.strategy = "latest_github_tag" + [resources.sources.main] + url = "https://github.com/netdata/netdata/releases/download/v1.44.1/netdata-v1.44.1.tar.gz" + sha256 = "77e94acf7085c23ab20b2d0d2d4d2bc5a289f121fc7aac5d0daffb960041fd95" + autoupdate.strategy = "latest_github_tag" [resources.system_user] diff --git a/scripts/change_url b/scripts/change_url index 76a6575..68591f6 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -16,7 +16,7 @@ source /usr/share/yunohost/helpers #================================================= 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" #================================================= # MODIFY URL IN NGINX CONF @@ -39,7 +39,7 @@ ynh_replace_string --match_string="registry to announce = https://$old_domain$ol #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="restart" --log_path="$install_dir/var/log/$app/error.log" +ynh_systemd_action --service_name="$app" --action="restart" --log_path="$install_dir/var/log/$app/error.log" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index e828f10..b618e7f 100644 --- a/scripts/install +++ b/scripts/install @@ -26,9 +26,9 @@ ynh_script_progression --message="Executing Netdata installer..." --weight=10 # create a temporary file for the log tmplog=$(mktemp /tmp/netdata-updater-log-XXXXXX.log) -pushd $NETDATA_TMPDIR +pushd "$NETDATA_TMPDIR" # the installer.sh script will append "netdata" after the --install-prefix arg - ./netdata-installer.sh --install-prefix /var/www/ --dont-wait --disable-cloud --disable-telemetry --stable-channel >$tmplog 2>$tmplog || ynh_die "FAILED TO COMPILE/INSTALL NETDATA" + ./netdata-installer.sh --install-prefix /var/www/ --dont-wait --disable-cloud --disable-telemetry --stable-channel >"$tmplog" 2>"$tmplog" || ynh_die "FAILED TO COMPILE/INSTALL NETDATA" popd # Specific configuration @@ -42,7 +42,7 @@ ynh_script_progression --message="Adding system configurations related to $app.. # Create a dedicated NGINX config ynh_add_nginx_config -yunohost service add $app --description "Real-time performance and health monitoring" --log "$install_dir/var/log/netdata/error.log" "$install_dir/var/log/netdata/access.log" "$install_dir/var/log/netdata/debug.log" +yunohost service add "$app" --description "Real-time performance and health monitoring" --log "$install_dir/var/log/netdata/error.log" "$install_dir/var/log/netdata/access.log" "$install_dir/var/log/netdata/debug.log" #================================================= # START SYSTEMD SERVICE @@ -50,7 +50,7 @@ yunohost service add $app --description "Real-time performance and health monito ynh_script_progression --message="Starting a systemd service..." --weight=2 # Start a systemd service -ynh_systemd_action --service_name=$app --action="restart" --log_path="$install_dir/var/log/$app/error.log" +ynh_systemd_action --service_name="$app" --action="restart" --log_path="$install_dir/var/log/$app/error.log" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 7f18d7c..4d2ff58 100644 --- a/scripts/remove +++ b/scripts/remove @@ -10,16 +10,13 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# STANDARD REMOVE -#================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST +# REMOVE SYSTEM CONFIGURATIONS #================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # 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..." --weight=2 - yunohost service remove $app +if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then + yunohost service remove "$app" fi # Remove the dedicated NGINX config diff --git a/scripts/restore b/scripts/restore index 041ebc6..ce3653a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -31,34 +31,29 @@ ynh_setup_source --dest_dir="$NETDATA_TMPDIR" # create a temporary file for the log tmplog=$(mktemp /tmp/netdata-updater-log-XXXXXX.log) -pushd $NETDATA_TMPDIR +pushd "$NETDATA_TMPDIR" # the installer.sh script will append "netdata" after the --install-prefix arg - ./netdata-installer.sh --install-prefix /var/www/ --dont-wait --disable-cloud --disable-telemetry --stable-channel >$tmplog 2>$tmplog || ynh_die "FAILED TO COMPILE/INSTALL NETDATA" + ./netdata-installer.sh --install-prefix /var/www/ --dont-wait --disable-cloud --disable-telemetry --stable-channel >"$tmplog" 2>"$tmplog" || ynh_die "FAILED TO COMPILE/INSTALL NETDATA" popd # Specific configuration configure_netdata #================================================= -# RESTORE THE NGINX CONFIGURATION +# RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - -yunohost service add $app --description "Real-time performance and health monitoring" --log "$install_dir/var/log/netdata/error.log" "$install_dir/var/log/netdata/access.log" "$install_dir/var/log/netdata/debug.log" +yunohost service add "$app" --description "Real-time performance and health monitoring" --log "$install_dir/var/log/netdata/error.log" "$install_dir/var/log/netdata/access.log" "$install_dir/var/log/netdata/debug.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="$install_dir/var/log/$app/error.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/var/log/$app/error.log" ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 743ccef..eb4a0d5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -10,45 +10,37 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# CHECK VERSION +# DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= - -upgrade_type=$(ynh_check_app_version_changed) +ynh_script_progression --message="Upgrading source files..." --weight=18 #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Upgrading source files..." --weight=18 +# Download, check integrity, uncompress and patch the source from app.src +NETDATA_TMPDIR=$(mktemp -d) +ynh_setup_source "$NETDATA_TMPDIR" - #================================================= - # DOWNLOAD, CHECK AND UNPACK SOURCE - #================================================= +#================================================= +# SPECIFIC UPGRADE +#================================================= - # Download, check integrity, uncompress and patch the source from app.src - NETDATA_TMPDIR=$(mktemp -d) - ynh_setup_source "$NETDATA_TMPDIR" - - #================================================= - # SPECIFIC UPGRADE - #================================================= - - # signal netdata to start saving its database - # this is handy if your database is big - pids=$(pidof netdata) - [ ! -z "${pids}" ] && kill -USR1 ${pids} - - # create a temporary file for the log - tmplog=$(mktemp /tmp/netdata-updater-log-XXXXXX.log) - - pushd $NETDATA_TMPDIR - # the installer.sh script will append "netdata" after the --install-prefix arg - ./netdata-installer.sh --install-prefix /var/www/ --dont-wait --disable-cloud >$tmplog 2>$tmplog || ynh_die "FAILED TO COMPILE/INSTALL NETDATA" - popd +# signal netdata to start saving its database +# this is handy if your database is big +pids=$(pidof netdata) +if [ -n "${pids}" ]; then + kill -USR1 ${pids} fi +# create a temporary file for the log +tmplog=$(mktemp /tmp/netdata-updater-log-XXXXXX.log) + +pushd "$NETDATA_TMPDIR" + # the installer.sh script will append "netdata" after the --install-prefix arg + ./netdata-installer.sh --install-prefix /var/www/ --dont-wait --disable-cloud >"$tmplog" 2>"$tmplog" || ynh_die "FAILED TO COMPILE/INSTALL NETDATA" +popd + # Specific configuration configure_netdata @@ -60,14 +52,14 @@ ynh_script_progression --message="Upgrading system configurations related to $ap # Create a dedicated NGINX config ynh_add_nginx_config -yunohost service add $app --description "Real-time performance and health monitoring" --log "$install_dir/var/log/netdata/error.log" "$install_dir/var/log/netdata/access.log" "$install_dir/var/log/netdata/debug.log" +yunohost service add "$app" --description "Real-time performance and health monitoring" --log "$install_dir/var/log/netdata/error.log" "$install_dir/var/log/netdata/access.log" "$install_dir/var/log/netdata/debug.log" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="restart" --log_path="$install_dir/var/log/$app/error.log" +ynh_systemd_action --service_name="$app" --action="restart" --log_path="$install_dir/var/log/$app/error.log" #================================================= # END OF SCRIPT diff --git a/tests.toml b/tests.toml index 91daf17..953b195 100644 --- a/tests.toml +++ b/tests.toml @@ -1,7 +1,9 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + test_format = 1.0 [default] # ------------ # Tests to run - # ------------ \ No newline at end of file + # ------------