scripts-misc/proxmox/stop-all-guests.sh

31 lines
456 B
Bash
Raw Normal View History

2023-03-31 10:42:21 +02:00
#!/bin/bash
VM_LIST=`mktemp`
CT_LIST=`mktemp`
# We catch the VM & CT from each server
qm list | awk 'NR>1{ print $1 }' > $VM_LIST
pct list | awk 'NR>1{ print $1 }' > $CT_LIST
mapfile -t listvm < $VM_LIST
for i in ${listvm[@]};
do
echo "shutdown VM $i"
qm shutdown $i &
sleep 2s
done
mapfile -t listct < $CT_LIST
for i in ${listct[@]};
do
echo "shutdown CT $i"
pct shutdown $i &
sleep 2s
done
rm $VM_LIST
rm $CT_LIST