22 lines
474 B
Bash
Executable File
22 lines
474 B
Bash
Executable File
#!/bin/bash
|
|
if [[ -z $1 ]]; then
|
|
echo 'all or vm-name'
|
|
fi
|
|
|
|
if [[ $1 = 'all' ]]; then
|
|
machine=$(virsh -c qemu:///system list --name)
|
|
else
|
|
machine=("$@")
|
|
fi
|
|
|
|
for i in ${machine[@]}; do
|
|
snapshot=$(virsh -c qemu:///system snapshot-list $i | sed -n 3p | awk '{print $1}')
|
|
virsh -c qemu:///system destroy $i
|
|
virsh -c qemu:///system snapshot-revert $i $snapshot
|
|
if [[ $2 = 'stop' ]]; then
|
|
true
|
|
else
|
|
virsh -c qemu:///system start $i
|
|
fi
|
|
done
|