mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-02-07 16:29:18 +00:00
Add input sanity checking
This commit is contained in:
parent
d1ff5356ad
commit
dffa262b88
@ -765,23 +765,38 @@ config_file(){
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -z "$DISK_SIZE" ]]; then
|
if [[ ! -z "$DISK_SIZE" ]]; then
|
||||||
echo -e "${DISKSIZE}${BOLD}${DGN}Disk Size: ${BGN}${DISK_SIZE} GB${CL}"
|
if [[ "$DISK_SIZE" =~ ^-?[0-9]+$ ]]; then
|
||||||
|
echo -e "${DISKSIZE}${BOLD}${DGN}Disk Size: ${BGN}${DISK_SIZE} GB${CL}"
|
||||||
|
else
|
||||||
|
msg_error "DISK_SIZE must be an integer"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
msg_error "Disk Size cannot be empty"
|
msg_error "DISK_SIZE cannot be empty"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -z "$CORE_COUNT" ]]; then
|
if [[ ! -z "$CORE_COUNT" ]]; then
|
||||||
echo -e "${CPUCORE}${BOLD}${DGN}CPU Cores: ${BGN}${CORE_COUNT}${CL}"
|
if [[ "$CORE_COUNT" =~ ^-?[0-9]+$ ]]; then
|
||||||
|
echo -e "${CPUCORE}${BOLD}${DGN}CPU Cores: ${BGN}${CORE_COUNT}${CL}"
|
||||||
|
else
|
||||||
|
msg_error "CORE_COUNT must be an integer"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
msg_error "CPU Cores cannot be empty"
|
msg_error "CORE_COUNT cannot be empty"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -z "$RAM_SIZE" ]]; then
|
if [[ ! -z "$RAM_SIZE" ]]; then
|
||||||
echo -e "${RAMSIZE}${BOLD}${DGN}RAM Size: ${BGN}${RAM_SIZE} MiB${CL}"
|
if [[ "$RAM_SIZE" =~ ^-?[0-9]+$ ]]; then
|
||||||
|
echo -e "${RAMSIZE}${BOLD}${DGN}RAM Size: ${BGN}${RAM_SIZE} MiB${CL}"
|
||||||
|
else
|
||||||
|
msg_error "RAM_SIZE must be an integer"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
msg_error "RAM Size cannot be empty"
|
msg_error "RAM_SIZE cannot be empty"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -864,8 +879,13 @@ config_file(){
|
|||||||
|
|
||||||
|
|
||||||
if [[ ! -z "$NS" ]]; then
|
if [[ ! -z "$NS" ]]; then
|
||||||
echo -e "${NETWORK}${BOLD}${DGN}DNS Server IP Address: ${BGN}$NS${CL}"
|
if [[ "$NS" =~ $ip_regex ]]; then
|
||||||
NS="-nameserver=$NS"
|
echo -e "${NETWORK}${BOLD}${DGN}DNS Server IP Address: ${BGN}$NS${CL}"
|
||||||
|
NS="-nameserver=$NS"
|
||||||
|
else
|
||||||
|
msg_error "Invalid IP Address format for Name Server: ${NS}"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
NS=""
|
NS=""
|
||||||
echo -e "${NETWORK}${BOLD}${DGN}DNS Server IP Address: ${BGN}HOST${CL}"
|
echo -e "${NETWORK}${BOLD}${DGN}DNS Server IP Address: ${BGN}HOST${CL}"
|
||||||
@ -877,8 +897,13 @@ config_file(){
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -z "$VLAN" ]]; then
|
if [[ ! -z "$VLAN" ]]; then
|
||||||
echo -e "${VLANTAG}${BOLD}${DGN}Vlan: ${BGN}$VLAN${CL}"
|
if [[ "$VLAN" =~ ^-?[0-9]+$ ]]; then
|
||||||
VLAN=",tag=$VLAN"
|
echo -e "${VLANTAG}${BOLD}${DGN}Vlan: ${BGN}$VLAN${CL}"
|
||||||
|
VLAN=",tag=$VLAN"
|
||||||
|
else
|
||||||
|
msg_error "VLAN must be an integer"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -z "$TAGS" ]]; then
|
if [[ ! -z "$TAGS" ]]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user