From 40ac3e7eb746c1891294c60a20ed2cf7f97e6432 Mon Sep 17 00:00:00 2001 From: pvogt09 <50047961+pvogt09@users.noreply.github.com> Date: Fri, 3 Apr 2020 20:07:44 +0200 Subject: [PATCH] remove pihole group during uninstall Signed-off-by: pvogt09 <50047961+pvogt09@users.noreply.github.com> --- automated install/basic-install.sh | 4 ++-- automated install/uninstall.sh | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 4474d37e..1070a7a3 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1771,7 +1771,7 @@ create_pihole_user() { # If the user pihole exists, if id -u pihole &> /dev/null; then # if group exists - if getent group pihole; then + if getent group pihole > /dev/null 2>&1; then # just show a success printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}" else @@ -1799,7 +1799,7 @@ create_pihole_user() { local str="Creating user 'pihole'" printf "%b %b %s..." "${OVER}" "${INFO}" "${str}" # create her with the useradd command - if getent group pihole; then + if getent group pihole > /dev/null 2>&1; then # add primary group pihole as it already exists if useradd -r --no-user-group -g pihole -s /usr/sbin/nologin pihole; then printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}" diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 01ce9c39..5dab2136 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -188,6 +188,14 @@ removeNoPurge() { echo -e " ${CROSS} Unable to remove 'pihole' user" fi fi + # If the pihole group exists, then remove + if getent group "pihole" &> /dev/null; then + if ${SUDO} groupdel pihole 2> /dev/null; then + echo -e " ${TICK} Removed 'pihole' group" + else + echo -e " ${CROSS} Unable to remove 'pihole' group" + fi + fi echo -e "\\n We're sorry to see you go, but thanks for checking out Pi-hole! If you need help, reach out to us on Github, Discourse, Reddit or Twitter