Added some error messages to vm-mount.

in-use
Andrew Klapp 7 years ago
parent df75a7f6ed
commit fcf73d03a1
No known key found for this signature in database
GPG Key ID: D78ADB07F66B6AE4

@ -8,17 +8,23 @@ REMOTE_DIRECTORY="/home/lumia/src/"
if [ "$1" = "-u" ]; then
vm_name="$2"
mountpoint="${MOUNTPOINT_PARENT}/${vm_name}.vm"
# TODO: Print some messages here.
if [ -z "${vm_name}" ]; then
echo "Virtual machine name not provided."
exit 1
fi
if mount | grep -q "on ${mountpoint} "; then
echo "Unmounting ${mountpoint}."
fusermount -u "${mountpoint}"
fi
if virsh list | grep -q " ${vm_name} "; then
echo "Stopping ${vm_name}"
virsh destroy "${vm_name}"
fi
if [ -d "${mountpoint}" ]; then
echo "Deleting directory ${mountpoint}."
rmdir "${mountpoint}"
fi
@ -26,6 +32,11 @@ else
vm_name="$1"
mountpoint="${MOUNTPOINT_PARENT}/${vm_name}.vm"
if [ -z "${vm_name}" ]; then
echo "Virtual machine name not provided."
exit 1
fi
if [ "$(virsh list | grep " ${vm_name} ")" = "" ]; then
virsh start "${vm_name}"
fi
@ -45,10 +56,10 @@ else
# TODO: Make sure this directory isn't made if the vm fails to start or connect.
mkdir -p "${mountpoint}"
# TODO: This needs a better "error" message and a proper timeout.
# TODO: This needs a proper timeout.
echo "Attempting to mount over ssh."
until sshfs "${vm_ip_address}:${REMOTE_DIRECTORY}" "${mountpoint}"; do
echo "Could not connect via SSH, retrying."
sleep 3
echo "An error occurred, retrying."
done
fi

Loading…
Cancel
Save