fixed bugs
This commit is contained in:
parent
4e5eebe367
commit
983e915090
4 changed files with 20 additions and 9 deletions
|
@ -14,15 +14,14 @@ fi
|
|||
cd /var/lib/libvirt/images
|
||||
|
||||
VM_NAME=$1
|
||||
VM_DIR="/tmp/${UID}/vmimages"
|
||||
VM_XML="${VM_DIR}/xml/${VM_NAME}-clone.xml"
|
||||
|
||||
if [[ ! -f "xml/${VM_NAME}.xml" ]] || [[ ! -f "${VM_NAME}.qcow2" ]]; then
|
||||
if ! [[ -f "xml/${VM_NAME}.xml" && -f "${VM_NAME}.qcow2" ]] && ! [[ -f "${VM_DIR}/xml/${VM_NAME}.xml" && -f "${VM_DIR}/${VM_NAME}.qcow2" ]]; then
|
||||
echo "xml or qcow2 File does not exists." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VM_DIR="/tmp/${UID}/vmimages"
|
||||
VM_XML="${VM_DIR}/xml/${VM_NAME}-clone.xml"
|
||||
|
||||
# Create User-VM-Dir and link system VM-Images
|
||||
[[ -d "${VM_DIR}/xml" ]] || mkdir -p "${VM_DIR}/xml"
|
||||
sudo /usr/local/bin/link-images.sh
|
||||
|
@ -32,7 +31,7 @@ cd "${VM_DIR}"
|
|||
qemu-img create -f qcow2 -F qcow2 -b "${VM_NAME}.qcow2" "${VM_NAME}-clone.qcow2"
|
||||
|
||||
# Create machine-definition-file
|
||||
cp "/var/lib/libvirt/images/xml/${VM_NAME}.xml" "${VM_XML}"
|
||||
cp "${VM_DIR}/xml/${VM_NAME}.xml" "${VM_XML}"
|
||||
|
||||
# set VM_DIR:
|
||||
sed -i "s:VMIMAGEDIR:${VM_DIR}:" "${VM_XML}"
|
||||
|
|
|
@ -11,9 +11,13 @@ fi
|
|||
|
||||
VM_NAME=$1
|
||||
VM_CLONE=$2
|
||||
VM_DIR="/tmp/${UID}/vmimages"
|
||||
|
||||
# Create User-VM-Dir and link system VM-Images
|
||||
[[ -d "${VM_DIR}/xml" ]] || mkdir -p "${VM_DIR}/xml"
|
||||
sudo /usr/local/bin/link-images.sh
|
||||
|
||||
# change to image-directory
|
||||
VM_DIR="/tmp/${UID}/vmimages"
|
||||
cd "${VM_DIR}"
|
||||
|
||||
if { [[ ! -f "xml/${VM_NAME}.xml" ]] && [[ ! -f "/var/lib/libvirt/images/xml/${VM_NAME}.xml" ]]; } || [[ ! -f "${VM_NAME}.qcow2" ]]; then
|
||||
|
|
|
@ -11,4 +11,12 @@ VM_DIR="/tmp/${SUDO_UID}/vmimages"
|
|||
# link system-VM-Images to User VM Directory
|
||||
for i in *.qcow2; do
|
||||
[[ -f "${VM_DIR}/${i}" ]] || ln "${i}" "${VM_DIR}/${i}"
|
||||
done
|
||||
done
|
||||
|
||||
# change to image-directory
|
||||
cd /var/lib/libvirt/images/xml
|
||||
|
||||
# link system-VM-Machine-Definitions to User VM Directory
|
||||
for i in *.xml; do
|
||||
[[ -f "${VM_DIR}/xml/${i}" ]] || ln "${i}" "${VM_DIR}/xml/${i}"
|
||||
done
|
||||
|
|
|
@ -27,7 +27,7 @@ upload_image() {
|
|||
ln -f "${VM_DIR}/${VM_NAME}.qcow2" "/var/lib/libvirt/images/${VM_NAME}.qcow2"
|
||||
fi
|
||||
# check if VM-Machine-Definition XML exists
|
||||
if [[ ! (-f "/var/lib/libvirt/images/xml/${VM_NAME}.xml" || -f "${VM_DIR}/xml/${VM_NAME}") ]]; then
|
||||
if [[ ! (-f "/var/lib/libvirt/images/xml/${VM_NAME}.xml" || -f "${VM_DIR}/xml/${VM_NAME}.xml") ]]; then
|
||||
echo "File not found ${VM_NAME}.xml" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
@ -36,7 +36,7 @@ upload_image() {
|
|||
&& ( -f "/var/lib/libvirt/images/xml/${VM_NAME}.xml" && $(cmp -s "${VM_DIR}/xml/${VM_NAME}.xml" "/var/lib/libvirt/images/xml/${VM_NAME}.xml") \
|
||||
|| ! -f "/var/lib/libvirt/images/xml/${VM_NAME}.xml") ]]; then
|
||||
echo "copy private VM-Maschine-Definition XML to system-dir"
|
||||
cp "${VM_DIR}/${VM_NAME}.xml" "/var/lib/libvirt/images/${VM_NAME}.xml"
|
||||
cp "${VM_DIR}/xml/${VM_NAME}.xml" "/var/lib/libvirt/images/xml/"
|
||||
fi
|
||||
# (re-) create torrent file
|
||||
/usr/local/bin/vmimage-torrent create "${VM_NAME}.qcow2"
|
||||
|
|
Loading…
Add table
Reference in a new issue