diff options
Diffstat (limited to 'packaging/installer/netdata-uninstaller.sh')
-rwxr-xr-x | packaging/installer/netdata-uninstaller.sh | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/packaging/installer/netdata-uninstaller.sh b/packaging/installer/netdata-uninstaller.sh index 4326ebe2..1627ca6b 100755 --- a/packaging/installer/netdata-uninstaller.sh +++ b/packaging/installer/netdata-uninstaller.sh @@ -520,6 +520,15 @@ portable_del_user_from_group() { groupname="${1}" username="${2}" + if command -v getent > /dev/null 2>&1; then + getent group "${1:-""}" | grep -q "${2}" + else + grep "^${1}:" /etc/group | grep -q "${2}" + fi + + ret=$? + [ "${ret}" != "0" ] && return 0 + # username is not in group info "Deleting ${username} user from ${groupname} group ..." @@ -714,6 +723,10 @@ trap quit_msg EXIT info "Stopping a possibly running netdata..." stop_all_netdata +if [ "$(uname -s)" = "Darwin" ]; then + launchctl unload /Library/LaunchDaemons/com.github.netdata.plist 2>/dev/null +fi + #### REMOVE NETDATA FILES rm_file /etc/logrotate.d/netdata rm_file /etc/systemd/system/netdata.service @@ -732,6 +745,7 @@ rm_file /etc/periodic/daily/netdata-updater rm_file /etc/cron.daily/netdata-updater rm_file /etc/cron.d/netdata-updater rm_file /etc/cron.d/netdata-updater-daily +rm_file /Library/LaunchDaemons/com.github.netdata.plist if [ -n "${NETDATA_PREFIX}" ] && [ -d "${NETDATA_PREFIX}" ] && [ "netdata" = "$(basename "$NETDATA_PREFIX")" ] ; then @@ -758,8 +772,10 @@ fi FILE_REMOVAL_STATUS=1 -#### REMOVE NETDATA USER FROM ADDED GROUPS -if [ -n "$NETDATA_ADDED_TO_GROUPS" ]; then +#### REMOVE USER +if user_input "Do you want to delete 'netdata' system user ? "; then + portable_del_user "netdata" || : +elif [ -n "$NETDATA_ADDED_TO_GROUPS" ]; then if user_input "Do you want to delete 'netdata' from following groups: '$NETDATA_ADDED_TO_GROUPS' ? "; then for group in $NETDATA_ADDED_TO_GROUPS; do portable_del_user_from_group "${group}" "netdata" @@ -767,11 +783,6 @@ if [ -n "$NETDATA_ADDED_TO_GROUPS" ]; then fi fi -#### REMOVE USER -if user_input "Do you want to delete 'netdata' system user ? "; then - portable_del_user "netdata" || : -fi - ### REMOVE GROUP if user_input "Do you want to delete 'netdata' system group ? "; then portable_del_group "netdata" || : |