From 0d9de5c6a6d1fe7634c3c8997d6414afc616645a Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 6 Jan 2024 20:43:38 +0100 Subject: [PATCH] Update remove script: don't use the official script which is essentially blowing hot air (and removes the system user which then makes yunohost unhappy) --- manifest.toml | 6 ------ scripts/remove | 35 ++++++++++++++++++----------------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/manifest.toml b/manifest.toml index 8ee05d7..2370d06 100644 --- a/manifest.toml +++ b/manifest.toml @@ -52,12 +52,6 @@ ram.runtime = "50M" sha256 = "77e94acf7085c23ab20b2d0d2d4d2bc5a289f121fc7aac5d0daffb960041fd95" autoupdate.strategy = "latest_github_tag" - [resources.sources.uninstaller] - url = "https://raw.githubusercontent.com/netdata/netdata/v1.15.0/packaging/installer/netdata-uninstaller.sh" - sha256 = "a4727069b47138cea5c466bc902934545841c88dc5f641728ef0feb921efd218" - format = "whatever" - rename = "netdata-uninstaller.sh" - [resources.system_user] [resources.install_dir] diff --git a/scripts/remove b/scripts/remove index c0fd58f..7f18d7c 100644 --- a/scripts/remove +++ b/scripts/remove @@ -30,24 +30,25 @@ ynh_remove_nginx_config #================================================= ynh_script_progression --message="Uninstalling Netdata..." --weight=6 -# Prepare to execute uninstaller(generated by NetData install script) -UNINSTALL_SCRIPT="netdata-uninstaller.sh" -tmpdir=$(mktemp -d) +# Kill all netdata processes (essentially what the official uninstaller does) +pkill netdata +pkill -U netdata -ynh_setup_source --dest_dir="$tmpdir" --source_id="uninstaller" -chmod +x $tmpdir/$UNINSTALL_SCRIPT - -# Move outside the directory (which will be removed) -pushd $tmpdir - # create a temporary file for the log - tmplog=$(mktemp /tmp/netdata-uninstaller-log-XXXXXX.log) - - # Execute the uninstall script - ./${UNINSTALL_SCRIPT} --yes --force --env $install_dir/etc/netdata/.environment >$tmplog 2>$tmplog -popd - -# Remove MySQL netdata user -ynh_mysql_execute_as_root "drop user 'netdata'@'localhost'; flush privileges;" +# 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 "/var/log/netdata" +ynh_secure_remove "/etc/netdata" #================================================= # END OF SCRIPT