diff --git a/vm/archlinux-vm.sh b/vm/archlinux-vm.sh index 482f09c85..cbd966c8b 100644 --- a/vm/archlinux-vm.sh +++ b/vm/archlinux-vm.sh @@ -310,7 +310,10 @@ function advanced_settings() { HN="arch-linux" echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" else - HN=$(echo "${VM_NAME,,}" | tr -d ' ') + HN=$(echo "${VM_NAME,,}" | tr -cs 'a-z0-9-' '-' | sed 's/^-//;s/-$//') + if [ "$HN" != "${VM_NAME,,}" ]; then + whiptail --backtitle "Proxmox VE Helper Scripts" --title "HOSTNAME ADJUSTED" --msgbox "Invalid characters detected. Hostname has been adjusted to:\n\n $HN" 10 58 + fi echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" fi else diff --git a/vm/debian-13-vm.sh b/vm/debian-13-vm.sh index 4b52b7d47..e0493a81e 100644 --- a/vm/debian-13-vm.sh +++ b/vm/debian-13-vm.sh @@ -325,7 +325,10 @@ function advanced_settings() { HN="debian" echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" else - HN=$(echo "${VM_NAME,,}" | tr -d ' ') + HN=$(echo "${VM_NAME,,}" | tr -cs 'a-z0-9-' '-' | sed 's/^-//;s/-$//') + if [ "$HN" != "${VM_NAME,,}" ]; then + whiptail --backtitle "Proxmox VE Helper Scripts" --title "HOSTNAME ADJUSTED" --msgbox "Invalid characters detected. Hostname has been adjusted to:\n\n $HN" 10 58 + fi echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" fi else diff --git a/vm/debian-vm.sh b/vm/debian-vm.sh index cff40a43a..6081ebc83 100644 --- a/vm/debian-vm.sh +++ b/vm/debian-vm.sh @@ -315,7 +315,10 @@ function advanced_settings() { HN="debian" echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" else - HN=$(echo ${VM_NAME,,} | tr -d ' ') + HN=$(echo "${VM_NAME,,}" | tr -cs 'a-z0-9-' '-' | sed 's/^-//;s/-$//') + if [ "$HN" != "${VM_NAME,,}" ]; then + whiptail --backtitle "Proxmox VE Helper Scripts" --title "HOSTNAME ADJUSTED" --msgbox "Invalid characters detected. Hostname has been adjusted to:\n\n $HN" 10 58 + fi echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" fi else diff --git a/vm/docker-vm.sh b/vm/docker-vm.sh index 42fb22091..45adb5608 100644 --- a/vm/docker-vm.sh +++ b/vm/docker-vm.sh @@ -251,7 +251,10 @@ function advanced_settings() { if [ -z $VM_NAME ]; then HN="docker" else - HN=$(echo ${VM_NAME,,} | tr -d ' ') + HN=$(echo "${VM_NAME,,}" | tr -cs 'a-z0-9-' '-' | sed 's/^-//;s/-$//') + if [ "$HN" != "${VM_NAME,,}" ]; then + whiptail --backtitle "Proxmox VE Helper Scripts" --title "HOSTNAME ADJUSTED" --msgbox "Invalid characters detected. Hostname has been adjusted to:\n\n $HN" 10 58 + fi fi echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" else diff --git a/vm/haos-vm.sh b/vm/haos-vm.sh index 832640e0a..bed97a588 100644 --- a/vm/haos-vm.sh +++ b/vm/haos-vm.sh @@ -391,7 +391,10 @@ function advanced_settings() { HN="haos${BRANCH}" echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" else - HN=$(echo ${VM_NAME,,} | tr -d ' ') + HN=$(echo "${VM_NAME,,}" | tr -cs 'a-z0-9-' '-' | sed 's/^-//;s/-$//') + if [ "$HN" != "${VM_NAME,,}" ]; then + whiptail --backtitle "Proxmox VE Helper Scripts" --title "HOSTNAME ADJUSTED" --msgbox "Invalid characters detected. Hostname has been adjusted to:\n\n $HN" 10 58 + fi echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" fi else diff --git a/vm/mikrotik-routeros.sh b/vm/mikrotik-routeros.sh index 4e46f5900..0b383e8c1 100644 --- a/vm/mikrotik-routeros.sh +++ b/vm/mikrotik-routeros.sh @@ -377,7 +377,10 @@ function advanced_settings() { HN="mikrotik-routeros-chr" echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" else - HN=$(echo ${VM_NAME,,} | tr -d ' ') + HN=$(echo "${VM_NAME,,}" | tr -cs 'a-z0-9-' '-' | sed 's/^-//;s/-$//') + if [ "$HN" != "${VM_NAME,,}" ]; then + whiptail --backtitle "Proxmox VE Helper Scripts" --title "HOSTNAME ADJUSTED" --msgbox "Invalid characters detected. Hostname has been adjusted to:\n\n $HN" 10 58 + fi echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" fi else diff --git a/vm/nextcloud-vm.sh b/vm/nextcloud-vm.sh index 3307cc6b7..460e4f07f 100644 --- a/vm/nextcloud-vm.sh +++ b/vm/nextcloud-vm.sh @@ -313,7 +313,10 @@ function advanced_settings() { HN="nextcloud-vm" echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" else - HN=$(echo ${VM_NAME,,} | tr -d ' ') + HN=$(echo "${VM_NAME,,}" | tr -cs 'a-z0-9-' '-' | sed 's/^-//;s/-$//') + if [ "$HN" != "${VM_NAME,,}" ]; then + whiptail --backtitle "Proxmox VE Helper Scripts" --title "HOSTNAME ADJUSTED" --msgbox "Invalid characters detected. Hostname has been adjusted to:\n\n $HN" 10 58 + fi echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" fi else diff --git a/vm/openwrt-vm.sh b/vm/openwrt-vm.sh index c7e030245..4260a3be6 100644 --- a/vm/openwrt-vm.sh +++ b/vm/openwrt-vm.sh @@ -328,7 +328,10 @@ function advanced_settings() { if [ -z $VM_NAME ]; then HN="openwrt" else - HN=$(echo ${VM_NAME,,} | tr -d ' ') + HN=$(echo "${VM_NAME,,}" | tr -cs 'a-z0-9-' '-' | sed 's/^-//;s/-$//') + if [ "$HN" != "${VM_NAME,,}" ]; then + whiptail --backtitle "Proxmox VE Helper Scripts" --title "HOSTNAME ADJUSTED" --msgbox "Invalid characters detected. Hostname has been adjusted to:\n\n $HN" 10 58 + fi fi echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" else diff --git a/vm/opnsense-vm.sh b/vm/opnsense-vm.sh index 71ec65f41..243f02108 100644 --- a/vm/opnsense-vm.sh +++ b/vm/opnsense-vm.sh @@ -421,7 +421,10 @@ function advanced_settings() { if [ -z "$VM_NAME" ]; then HN="OPNsense" else - HN=$(echo ${VM_NAME,,} | tr -d ' ') + HN=$(echo "${VM_NAME,,}" | tr -cs 'a-z0-9-' '-' | sed 's/^-//;s/-$//') + if [ "$HN" != "${VM_NAME,,}" ]; then + whiptail --backtitle "Proxmox VE Helper Scripts" --title "HOSTNAME ADJUSTED" --msgbox "Invalid characters detected. Hostname has been adjusted to:\n\n $HN" 10 58 + fi fi echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" else diff --git a/vm/owncloud-vm.sh b/vm/owncloud-vm.sh index d0ebe2115..7738ecbb8 100644 --- a/vm/owncloud-vm.sh +++ b/vm/owncloud-vm.sh @@ -314,7 +314,10 @@ function advanced_settings() { HN="owncloud-vm" echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" else - HN=$(echo ${VM_NAME,,} | tr -d ' ') + HN=$(echo "${VM_NAME,,}" | tr -cs 'a-z0-9-' '-' | sed 's/^-//;s/-$//') + if [ "$HN" != "${VM_NAME,,}" ]; then + whiptail --backtitle "Proxmox VE Helper Scripts" --title "HOSTNAME ADJUSTED" --msgbox "Invalid characters detected. Hostname has been adjusted to:\n\n $HN" 10 58 + fi echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" fi else diff --git a/vm/pimox-haos-vm.sh b/vm/pimox-haos-vm.sh index a3bbba24d..708be777f 100644 --- a/vm/pimox-haos-vm.sh +++ b/vm/pimox-haos-vm.sh @@ -274,7 +274,10 @@ function advanced_settings() { echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" else if [ $exitstatus = 0 ]; then - HN=$(echo ${VM_NAME,,} | tr -d ' ') + HN=$(echo "${VM_NAME,,}" | tr -cs 'a-z0-9-' '-' | sed 's/^-//;s/-$//') + if [ "$HN" != "${VM_NAME,,}" ]; then + whiptail --backtitle "Proxmox VE Helper Scripts" --title "HOSTNAME ADJUSTED" --msgbox "Invalid characters detected. Hostname has been adjusted to:\n\n $HN" 10 58 + fi echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" fi fi diff --git a/vm/truenas-vm.sh b/vm/truenas-vm.sh index 3e7274543..1386d0783 100644 --- a/vm/truenas-vm.sh +++ b/vm/truenas-vm.sh @@ -355,7 +355,10 @@ function advanced_settings() { if [ -z $VM_NAME ]; then echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" else - HN=$(echo ${VM_NAME,,} | tr -d ' ') + HN=$(echo "${VM_NAME,,}" | tr -cs 'a-z0-9-' '-' | sed 's/^-//;s/-$//') + if [ "$HN" != "${VM_NAME,,}" ]; then + whiptail --backtitle "Proxmox VE Helper Scripts" --title "HOSTNAME ADJUSTED" --msgbox "Invalid characters detected. Hostname has been adjusted to:\n\n $HN" 10 58 + fi echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" fi else diff --git a/vm/ubuntu2204-vm.sh b/vm/ubuntu2204-vm.sh index 0c281ec7f..9f4b0ac13 100644 --- a/vm/ubuntu2204-vm.sh +++ b/vm/ubuntu2204-vm.sh @@ -310,7 +310,10 @@ function advanced_settings() { HN="ubuntu" echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" else - HN=$(echo ${VM_NAME,,} | tr -d ' ') + HN=$(echo "${VM_NAME,,}" | tr -cs 'a-z0-9-' '-' | sed 's/^-//;s/-$//') + if [ "$HN" != "${VM_NAME,,}" ]; then + whiptail --backtitle "Proxmox VE Helper Scripts" --title "HOSTNAME ADJUSTED" --msgbox "Invalid characters detected. Hostname has been adjusted to:\n\n $HN" 10 58 + fi echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" fi else diff --git a/vm/ubuntu2404-vm.sh b/vm/ubuntu2404-vm.sh index eba9846a5..283986b24 100644 --- a/vm/ubuntu2404-vm.sh +++ b/vm/ubuntu2404-vm.sh @@ -313,7 +313,10 @@ function advanced_settings() { HN="ubuntu" echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" else - HN=$(echo ${VM_NAME,,} | tr -d ' ') + HN=$(echo "${VM_NAME,,}" | tr -cs 'a-z0-9-' '-' | sed 's/^-//;s/-$//') + if [ "$HN" != "${VM_NAME,,}" ]; then + whiptail --backtitle "Proxmox VE Helper Scripts" --title "HOSTNAME ADJUSTED" --msgbox "Invalid characters detected. Hostname has been adjusted to:\n\n $HN" 10 58 + fi echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" fi else diff --git a/vm/ubuntu2504-vm.sh b/vm/ubuntu2504-vm.sh index f9040855d..2ec9e65d8 100644 --- a/vm/ubuntu2504-vm.sh +++ b/vm/ubuntu2504-vm.sh @@ -312,7 +312,10 @@ function advanced_settings() { HN="ubuntu" echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" else - HN=$(echo ${VM_NAME,,} | tr -d ' ') + HN=$(echo "${VM_NAME,,}" | tr -cs 'a-z0-9-' '-' | sed 's/^-//;s/-$//') + if [ "$HN" != "${VM_NAME,,}" ]; then + whiptail --backtitle "Proxmox VE Helper Scripts" --title "HOSTNAME ADJUSTED" --msgbox "Invalid characters detected. Hostname has been adjusted to:\n\n $HN" 10 58 + fi echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" fi else diff --git a/vm/umbrel-os-vm.sh b/vm/umbrel-os-vm.sh index fc193d0bb..1fc47c825 100644 --- a/vm/umbrel-os-vm.sh +++ b/vm/umbrel-os-vm.sh @@ -373,7 +373,10 @@ function advanced_settings() { HN="umbrelos" echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" else - HN=$(echo ${VM_NAME,,} | tr -d ' ') + HN=$(echo "${VM_NAME,,}" | tr -cs 'a-z0-9-' '-' | sed 's/^-//;s/-$//') + if [ "$HN" != "${VM_NAME,,}" ]; then + whiptail --backtitle "Proxmox VE Helper Scripts" --title "HOSTNAME ADJUSTED" --msgbox "Invalid characters detected. Hostname has been adjusted to:\n\n $HN" 10 58 + fi echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}" fi else