|
|
@ -8,6 +8,12 @@ function disk_delete() { |
|
|
|
else |
|
|
|
else |
|
|
|
echo "NOTE! ${disk_img} not found. Doing nothing." |
|
|
|
echo "NOTE! ${disk_img} not found. Doing nothing." |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
local VMNAME=$(basename "${VM}" .conf) |
|
|
|
|
|
|
|
local SHORTCUT_DIR="/home/${USER}/.local/share/applications/" |
|
|
|
|
|
|
|
if [ -e ${SHORTCUT_DIR}/${VMNAME}.desktop ]; then |
|
|
|
|
|
|
|
rm -v "${SHORTCUT_DIR}/${VMNAME}.desktop" |
|
|
|
|
|
|
|
echo "Deleted ${VM} desktop shortcut" |
|
|
|
|
|
|
|
fi |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function snapshot_apply() { |
|
|
|
function snapshot_apply() { |
|
|
@ -377,6 +383,22 @@ function vm_boot() { |
|
|
|
fi |
|
|
|
fi |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function shortcut_create { |
|
|
|
|
|
|
|
local VMNAME=$(basename "${VM}" .conf) |
|
|
|
|
|
|
|
local LAUNCHER_DIR="$(dirname "$(realpath "$0")")" |
|
|
|
|
|
|
|
local filename="/home/${USER}/.local/share/applications/${VMNAME}.desktop" |
|
|
|
|
|
|
|
cat << EOF > ${filename} |
|
|
|
|
|
|
|
[Desktop Entry] |
|
|
|
|
|
|
|
Version=1.0 |
|
|
|
|
|
|
|
Type=Application |
|
|
|
|
|
|
|
Terminal=true |
|
|
|
|
|
|
|
Exec=${LAUNCHER_DIR}/${LAUNCHER} --vm ${VM} |
|
|
|
|
|
|
|
Name=${VMNAME} |
|
|
|
|
|
|
|
Icon=/snap/qemu-virgil/current/meta/gui/icon.png |
|
|
|
|
|
|
|
EOF |
|
|
|
|
|
|
|
echo "Created ${VMNAME}.desktop file" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function usage() { |
|
|
|
function usage() { |
|
|
|
echo |
|
|
|
echo |
|
|
|
echo "Usage" |
|
|
|
echo "Usage" |
|
|
@ -384,6 +406,7 @@ function usage() { |
|
|
|
echo |
|
|
|
echo |
|
|
|
echo "You can also pass optional parameters" |
|
|
|
echo "You can also pass optional parameters" |
|
|
|
echo " --delete : Delete the disk image." |
|
|
|
echo " --delete : Delete the disk image." |
|
|
|
|
|
|
|
echo " --shortcut : Create a desktop shortcut" |
|
|
|
echo " --snapshot apply <tag> : Apply/restore a snapshot." |
|
|
|
echo " --snapshot apply <tag> : Apply/restore a snapshot." |
|
|
|
echo " --snapshot create <tag> : Create a snapshot." |
|
|
|
echo " --snapshot create <tag> : Create a snapshot." |
|
|
|
echo " --snapshot delete <tag> : Delete a snapshot." |
|
|
|
echo " --snapshot delete <tag> : Delete a snapshot." |
|
|
@ -408,6 +431,7 @@ SNAPSHOT_TAG="" |
|
|
|
STATUS_QUO="" |
|
|
|
STATUS_QUO="" |
|
|
|
USB_PASSTHOUGH="" |
|
|
|
USB_PASSTHOUGH="" |
|
|
|
VM="" |
|
|
|
VM="" |
|
|
|
|
|
|
|
SHORTCUT=0 |
|
|
|
|
|
|
|
|
|
|
|
readonly LAUNCHER=$(basename "${0}") |
|
|
|
readonly LAUNCHER=$(basename "${0}") |
|
|
|
readonly DISK_MIN_SIZE=$((197632 * 8)) |
|
|
|
readonly DISK_MIN_SIZE=$((197632 * 8)) |
|
|
@ -441,6 +465,9 @@ while [ $# -gt 0 ]; do |
|
|
|
VM="${2}" |
|
|
|
VM="${2}" |
|
|
|
shift |
|
|
|
shift |
|
|
|
shift;; |
|
|
|
shift;; |
|
|
|
|
|
|
|
-shortcut|--shortcut) |
|
|
|
|
|
|
|
SHORTCUT=1 |
|
|
|
|
|
|
|
shift;; |
|
|
|
-h|--h|-help|--help) |
|
|
|
-h|--h|-help|--help) |
|
|
|
usage;; |
|
|
|
usage;; |
|
|
|
*) |
|
|
|
*) |
|
|
@ -495,4 +522,10 @@ if [ -n "${SNAPSHOT_ACTION}" ]; then |
|
|
|
esac |
|
|
|
esac |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ ${SHORTCUT} -eq 1 ]; then |
|
|
|
|
|
|
|
# echo "VM=" ${VM} |
|
|
|
|
|
|
|
shortcut_create |
|
|
|
|
|
|
|
exit |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
vm_boot |
|
|
|
vm_boot |