forked from 3wordchant/capsul-flask
fixing get inconsistency and adding vm_state_command
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
|
||||
#!/bin/sh
|
||||
|
||||
vmname="$1"
|
||||
@ -7,10 +8,13 @@ if echo "$vmname" | grep -vqE '^(cvm|capsul)-[a-z0-9]{10}$'; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! virsh list --name --all | grep -qE "^$vmname$" ; then
|
||||
echo "Error: $vmname not found"
|
||||
exit 1
|
||||
# this will let us know if the vm exists or not
|
||||
exists="false"
|
||||
if virsh domuuid "$vmname" | grep -vqE '^[\t\s\n]*$'; then
|
||||
exists="true"
|
||||
fi
|
||||
|
||||
# this gets the ipv4
|
||||
virsh domifaddr "$vmname" | awk '/vnet/ {print $4}' | cut -d'/' -f1
|
||||
ipv4="$(virsh domifaddr "$vmname" | awk '/vnet/ {print $4}' | cut -d'/' -f1)"
|
||||
|
||||
echo "$exists $ipv4"
|
Reference in New Issue
Block a user