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:
+3
-5
@@ -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 ""
|
||||||
|
|||||||
@@ -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,27 +158,38 @@ 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 ""
|
|
||||||
read -p "Remove entire toolkit directory? (yes/no): " remove_dir
|
|
||||||
|
|
||||||
if [ "$remove_dir" = "yes" ]; then
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Removing toolkit directory..."
|
echo "Removing toolkit directory..."
|
||||||
cd /root
|
cd /root
|
||||||
rm -rf "$SCRIPT_DIR"
|
rm -rf "$SCRIPT_DIR"
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "${GREEN}✓ Toolkit completely removed${NC}"
|
echo -e "${GREEN}✓ Toolkit completely removed${NC}"
|
||||||
echo ""
|
|
||||||
echo "All traces have been erased."
|
|
||||||
else
|
else
|
||||||
|
# Manual mode: ask user
|
||||||
echo ""
|
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 ""
|
||||||
echo "Toolkit directory remains at: $SCRIPT_DIR"
|
read -p "Remove entire toolkit directory? (yes/no): " remove_dir
|
||||||
echo "You can manually remove it later with: rm -rf $SCRIPT_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
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
Reference in New Issue
Block a user