Simplify exit cleanup - one question, full cleanup
Changes: - Single question on exit: 'Clean history and remove traces?' - If yes: runs full trace eraser automatically - Auto mode skips all prompts, removes everything - TRACE_ERASER_AUTO=yes flag for non-interactive mode User experience: - Exit (0) - One question - If yes: everything cleaned and removed automatically - No multiple prompts
This commit is contained in:
@@ -12,28 +12,23 @@ source "$SCRIPT_DIR/lib/common-functions.sh" 2>/dev/null || true
|
||||
|
||||
print_banner "Toolkit Trace Eraser"
|
||||
|
||||
echo ""
|
||||
echo "This will remove all traces of the Server Toolkit from:"
|
||||
echo " • Bash history (all toolkit-related commands)"
|
||||
echo " • System logs (toolkit operations)"
|
||||
echo " • Download records"
|
||||
echo " • Temporary files"
|
||||
echo ""
|
||||
echo -e "${YELLOW}TIP: Prevent history recording in the first place!${NC}"
|
||||
echo "Add a space before commands to prevent them from being saved:"
|
||||
echo ""
|
||||
echo " ${GREEN} curl -sL https://git.mull.lol/.../archive/main.tar.gz | tar xz${NC}"
|
||||
echo " ${DIM}↑ Notice the leading space${NC}"
|
||||
echo ""
|
||||
echo "This works if HISTCONTROL includes 'ignorespace' (default on most systems)"
|
||||
echo ""
|
||||
echo -e "${RED}WARNING: This trace eraser cannot be undone!${NC}"
|
||||
echo ""
|
||||
read -p "Are you sure you want to proceed? (yes/no): " confirm
|
||||
# Check if running in auto mode (from launcher exit)
|
||||
if [ "$TRACE_ERASER_AUTO" != "yes" ]; then
|
||||
echo ""
|
||||
echo "This will remove all traces of the Server Toolkit from:"
|
||||
echo " • Bash history (all toolkit-related commands)"
|
||||
echo " • System logs (toolkit operations)"
|
||||
echo " • Download records"
|
||||
echo " • Temporary files"
|
||||
echo ""
|
||||
echo -e "${RED}WARNING: This cannot be undone!${NC}"
|
||||
echo ""
|
||||
read -p "Are you sure you want to proceed? (yes/no): " confirm
|
||||
|
||||
if [ "$confirm" != "yes" ]; then
|
||||
echo "Cancelled."
|
||||
exit 0
|
||||
if [ "$confirm" != "yes" ]; then
|
||||
echo "Cancelled."
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
@@ -163,27 +158,38 @@ if [ "$CLEAN_HISTORY" = true ] && [ -f ~/.bash_history ]; then
|
||||
fi
|
||||
|
||||
# Offer to remove the entire toolkit (AFTER history cleaning)
|
||||
echo ""
|
||||
echo -e "${YELLOW}Final step: Remove toolkit directory?${NC}"
|
||||
echo "This will delete: $SCRIPT_DIR"
|
||||
echo ""
|
||||
read -p "Remove entire toolkit directory? (yes/no): " remove_dir
|
||||
|
||||
if [ "$remove_dir" = "yes" ]; then
|
||||
if [ "$TRACE_ERASER_AUTO" = "yes" ]; then
|
||||
# Auto mode: always remove directory and skip prompt
|
||||
echo ""
|
||||
echo "Removing toolkit directory..."
|
||||
cd /root
|
||||
rm -rf "$SCRIPT_DIR"
|
||||
echo ""
|
||||
echo -e "${GREEN}✓ Toolkit completely removed${NC}"
|
||||
echo ""
|
||||
echo "All traces have been erased."
|
||||
else
|
||||
# Manual mode: ask user
|
||||
echo ""
|
||||
echo -e "${GREEN}✓ History and logs cleaned${NC}"
|
||||
echo -e "${YELLOW}Final step: Remove toolkit directory?${NC}"
|
||||
echo "This will delete: $SCRIPT_DIR"
|
||||
echo ""
|
||||
echo "Toolkit directory remains at: $SCRIPT_DIR"
|
||||
echo "You can manually remove it later with: rm -rf $SCRIPT_DIR"
|
||||
read -p "Remove entire toolkit directory? (yes/no): " remove_dir
|
||||
|
||||
if [ "$remove_dir" = "yes" ]; then
|
||||
echo ""
|
||||
echo "Removing toolkit directory..."
|
||||
cd /root
|
||||
rm -rf "$SCRIPT_DIR"
|
||||
echo ""
|
||||
echo -e "${GREEN}✓ Toolkit completely removed${NC}"
|
||||
echo ""
|
||||
echo "All traces have been erased."
|
||||
else
|
||||
echo ""
|
||||
echo -e "${GREEN}✓ History and logs cleaned${NC}"
|
||||
echo ""
|
||||
echo "Toolkit directory remains at: $SCRIPT_DIR"
|
||||
echo "You can manually remove it later with: rm -rf $SCRIPT_DIR"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user