create VMs without xml machine file

This commit is contained in:
Raphael Dannecker 2024-01-24 10:02:03 +01:00
parent 5a2ae0d33c
commit b5bb3c9fa6
5 changed files with 102 additions and 97 deletions

View file

@ -5,7 +5,7 @@ set -eu
show_help() {
cat << EOF >&2
Usage: $(basename "$0") vmname"
Create torrent and upload disk and xml-VM-Definiton on server.
Create torrent and upload disk on server.
EOF
}
@ -16,11 +16,6 @@ upload_image() {
echo "File not found ${VM_NAME}.qcow2" >&2
exit 1
fi
# check if VM-Machine-Definition XML exists
if [[ ! (-f "${VM_SYSDIR}/${VM_NAME}.xml" || -f "${VM_DIR}/${VM_NAME}.xml") ]]; then
echo "File not found ${VM_NAME}.xml" >&2
exit 1
fi
sudo vm-aria2 stop "${VM_NAME}" || echo "VMImage-torrent not running"
# link private VM-Diskimage to system-Dir
if [[ -f "${VM_DIR}/${VM_NAME}.qcow2" \
@ -30,19 +25,9 @@ upload_image() {
chown lmnsynci:lmnsynci "${VM_DIR}/${VM_NAME}.qcow2"
ln -f "${VM_DIR}/${VM_NAME}.qcow2" "${VM_SYSDIR}/${VM_NAME}.qcow2"
fi
# copy private VM-Maschine-Definition XML to system-Dir
if [[ -f "${VM_DIR}/${VM_NAME}.xml" \
&& ( -f "${VM_SYSDIR}/${VM_NAME}.xml" && $(cmp -s "${VM_DIR}/${VM_NAME}.xml" "${VM_SYSDIR}/${VM_NAME}.xml") \
|| ! -f "${VM_SYSDIR}/${VM_NAME}.xml") ]]; then
echo "copy private VM-Maschine-Definition XML to system-dir"
chown lmnsynci:lmnsynci "${VM_DIR}/${VM_NAME}.xml"
cp -a "${VM_DIR}/${VM_NAME}.xml" "${VM_SYSDIR}"
fi
cd "${VM_SYSDIR}"
uploadseed --server "${SEEDBOX_HOST}:${SEEDBOX_RPC_PORT}" --dht-port "${SEEDBOX_PORT}" \
--pwdfile "${SEEDBOX_PWFILE}" --no-cert "${VM_NAME}.qcow2"
uploadseed --server "${SEEDBOX_HOST}:${SEEDBOX_RPC_PORT}" --dht-port "${SEEDBOX_PORT}" \
--pwdfile "${SEEDBOX_PWFILE}" --no-cert "${VM_NAME}.xml"
}
source /etc/lmn/vm.conf