From dd7c385fc0dd494de4c4def3a8f2f605398d5c82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Barbosa?= Date: Sun, 21 Sep 2025 10:44:12 +0100 Subject: [PATCH] Refactor hostname configuration in customization script to improve user experience. Simplify prompts for changing hostname and ensure current hostname is displayed clearly. Maintain existing hostname if no new input is provided. --- costumize.sh | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/costumize.sh b/costumize.sh index b33294a..ff269f9 100755 --- a/costumize.sh +++ b/costumize.sh @@ -37,20 +37,16 @@ check_user() { set_hostname() { echo "" echo -e "${BLUE}=== Server Hostname Configuration ===${NC}" - echo "Current hostname: $(hostname)" + local current_hostname=$(hostname) + echo "Current hostname: $current_hostname" echo "" - read -p "Do you want to change the hostname? (y/N): " change_hostname - - if [[ ! "$change_hostname" =~ ^[Yy]$ ]]; then - log "Keeping current hostname: $(hostname)" - return 0 - fi - - read -p "Enter new hostname for this server: " new_hostname + read -p "Enter hostname for this server (press Enter to keep '$current_hostname'): " new_hostname + # If empty, keep current hostname if [[ -z "$new_hostname" ]]; then - error "Hostname cannot be empty" + log "Keeping current hostname: $current_hostname" + return 0 fi # Validate hostname format