Add cancel/back options to all user input prompts

Changes:
- Added "0) Cancel" option to all menu prompts
- Added "(or 0 to cancel)" to all text input prompts
- Ensures users can back out of any operation at any time
- Scripts affected:
  - website-error-analyzer.sh (scope selection, time range)
  - 500-error-tracker.sh (time range selection)
  - wordpress-cron-manager.sh (all domain/user input prompts, status checks)

User Experience Improvements:
- No more being trapped in prompts
- Clear cancel instructions on every input
- Consistent "Operation cancelled" messaging
- Proper exit codes (0 for user cancellation)

Tested:
✓ website-error-analyzer.sh - cancel on scope selection
✓ 500-error-tracker.sh - cancel on time selection
✓ wordpress-cron-manager.sh - cancel on domain/user input
✓ All cancellations return cleanly to menu

🤖 Generated with Claude Code
https://claude.com/claude-code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
cschantz
2025-11-07 17:42:11 -05:00
parent b9ce90c812
commit 56776a1c60
3 changed files with 69 additions and 22 deletions
+7
View File
@@ -26,11 +26,18 @@ echo -e "${CYAN}How far back to scan?${NC}"
echo " 1) Last 24 hours (default)"
echo " 2) Last 7 days"
echo " 3) Last 30 days"
echo " 0) Cancel and return to menu"
echo ""
read -p "Select option [1]: " time_choice
time_choice=${time_choice:-1}
case $time_choice in
0)
echo ""
echo "Scan cancelled."
echo ""
exit 0
;;
1) HOURS_TO_SCAN=24 ;;
2) HOURS_TO_SCAN=168 ;;
3) HOURS_TO_SCAN=720 ;;
+26 -3
View File
@@ -47,26 +47,42 @@ echo -e "${CYAN}Analysis Scope:${NC}"
echo " 1) All users/domains (default)"
echo " 2) Specific cPanel user"
echo " 3) Specific domain"
echo " 0) Cancel and return to menu"
echo ""
read -p "Select option [1]: " scope_choice
scope_choice=${scope_choice:-1}
case $scope_choice in
0)
echo ""
echo "Analysis cancelled."
echo ""
exit 0
;;
2)
# Select specific user
select_user_interactive "Select cPanel user to analyze"
if [ -n "$SELECTED_USER" ]; then
FILTER_USER="$SELECTED_USER"
echo "→ Filtering for user: $FILTER_USER"
else
echo ""
echo "No user selected. Analysis cancelled."
echo ""
exit 0
fi
;;
3)
# Enter specific domain
echo ""
read -p "Enter domain name (e.g., example.com): " FILTER_DOMAIN
if [ -n "$FILTER_DOMAIN" ]; then
echo "→ Filtering for domain: $FILTER_DOMAIN"
read -p "Enter domain name (e.g., example.com) or 0 to cancel: " FILTER_DOMAIN
if [ "$FILTER_DOMAIN" = "0" ] || [ -z "$FILTER_DOMAIN" ]; then
echo ""
echo "Analysis cancelled."
echo ""
exit 0
fi
echo "→ Filtering for domain: $FILTER_DOMAIN"
;;
*)
echo "→ Analyzing all users/domains"
@@ -82,11 +98,18 @@ echo " 2) Last 6 hours"
echo " 3) Last 24 hours (default)"
echo " 4) Last 7 days"
echo " 5) Last 30 days"
echo " 0) Cancel and return to menu"
echo ""
read -p "Select option [3]: " time_choice
time_choice=${time_choice:-3}
case $time_choice in
0)
echo ""
echo "Analysis cancelled."
echo ""
exit 0
;;
1) HOURS_TO_ANALYZE=1 ;;
2) HOURS_TO_ANALYZE=6 ;;
3) HOURS_TO_ANALYZE=24 ;;
@@ -199,13 +199,13 @@ case "$choice" in
2)
# Disable wp-cron for specific domain
echo ""
echo -n "Enter domain name: "
echo -n "Enter domain name (or 0 to cancel): "
read -r domain
if [ -z "$domain" ]; then
print_error "Domain cannot be empty"
if [ -z "$domain" ] || [ "$domain" = "0" ]; then
echo "Operation cancelled."
press_enter
exit 1
exit 0
fi
# Find WordPress installation for this domain
@@ -289,13 +289,13 @@ case "$choice" in
3)
# Disable wp-cron for specific user
echo ""
echo -n "Enter cPanel username: "
echo -n "Enter cPanel username (or 0 to cancel): "
read -r target_user
if [ -z "$target_user" ]; then
print_error "Username cannot be empty"
if [ -z "$target_user" ] || [ "$target_user" = "0" ]; then
echo "Operation cancelled."
press_enter
exit 1
exit 0
fi
if [ ! -d "/home/$target_user" ]; then
@@ -432,16 +432,27 @@ case "$choice" in
echo "Check wp-cron status for:"
echo " 1) Specific domain"
echo " 2) Specific user"
echo " 0) Cancel"
echo ""
echo -n "Select [1]: "
read -r check_choice
check_choice="${check_choice:-1}"
if [ "$check_choice" = "1" ]; then
if [ "$check_choice" = "0" ]; then
echo "Operation cancelled."
press_enter
exit 0
elif [ "$check_choice" = "1" ]; then
echo ""
echo -n "Enter domain name: "
echo -n "Enter domain name (or 0 to cancel): "
read -r domain
if [ -z "$domain" ] || [ "$domain" = "0" ]; then
echo "Operation cancelled."
press_enter
exit 0
fi
# Find WordPress for domain
wp_config=""
for userdata_file in /var/cpanel/userdata/*/main; do
@@ -490,9 +501,15 @@ case "$choice" in
else
echo ""
echo -n "Enter cPanel username: "
echo -n "Enter cPanel username (or 0 to cancel): "
read -r check_user
if [ -z "$check_user" ] || [ "$check_user" = "0" ]; then
echo "Operation cancelled."
press_enter
exit 0
fi
if [ ! -d "/home/$check_user" ]; then
print_error "User $check_user does not exist"
press_enter
@@ -537,13 +554,13 @@ case "$choice" in
6)
# Re-enable wp-cron for specific domain
echo ""
echo -n "Enter domain name: "
echo -n "Enter domain name (or 0 to cancel): "
read -r domain
if [ -z "$domain" ]; then
print_error "Domain cannot be empty"
if [ -z "$domain" ] || [ "$domain" = "0" ]; then
echo "Operation cancelled."
press_enter
exit 1
exit 0
fi
# Find WordPress installation
@@ -597,13 +614,13 @@ case "$choice" in
7)
# Re-enable wp-cron for specific user
echo ""
echo -n "Enter cPanel username: "
echo -n "Enter cPanel username (or 0 to cancel): "
read -r target_user
if [ -z "$target_user" ]; then
print_error "Username cannot be empty"
if [ -z "$target_user" ] || [ "$target_user" = "0" ]; then
echo "Operation cancelled."
press_enter
exit 1
exit 0
fi
if [ ! -d "/home/$target_user" ]; then