From b06bcf2a80775b3fcff8eaa9857e6071801343a8 Mon Sep 17 00:00:00 2001 From: Alex Solomes Date: Mon, 4 Oct 2021 12:02:16 +0100 Subject: postrm update to remove leftover files after purge [CIT-556] (#460) * postrm rm users, groups, logs, .d files [CIT-556] Signed-off-by: Alex Solomes * added case statement & purge/remove logic [CIT-556] Signed-off-by: Alex Solomes * removing sudoers file [CIT-556] Signed-off-by: Alex Solomes * remove sudoers from tedge-agent [CIT-556] Signed-off-by: Alex Solomes --- configuration/debian/tedge_agent/postrm | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 configuration/debian/tedge_agent/postrm (limited to 'configuration/debian/tedge_agent/postrm') diff --git a/configuration/debian/tedge_agent/postrm b/configuration/debian/tedge_agent/postrm new file mode 100644 index 00000000..2c54bb97 --- /dev/null +++ b/configuration/debian/tedge_agent/postrm @@ -0,0 +1,48 @@ +#!/bin/sh +set -e + +remove_tedge_agent_user() { + if getent passwd tedge-agent >/dev/null; then + pkill -u tedge-agent || true + deluser --quiet --system tedge-agent + fi +} + +remove_sudoers_file() { + if [ -f "/etc/sudoers.d/tedge-agent" ]; then + rm /etc/sudoers.d/tedge-agent + fi + + if [ -f "/etc/sudoers.d/010_pi-nopasswd" ]; then + rm /etc/sudoers.d/010_pi-nopasswd + fi +} + +purge_agent_directory() { + if [ -d "/etc/tedge/.agent" ]; then + rm -rf /etc/tedge/.agent + fi +} + +case "$1" in + purge) + remove_tedge_agent_user + remove_sudoers_file + purge_agent_directory + ;; + + remove) + remove_tedge_agent_user + remove_sudoers_file + ;; + + upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + *) + echo "tedge postrm called with unknown argument \`$1\`" >&2 + exit 1 + ;; +esac + +#DEBHELPER# -- cgit v1.2.3