diff --git a/config.cfg b/config.cfg index 9508204..a656e0f 100755 --- a/config.cfg +++ b/config.cfg @@ -12,6 +12,7 @@ HS_CIIMG=$HS_PATH_DATASTR/template/iso # Folder dedicated t HS_LXCIMG=$HS_PATH_DATASTR/template/cache # Folder dedicated to LXC images HS_PATH_CONF=$HS_PATH_DATASTR/snippets # Folder dedicated to cloud-init config files (.yaml) HS_LXCREPO="http://download.proxmox.com/images/system" # Default repository of proxmox lxc images +HS_MAX_ID=9999 # Default max id number ####################################################################################################################################### # BASE PGK SETTINGS @@ -117,4 +118,4 @@ CS_ONBOOT="0" ## Start immediatly after creation (value: 0|1) CS_SBOOT="0" -####################################################################################################################################### \ No newline at end of file +####################################################################################################################################### diff --git a/src/chk_mod.sh b/src/chk_mod.sh index 2084f29..d5e436c 100755 --- a/src/chk_mod.sh +++ b/src/chk_mod.sh @@ -99,8 +99,8 @@ chk_args(){ IFS=',' read -ra nums <<< "$3" for num in "${nums[@]}"; do - if ! [[ "$num" =~ ^[0-9]+$ ]] || ! (( num >= 100 && num <= 9999 )); then - msg_error "Argument: '$num' must be an integer between 100 and 9999, list must be separted by comas." + if ! [[ "$num" =~ ^[0-9]+$ ]] || ! (( num >= 100 && num <= $HS_MAX_ID )); then + msg_error "Argument: '$num' must be an integer between 100 and $HS_MAX_ID, list must be separted by comas." exit 1 fi done diff --git a/src/id_mod.sh b/src/id_mod.sh index 9dadc39..dff7ef5 100755 --- a/src/id_mod.sh +++ b/src/id_mod.sh @@ -28,13 +28,13 @@ next_available_vmid() { qm_ids=$(qm list | awk '{print $1}') pct_ids=$(pct list | awk '{print $1}') - for (( i=100; i<=9999; i++ )); do + for (( i=100; i<=$HS_MAX_ID; i++ )); do if ! echo "$qm_ids" | grep -q -w "$i" && ! echo "$pct_ids" | grep -q -w "$i"; then GS_VMID="$i" return fi done - msg_error "No available virtual machine ID found in the range 100 to 9999" + msg_error "No available virtual machine ID found in the range 100 to $HS_MAX_ID" } check_vmid_list() {