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.

This commit is contained in:
2025-09-21 10:44:12 +01:00
parent 55dbf5e37c
commit dd7c385fc0

View File

@@ -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