#!/usr/bin/bash
# link VM in Use-Dir in /tmp

set -eu

# change to image-directory
cd /lmn/vm

VM_DIR="/tmp/${SUDO_UID}/vm"

# link system-VM-Images to User VM Directory
for i in *.qcow2; do
  [[ -f "${VM_DIR}/${i}" ]] || ln "${i}" "${VM_DIR}/${i}"
done

# link system-VM-Machine-Definitions to User VM Directory
for i in *.xml; do
  [[ -f "${VM_DIR}/${i}" ]] || ln "${i}" "${VM_DIR}/${i}"
done
