|
|
|
@ -31,6 +31,7 @@ if [ "$1" = "-u" ]; then
|
|
|
|
else
|
|
|
|
else
|
|
|
|
vm_name="$1"
|
|
|
|
vm_name="$1"
|
|
|
|
mountpoint="${MOUNTPOINT_PARENT}/${vm_name}.vm"
|
|
|
|
mountpoint="${MOUNTPOINT_PARENT}/${vm_name}.vm"
|
|
|
|
|
|
|
|
awk_script="/${vm_name}/ && split(\$5, a, \"/\"){ print a[1] }"
|
|
|
|
|
|
|
|
|
|
|
|
if [ -z "${vm_name}" ]; then
|
|
|
|
if [ -z "${vm_name}" ]; then
|
|
|
|
echo "Virtual machine name not provided."
|
|
|
|
echo "Virtual machine name not provided."
|
|
|
|
@ -44,18 +45,17 @@ else
|
|
|
|
echo "Waiting for ${vm_name} to connect to the network..."
|
|
|
|
echo "Waiting for ${vm_name} to connect to the network..."
|
|
|
|
vm_ip_address=""
|
|
|
|
vm_ip_address=""
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Consider using a sleep here?
|
|
|
|
# TODO: Exit if this failes or times out.
|
|
|
|
|
|
|
|
# TODO: This needs a proper timeout.
|
|
|
|
while [ "${vm_ip_address}" = "" ]; do
|
|
|
|
while [ "${vm_ip_address}" = "" ]; do
|
|
|
|
virsh_line=""
|
|
|
|
vm_ip_address="$(virsh net-dhcp-leases "${NETWORK_NAME}" | awk "${awk_script}")"
|
|
|
|
virsh_line="$(virsh net-dhcp-leases "${NETWORK_NAME}" | grep "${vm_name}") > /dev/null"
|
|
|
|
|
|
|
|
if [ "${virsh_line}" != "" ]; then
|
|
|
|
|
|
|
|
vm_ip_address="$(echo "${virsh_line}" | sed "s/\\( \\)*/\\1/g" | cut -d " " -f6 | cut -d "/" -f1)"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Exit if this fails.
|
|
|
|
# TODO: Make sure this directory isn't made if the vm fails to start or connect.
|
|
|
|
# TODO: Make sure this directory isn't made if the vm fails to start or connect.
|
|
|
|
mkdir -p "${mountpoint}"
|
|
|
|
mkdir -p "${mountpoint}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Exit if this failes or times out.
|
|
|
|
# TODO: This needs a proper timeout.
|
|
|
|
# TODO: This needs a proper timeout.
|
|
|
|
echo "Attempting to mount over ssh."
|
|
|
|
echo "Attempting to mount over ssh."
|
|
|
|
until sshfs "${vm_ip_address}:${REMOTE_DIRECTORY}" "${mountpoint}"; do
|
|
|
|
until sshfs "${vm_ip_address}:${REMOTE_DIRECTORY}" "${mountpoint}"; do
|
|
|
|
|