capsul-flask/capsulflask/shell_scripts/get.sh

17 lines
357 B
Bash
Raw Normal View History

#!/bin/sh
vmname="$1"
2020-05-13 18:56:43 +00:00
if echo "$vmname" | grep -vqE '^(cvm|capsul)-[a-z0-9]{10}$'; then
echo "vmname $vmname must match "'"^capsul-[a-z0-9]{10}$"'
exit 1
fi
if ! virsh list --name --all | grep -qE "^$vmname$" ; then
echo "Error: $vmname not found"
exit 1
fi
# this gets the ipv4
virsh domifaddr "$vmname" | awk '/vnet/ {print $4}' | cut -d'/' -f1