Update unifi-os-server-vm.sh
This commit is contained in:
parent
53fb32e50d
commit
db2a6e1e20
@ -87,11 +87,18 @@ function get_valid_nextid() {
|
|||||||
local try_id
|
local try_id
|
||||||
try_id=$(pvesh get /cluster/nextid)
|
try_id=$(pvesh get /cluster/nextid)
|
||||||
while true; do
|
while true; do
|
||||||
|
# Check if VM config exists
|
||||||
if [ -f "/etc/pve/qemu-server/${try_id}.conf" ] || [ -f "/etc/pve/lxc/${try_id}.conf" ]; then
|
if [ -f "/etc/pve/qemu-server/${try_id}.conf" ] || [ -f "/etc/pve/lxc/${try_id}.conf" ]; then
|
||||||
try_id=$((try_id + 1))
|
try_id=$((try_id + 1))
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
if lvs --noheadings -o lv_name | grep -qE "(^|[-_])${try_id}($|[-_])"; then
|
# Check if VM or CT actually exists (running or stopped)
|
||||||
|
if qm status "$try_id" &>/dev/null || pct status "$try_id" &>/dev/null; then
|
||||||
|
try_id=$((try_id + 1))
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
# Check if LVM volumes with this ID exist
|
||||||
|
if lvs --noheadings -o lv_name 2>/dev/null | grep -qE "(^|[-_])${try_id}($|[-_])"; then
|
||||||
try_id=$((try_id + 1))
|
try_id=$((try_id + 1))
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user