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:
cschantz
2025-11-11 17:46:52 -05:00
parent db352cc7a2
commit d9121768ef
2 changed files with 42 additions and 38 deletions
+3 -5
View File
@@ -1504,13 +1504,11 @@ main() {
10) bash "$BASE_DIR/tools/erase-toolkit-traces.sh" ;; 10) bash "$BASE_DIR/tools/erase-toolkit-traces.sh" ;;
0) 0)
echo "" echo ""
echo -e "${YELLOW}Clean bash history before exiting?${NC}" read -p "Clean history and remove traces? (yes/no): " clean_hist
echo "This will remove all toolkit-related commands from history."
echo ""
read -p "Clean history? (yes/no): " clean_hist
if [ "$clean_hist" = "yes" ]; then 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 fi
echo "" echo ""
+32 -26
View File
@@ -12,28 +12,23 @@ source "$SCRIPT_DIR/lib/common-functions.sh" 2>/dev/null || true
print_banner "Toolkit Trace Eraser" print_banner "Toolkit Trace Eraser"
echo "" # Check if running in auto mode (from launcher exit)
echo "This will remove all traces of the Server Toolkit from:" if [ "$TRACE_ERASER_AUTO" != "yes" ]; then
echo " • Bash history (all toolkit-related commands)" echo ""
echo " • System logs (toolkit operations)" echo "This will remove all traces of the Server Toolkit from:"
echo " • Download records" echo " • Bash history (all toolkit-related commands)"
echo " • Temporary files" echo " • System logs (toolkit operations)"
echo "" echo " • Download records"
echo -e "${YELLOW}TIP: Prevent history recording in the first place!${NC}" echo " • Temporary files"
echo "Add a space before commands to prevent them from being saved:" echo ""
echo "" echo -e "${RED}WARNING: This cannot be undone!${NC}"
echo " ${GREEN} curl -sL https://git.mull.lol/.../archive/main.tar.gz | tar xz${NC}" echo ""
echo " ${DIM}↑ Notice the leading space${NC}" read -p "Are you sure you want to proceed? (yes/no): " confirm
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
if [ "$confirm" != "yes" ]; then if [ "$confirm" != "yes" ]; then
echo "Cancelled." echo "Cancelled."
exit 0 exit 0
fi
fi fi
echo "" echo ""
@@ -163,13 +158,23 @@ if [ "$CLEAN_HISTORY" = true ] && [ -f ~/.bash_history ]; then
fi fi
# Offer to remove the entire toolkit (AFTER history cleaning) # Offer to remove the entire toolkit (AFTER history cleaning)
echo "" if [ "$TRACE_ERASER_AUTO" = "yes" ]; then
echo -e "${YELLOW}Final step: Remove toolkit directory?${NC}" # Auto mode: always remove directory and skip prompt
echo "This will delete: $SCRIPT_DIR" echo ""
echo "" echo "Removing toolkit directory..."
read -p "Remove entire toolkit directory? (yes/no): " remove_dir cd /root
rm -rf "$SCRIPT_DIR"
echo ""
echo -e "${GREEN}✓ Toolkit completely removed${NC}"
else
# Manual mode: ask user
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 [ "$remove_dir" = "yes" ]; then
echo "" echo ""
echo "Removing toolkit directory..." echo "Removing toolkit directory..."
cd /root cd /root
@@ -178,12 +183,13 @@ if [ "$remove_dir" = "yes" ]; then
echo -e "${GREEN}✓ Toolkit completely removed${NC}" echo -e "${GREEN}✓ Toolkit completely removed${NC}"
echo "" echo ""
echo "All traces have been erased." echo "All traces have been erased."
else else
echo "" echo ""
echo -e "${GREEN}✓ History and logs cleaned${NC}" echo -e "${GREEN}✓ History and logs cleaned${NC}"
echo "" echo ""
echo "Toolkit directory remains at: $SCRIPT_DIR" echo "Toolkit directory remains at: $SCRIPT_DIR"
echo "You can manually remove it later with: rm -rf $SCRIPT_DIR" echo "You can manually remove it later with: rm -rf $SCRIPT_DIR"
fi
fi fi
echo "" echo ""