From 9365ed8bf622ed43c0533a63707195ff30460465 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sat, 31 Aug 2024 01:10:02 +0200 Subject: [PATCH] [autopatch] Automatic patch attempt for helpers 2.1 --- manifest.toml | 3 ++- scripts/_common.sh | 14 +++++--------- scripts/backup | 17 ++++------------- scripts/change_url | 26 ++++++++------------------ scripts/install | 26 ++++++++++---------------- scripts/remove | 44 +++++++++++++++++++------------------------- scripts/restore | 30 ++++++++++++------------------ scripts/upgrade | 26 +++++++++----------------- 8 files changed, 69 insertions(+), 117 deletions(-) diff --git a/manifest.toml b/manifest.toml index 983d29e..e536b84 100644 --- a/manifest.toml +++ b/manifest.toml @@ -23,7 +23,8 @@ not-totally-free-upstream.en = "Netdata now includes a dependencie to a UI which not-totally-free-upstream.fr = "Netdata inclut maintenant une dépendance à une interface utilisateur qui est sous une licence bizarre qui interdit la rétro-ingénierie ou la personnalisation. Voir : https://github.com/YunoHost/apps/pull/2519" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = false diff --git a/scripts/_common.sh b/scripts/_common.sh index 0e25271..2d470f6 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,11 +1,7 @@ #!/bin/bash #================================================= -# COMMON VARIABLES -#================================================= - -#================================================= -# PERSONAL HELPERS +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= # Configure NetData @@ -28,9 +24,9 @@ configure_netdata() { netdata_add_yunohost_postgres_configuration # Create netdata user to monitor MySQL (if needed) - is_mysql_user_existing=$(ynh_mysql_execute_as_root --sql="select user from mysql.user where user = 'netdata';") + is_mysql_user_existing=$(ynh_mysql_db_shell <<< "select user from mysql.user where user = 'netdata';") if [ -z "$is_mysql_user_existing" ] ; then - ynh_mysql_execute_as_root --sql="create user 'netdata'@'localhost'; + ynh_mysql_db_shell <<< "create user 'netdata'@'localhost'; grant usage on *.* to 'netdata'@'localhost' with grant option; flush privileges;" fi @@ -75,7 +71,7 @@ EOF chgrp netdata $web_log_file # Manage upgrade case from python to go plugin if [ -f "$install_dir/etc/netdata/python.d/web_log.conf" ] ; then - ynh_secure_remove --file="$install_dir/etc/netdata/python.d/web_log.conf" + ynh_safe_rm "$install_dir/etc/netdata/python.d/web_log.conf" fi } @@ -95,6 +91,6 @@ EOF chgrp netdata $postgres_file # Manage upgrade case from python to go plugin if [ -f "$install_dir/etc/netdata/python.d/postgres.conf" ] ; then - ynh_secure_remove --file="$install_dir/etc/netdata/python.d/postgres.conf" + ynh_safe_rm "$install_dir/etc/netdata/python.d/postgres.conf" fi } diff --git a/scripts/backup b/scripts/backup index d00af66..4f8a074 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,34 +1,25 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -ynh_print_info --message="Declaring files to be backed up..." +ynh_print_info "Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$install_dir/etc/netdata" +ynh_backup "$install_dir/etc/netdata" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info "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 68591f6..cd3439b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,48 +1,38 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD MODIFICATIONS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemctl --service="$app" --action="stop" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx #================================================= # SPECIFIC MODIFICATIONS #================================================= # Change registry link -ynh_replace_string --match_string="registry to announce = https://$old_domain$old_path" --replace_string="registry to announce = https://$new_domain$new_path" --target_file="$install_dir/etc/netdata/netdata.conf" +ynh_replace --match="registry to announce = https://$old_domain$old_path" --replace="registry to announce = https://$new_domain$new_path" --file="$install_dir/etc/netdata/netdata.conf" -#================================================= -# GENERIC FINALISATION #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="restart" --log_path="$install_dir/var/log/$app/error.log" +ynh_systemctl --service="$app" --action="restart" --log_path="$install_dir/var/log/$app/error.log" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index bf92c3f..b28480c 100644 --- a/scripts/install +++ b/scripts/install @@ -1,18 +1,12 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=11 +ynh_script_progression "Setting up source files..." # Download, check integrity, uncompress and patch the source from app.src NETDATA_TMPDIR="$install_dir/netdata_install" @@ -25,18 +19,18 @@ ynh_setup_source --source_id="go" --dest_dir="$GO_TMPDIR" #================================================= # BUILD #================================================= -ynh_script_progression --message="Executing Netdata installer..." --weight=10 +ynh_script_progression "Executing Netdata installer..." export PATH="$GO_TMPDIR/bin:$PATH" export GOPATH="$GO_TMPDIR/go/" export HOME=${HOME:-"/root/"} pushd "$NETDATA_TMPDIR" # the installer.sh script will append "netdata" after the --install-prefix arg - ynh_exec_warn_less ./netdata-installer.sh --install-prefix /var/www/ --dont-wait --disable-cloud --disable-telemetry --stable-channel + ynh_hide_warnings ./netdata-installer.sh --install-prefix /var/www/ --dont-wait --disable-cloud --disable-telemetry --stable-channel popd -ynh_secure_remove --file=$NETDATA_TMPDIR -ynh_secure_remove --file=$GO_TMPDIR +ynh_safe_rm $NETDATA_TMPDIR +ynh_safe_rm $GO_TMPDIR # Specific configuration configure_netdata @@ -44,23 +38,23 @@ configure_netdata #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 +ynh_script_progression "Adding system configurations related to $app..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx 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=2 +ynh_script_progression "Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name="$app" --action="restart" --log_path="$install_dir/var/log/$app/error.log" +ynh_systemctl --service="$app" --action="restart" --log_path="$install_dir/var/log/$app/error.log" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last \ No newline at end of file +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index a56bbd2..1596ad9 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,55 +1,49 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 +ynh_script_progression "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 +if ynh_hide_warnings yunohost service status "$app" >/dev/null; then yunohost service remove "$app" fi # Remove the dedicated NGINX config -ynh_remove_nginx_config +ynh_config_remove_nginx -ynh_systemd_action --service_name="$app" --action="stop" +ynh_systemctl --service="$app" --action="stop" #================================================= # UNINSTALLING NETDATA #================================================= -ynh_script_progression --message="Uninstalling Netdata..." --weight=6 +ynh_script_progression "Uninstalling Netdata..." # Kill all netdata processes (essentially what the official uninstaller does) pkill netdata pkill -U netdata # Rm all files that netdata may have installed (this is copypasta of the official uninstaller script) -ynh_secure_remove /etc/logrotate.d/netdata -ynh_secure_remove /etc/systemd/system/netdata.service -ynh_secure_remove /lib/systemd/system/netdata.service -ynh_secure_remove /usr/lib/systemd/system/netdata.service -ynh_secure_remove /etc/init.d/netdata -ynh_secure_remove /etc/periodic/daily/netdata-updater -ynh_secure_remove /etc/cron.daily/netdata-updater -ynh_secure_remove "/usr/sbin/netdata" -ynh_secure_remove "/usr/share/netdata" -ynh_secure_remove "/usr/libexec/netdata" -ynh_secure_remove "/var/lib/netdata" -ynh_secure_remove "/var/cache/netdata" -ynh_secure_remove "/etc/netdata" +ynh_safe_rm /etc/logrotate.d/netdata +ynh_safe_rm /etc/systemd/system/netdata.service +ynh_safe_rm /lib/systemd/system/netdata.service +ynh_safe_rm /usr/lib/systemd/system/netdata.service +ynh_safe_rm /etc/init.d/netdata +ynh_safe_rm /etc/periodic/daily/netdata-updater +ynh_safe_rm /etc/cron.daily/netdata-updater +ynh_safe_rm "/usr/sbin/netdata" +ynh_safe_rm "/usr/share/netdata" +ynh_safe_rm "/usr/libexec/netdata" +ynh_safe_rm "/var/lib/netdata" +ynh_safe_rm "/var/cache/netdata" +ynh_safe_rm "/etc/netdata" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index d26f6d3..77aee3e 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -15,14 +9,14 @@ source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring Netdata configuration directory..." --weight=1 +ynh_script_progression "Restoring Netdata configuration directory..." -ynh_restore_file --origin_path="$install_dir/etc/netdata" +ynh_restore "$install_dir/etc/netdata" #================================================= # INSTALL AND RESTORE THE APP CONFIGURATION #================================================= -ynh_script_progression --message="Reinstalling Netdata..." --weight=18 +ynh_script_progression "Reinstalling Netdata..." # Download, check integrity, uncompress and patch the source from app.src NETDATA_TMPDIR="$install_dir/netdata_install" @@ -37,11 +31,11 @@ export GOPATH="$GO_TMPDIR/go/" export HOME=${HOME:-"/root/"} pushd "$NETDATA_TMPDIR" # the installer.sh script will append "netdata" after the --install-prefix arg - ynh_exec_warn_less ./netdata-installer.sh --install-prefix /var/www/ --dont-wait --disable-cloud --disable-telemetry --stable-channel + ynh_hide_warnings ./netdata-installer.sh --install-prefix /var/www/ --dont-wait --disable-cloud --disable-telemetry --stable-channel popd -ynh_secure_remove --file=$NETDATA_TMPDIR -ynh_secure_remove --file=$GO_TMPDIR +ynh_safe_rm $NETDATA_TMPDIR +ynh_safe_rm $GO_TMPDIR # Specific configuration configure_netdata @@ -49,23 +43,23 @@ configure_netdata #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 +ynh_script_progression "Restoring system configurations related to $app..." -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" 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="Reloading NGINX web server and $app's service..." --weight=1 +ynh_script_progression "Reloading NGINX web server and $app's service..." -ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/var/log/$app/error.log" +ynh_systemctl --service="$app" --action="start" --log_path="$install_dir/var/log/$app/error.log" -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 1109e6a..8e9ca6e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,18 +1,12 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Upgrading source files..." --weight=18 +ynh_script_progression "Upgrading source files..." #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -26,8 +20,6 @@ GO_TMPDIR="$install_dir/go_install" mkdir -p $GO_TMPDIR ynh_setup_source --source_id="go" --dest_dir="$GO_TMPDIR" -#================================================= -# SPECIFIC UPGRADE #================================================= # signal netdata to start saving its database @@ -42,11 +34,11 @@ export GOPATH="$GO_TMPDIR/go/" export HOME=${HOME:-"/root/"} pushd "$NETDATA_TMPDIR" # the installer.sh script will append "netdata" after the --install-prefix arg - ynh_exec_warn_less ./netdata-installer.sh --install-prefix /var/www/ --dont-wait --disable-cloud --disable-telemetry --stable-channel + ynh_hide_warnings ./netdata-installer.sh --install-prefix /var/www/ --dont-wait --disable-cloud --disable-telemetry --stable-channel popd -ynh_secure_remove --file=$NETDATA_TMPDIR -ynh_secure_remove --file=$GO_TMPDIR +ynh_safe_rm $NETDATA_TMPDIR +ynh_safe_rm $GO_TMPDIR # Specific configuration configure_netdata @@ -54,22 +46,22 @@ configure_netdata #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 +ynh_script_progression "Upgrading system configurations related to $app..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx 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 "Starting $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="restart" --log_path="$install_dir/var/log/$app/error.log" +ynh_systemctl --service="$app" --action="restart" --log_path="$install_dir/var/log/$app/error.log" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed"