check hostname

This commit is contained in:
CanbiZ 2025-06-19 16:33:31 +02:00
parent 59a4083eac
commit ad4499cfbd

View File

@ -468,6 +468,14 @@ advanced_settings() {
else else
HN=$(echo "${CT_NAME,,}" | tr -d ' ') HN=$(echo "${CT_NAME,,}" | tr -d ' ')
fi fi
# Hostname validate (RFC 1123)
if ! [[ "$HN" =~ ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ ]]; then
whiptail --backtitle "[dev] Proxmox VE Helper Scripts" \
--msgbox "❌ Invalid hostname: '$HN'\n\nOnly lowercase letters, digits and hyphens (-) are allowed.\nUnderscores (_) or other characters are not permitted!" 10 70
advanced_settings
fi
echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}"
else else
exit_script exit_script