From 63928cd8f97722a7ae9a48e5ebf94dd4e18067bf Mon Sep 17 00:00:00 2001 From: cschantz Date: Tue, 11 Nov 2025 17:46:52 -0500 Subject: [PATCH] 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 --- launcher.sh | 8 ++-- tools/erase-toolkit-traces.sh | 72 +++++++++++++++++++---------------- 2 files changed, 42 insertions(+), 38 deletions(-) diff --git a/launcher.sh b/launcher.sh index ab242f2..305df4d 100755 --- a/launcher.sh +++ b/launcher.sh @@ -1504,13 +1504,11 @@ main() { 10) bash "$BASE_DIR/tools/erase-toolkit-traces.sh" ;; 0) echo "" - echo -e "${YELLOW}Clean bash history before exiting?${NC}" - echo "This will remove all toolkit-related commands from history." - echo "" - read -p "Clean history? (yes/no): " clean_hist + read -p "Clean history and remove traces? (yes/no): " clean_hist if [ "$clean_hist" = "yes" ]; then - bash "$BASE_DIR/tools/erase-toolkit-traces.sh" + # Run trace eraser in non-interactive mode + TRACE_ERASER_AUTO=yes bash "$BASE_DIR/tools/erase-toolkit-traces.sh" fi echo "" diff --git a/tools/erase-toolkit-traces.sh b/tools/erase-toolkit-traces.sh index cb5c050..7fc3b59 100755 --- a/tools/erase-toolkit-traces.sh +++ b/tools/erase-toolkit-traces.sh @@ -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 ""