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