Add default values for unset variables in build function for improved handling
This commit is contained in:
parent
ccc3c72bb9
commit
adb5031166
@ -307,15 +307,15 @@ CORE_COUNT="${DISK_SIZE}"
|
|||||||
RAM_SIZE="${RAM_SIZE}"
|
RAM_SIZE="${RAM_SIZE}"
|
||||||
HN="${HN}"
|
HN="${HN}"
|
||||||
BRG="${BRG}"
|
BRG="${BRG}"
|
||||||
APT_CACHER_IP="${APT_CACHER_IP}"
|
APT_CACHER_IP="${APT_CACHER_IP:-none}"
|
||||||
DISABLEIP6="${DISABLEIP6}"
|
DISABLEIP6="${DISABLEIP6}"
|
||||||
PW="${PW:-none}"
|
PW="${PW:-none}"
|
||||||
SSH="${SSH}"
|
SSH="${SSH}"
|
||||||
SSH_AUTHORIZED_KEY="${SSH_AUTHORIZED_KEY}"
|
SSH_AUTHORIZED_KEY="${SSH_AUTHORIZED_KEY}"
|
||||||
VERBOSE="${VERBOSE}"
|
VERBOSE="${VERBOSE}"
|
||||||
TAGS="${TAGS:-none}"
|
TAGS="${TAGS:-none}"
|
||||||
VLAN="${VLAN}"
|
VLAN="${VLAN:-none}"
|
||||||
MTU="${MTU}"
|
MTU="${MTU:-1500}"
|
||||||
GATE="${GATE:-none}"
|
GATE="${GATE:-none}"
|
||||||
SD="${SD:-none}"
|
SD="${SD:-none}"
|
||||||
MAC="${MAC:-none}"
|
MAC="${MAC:-none}"
|
||||||
@ -338,15 +338,15 @@ CORE_COUNT="${DISK_SIZE}"
|
|||||||
RAM_SIZE="${RAM_SIZE}"
|
RAM_SIZE="${RAM_SIZE}"
|
||||||
HN="${HN}"
|
HN="${HN}"
|
||||||
BRG="${BRG}"
|
BRG="${BRG}"
|
||||||
APT_CACHER_IP="${APT_CACHER_IP}"
|
APT_CACHER_IP="${APT_CACHER_IP:-none}"
|
||||||
DISABLEIP6="${DISABLEIP6}"
|
DISABLEIP6="${DISABLEIP6}"
|
||||||
PW="${PW:-none}"
|
PW="${PW:-none}"
|
||||||
SSH="${SSH}"
|
SSH="${SSH}"
|
||||||
SSH_AUTHORIZED_KEY="${SSH_AUTHORIZED_KEY}"
|
SSH_AUTHORIZED_KEY="${SSH_AUTHORIZED_KEY}"
|
||||||
VERBOSE="${VERBOSE}"
|
VERBOSE="${VERBOSE}"
|
||||||
TAGS="${TAGS:-none}"
|
TAGS="${TAGS:-none}"
|
||||||
VLAN="${VLAN}"
|
VLAN="${VLAN:-none}"
|
||||||
MTU="${MTU}"
|
MTU="${MTU:-1500}"
|
||||||
GATE="${GATE:-none}"
|
GATE="${GATE:-none}"
|
||||||
SD="${SD:-none}"
|
SD="${SD:-none}"
|
||||||
MAC="${MAC:-none}"
|
MAC="${MAC:-none}"
|
||||||
@ -1166,8 +1166,13 @@ config_file() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${SD-}" ]]; then
|
if [[ -n "${SD-}" ]]; then
|
||||||
|
if [[ "$SD" == "none" ]]; then
|
||||||
|
SD=""
|
||||||
|
echo -e "${SEARCH}${BOLD}${DGN}DNS Search Domain: ${BGN}Host${CL}"
|
||||||
|
else
|
||||||
echo -e "${SEARCH}${BOLD}${DGN}DNS Search Domain: ${BGN}$SD${CL}"
|
echo -e "${SEARCH}${BOLD}${DGN}DNS Search Domain: ${BGN}$SD${CL}"
|
||||||
SD="-searchdomain=$SD"
|
SD="-searchdomain=$SD"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
if SD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then
|
if SD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a DNS Search Domain (leave blank for HOST)" 8 58 --title "DNS Search Domain" 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$SD" ]; then
|
if [ -z "$SD" ]; then
|
||||||
@ -1184,6 +1189,10 @@ config_file() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${NS-}" ]]; then
|
if [[ -n "${NS-}" ]]; then
|
||||||
|
if [[ $NS == "none" ]]; then
|
||||||
|
NS=""
|
||||||
|
echo -e "${NETWORK}${BOLD}${DGN}DNS Server IP Address: ${BGN}Host${CL}"
|
||||||
|
else
|
||||||
if [[ "$NS" =~ $ip_regex ]]; then
|
if [[ "$NS" =~ $ip_regex ]]; then
|
||||||
echo -e "${NETWORK}${BOLD}${DGN}DNS Server IP Address: ${BGN}$NS${CL}"
|
echo -e "${NETWORK}${BOLD}${DGN}DNS Server IP Address: ${BGN}$NS${CL}"
|
||||||
NS="-nameserver=$NS"
|
NS="-nameserver=$NS"
|
||||||
@ -1191,6 +1200,7 @@ config_file() {
|
|||||||
msg_error "Invalid IP Address format for DNS Server. Needs to be 0.0.0.0, was ${NS}"
|
msg_error "Invalid IP Address format for DNS Server. Needs to be 0.0.0.0, was ${NS}"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
if NX=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then
|
if NX=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a DNS Server IP (leave blank for HOST)" 8 58 --title "DNS SERVER IP" 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$NX" ]; then
|
if [ -z "$NX" ]; then
|
||||||
@ -1206,6 +1216,10 @@ config_file() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${MAC-}" ]]; then
|
if [[ -n "${MAC-}" ]]; then
|
||||||
|
if [[ "$MAC" == "none" ]]; then
|
||||||
|
MAC=""
|
||||||
|
echo -e "${MACADDRESS}${BOLD}${DGN}MAC Address: ${BGN}Host${CL}"
|
||||||
|
else
|
||||||
if [[ "$MAC" =~ ^([A-Fa-f0-9]{2}:){5}[A-Fa-f0-9]{2}$ ]]; then
|
if [[ "$MAC" =~ ^([A-Fa-f0-9]{2}:){5}[A-Fa-f0-9]{2}$ ]]; then
|
||||||
echo -e "${MACADDRESS}${BOLD}${DGN}MAC Address: ${BGN}$MAC${CL}"
|
echo -e "${MACADDRESS}${BOLD}${DGN}MAC Address: ${BGN}$MAC${CL}"
|
||||||
MAC=",hwaddr=$MAC"
|
MAC=",hwaddr=$MAC"
|
||||||
@ -1213,6 +1227,7 @@ config_file() {
|
|||||||
msg_error "MAC Address must be in the format xx:xx:xx:xx:xx:xx, was ${MAC}"
|
msg_error "MAC Address must be in the format xx:xx:xx:xx:xx:xx, was ${MAC}"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address(leave blank for generated MAC)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then
|
if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address(leave blank for generated MAC)" 8 58 --title "MAC ADDRESS" 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$MAC1" ]; then
|
if [ -z "$MAC1" ]; then
|
||||||
@ -1228,6 +1243,10 @@ config_file() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${VLAN-}" ]]; then
|
if [[ -n "${VLAN-}" ]]; then
|
||||||
|
if [[ "$VLAN" == "none" ]]; then
|
||||||
|
VLAN=""
|
||||||
|
echo -e "${VLANTAG}${BOLD}${DGN}Vlan: ${BGN}Host${CL}"
|
||||||
|
else
|
||||||
if [[ "$VLAN" =~ ^-?[0-9]+$ ]]; then
|
if [[ "$VLAN" =~ ^-?[0-9]+$ ]]; then
|
||||||
echo -e "${VLANTAG}${BOLD}${DGN}Vlan: ${BGN}$VLAN${CL}"
|
echo -e "${VLANTAG}${BOLD}${DGN}Vlan: ${BGN}$VLAN${CL}"
|
||||||
VLAN=",tag=$VLAN"
|
VLAN=",tag=$VLAN"
|
||||||
@ -1235,6 +1254,7 @@ config_file() {
|
|||||||
msg_error "VLAN must be an integer, was ${VLAN}"
|
msg_error "VLAN must be an integer, was ${VLAN}"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for no VLAN)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then
|
if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for no VLAN)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VLAN1" ]; then
|
if [ -z "$VLAN1" ]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user