Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NodeQuery Agent Removal Script #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions nq-uninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
#
# NodeQuery Agent Removal Script
#
# Set environment
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

# Prepare output
echo -e "|\n| NodeQuery Uninstaller\n| ===================\n|"

# Root required
if [ $(id -u) != "0" ];
then
echo -e "| Error: You need to be root to uninstall the NodeQuery agent\n|"
exit 1
fi

# Attempt to delete previous agent
if [ -f /etc/nodequery/nq-agent.sh ]
then

# Remove cron entry and user
if id -u nodequery >/dev/null 2>&1
then
# Show Feedback
echo -e "|\n| nodequery user [FOUND]\n|"

(crontab -u nodequery -l | grep -v "/etc/nodequery/nq-agent.sh") | crontab -u nodequery - && userdel nodequery

# Show Feedback
echo -e "|\n| nodequery user & cron [DELETED]\n|"
fi

# Show Feedback
echo -e "|\n| /etc/nodequery/nq-agent.sh [FOUND]\n|"

# Remove agent dir
rm -Rf /etc/nodequery

# Show Feedback
echo -e "|\n| /etc/nodequery [DELETED]\n|"

else

# Show Feedback
echo -e "|\n| /etc/nodequery/nq-agent.sh not found\n|"

fi