diff options
Diffstat (limited to 'configuration/debian/tedge_agent/postrm')
-rw-r--r-- | configuration/debian/tedge_agent/postrm | 48 |
1 files changed, 48 insertions, 0 deletions
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# |