Skip to content

Make max ID number configurable #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -117,4 +118,4 @@ CS_ONBOOT="0"
## Start immediatly after creation (value: 0|1)
CS_SBOOT="0"

#######################################################################################################################################
#######################################################################################################################################
4 changes: 2 additions & 2 deletions src/chk_mod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/id_mod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down