From 7f0ae8b8c839667c8a5f0ef624f1853c5d3f7f91 Mon Sep 17 00:00:00 2001 From: zig Date: Wed, 27 Jan 2021 03:06:07 -0600 Subject: [PATCH 1/2] Automates uninstallation method --- uninstall.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 uninstall.sh diff --git a/uninstall.sh b/uninstall.sh new file mode 100755 index 00000000..b1a05920 --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +set -e + +uninstall_logid() { + if [ 1 -gt ${#1} ]; then + printf '%s\n' "No manifest_path detected for uninstall" + exit 1 + fi + local manifest_path="$1" + echo "manifest_path is $manifest_path" + while IFS= read -r line; do + printf '%s\n' "Removing $line.." + rm "$line" + done < <(cat "$manifest_path") + + printf '%s\n' "Uninstall complete" +} + +get_manifest_path() { + local manifest_path=$(find . -name 'install-manifest.txt' -type f -print) + if [ 1 -lt ${#manifest_path} ]; then + printf '%s\n' "This repo has not been built yet. Please build it to generate install-manifest.txt" + exit 1 + fi + echo "$manifest_path" +} + +disable_daemon() { + systemctl status logid 2>&1 /dev/null + if [ 0 -ne $? ]; then + printf '%s\n' "Unable to detect logid daemon in systemctl. Exiting..." + exit 1 + fi + sudo systemctl disable logid +} + +# MAIN +project_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +cd "$project_dir" +manifest_path=$(get_manifest_path) +uninstall_logid "$manifest_path" +disable_daemon + +printf '%s\n' "Completed uninstall successfully" + + From 8c6509f313b90ca54e0b2bb5b2ccc078f462d7fa Mon Sep 17 00:00:00 2001 From: zig Date: Wed, 27 Jan 2021 03:16:44 -0600 Subject: [PATCH 2/2] Continues uninstall attempt even after one part fails --- uninstall.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/uninstall.sh b/uninstall.sh index b1a05920..3408f7dc 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -4,8 +4,8 @@ set -e uninstall_logid() { if [ 1 -gt ${#1} ]; then - printf '%s\n' "No manifest_path detected for uninstall" - exit 1 + printf '%s\n' "No manifest_path detected for uninstall. Skipping..." + return fi local manifest_path="$1" echo "manifest_path is $manifest_path" @@ -20,19 +20,19 @@ uninstall_logid() { get_manifest_path() { local manifest_path=$(find . -name 'install-manifest.txt' -type f -print) if [ 1 -lt ${#manifest_path} ]; then - printf '%s\n' "This repo has not been built yet. Please build it to generate install-manifest.txt" - exit 1 + printf '%s\n' "This repo has not been built yet. Please build it to generate install-manifest.txt. Continuing..." + return fi echo "$manifest_path" } disable_daemon() { - systemctl status logid 2>&1 /dev/null + systemctl status logid 2> /dev/null if [ 0 -ne $? ]; then printf '%s\n' "Unable to detect logid daemon in systemctl. Exiting..." exit 1 fi - sudo systemctl disable logid + sudo systemctl disable logid 2> /dev/null } # MAIN @@ -42,6 +42,6 @@ manifest_path=$(get_manifest_path) uninstall_logid "$manifest_path" disable_daemon -printf '%s\n' "Completed uninstall successfully" +printf '%s\n' "Completed uninstall"