From e029bd62317905cc965a4c2c49149a1752884926 Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Wed, 25 May 2022 14:35:24 +0200 Subject: Add libvirt XML generator Signed-off-by: Georg Pfuetzenreuter --- scripts/sh/generate_libvirt_xml.sh | 63 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 scripts/sh/generate_libvirt_xml.sh (limited to 'scripts/sh') diff --git a/scripts/sh/generate_libvirt_xml.sh b/scripts/sh/generate_libvirt_xml.sh new file mode 100755 index 0000000..4f9b5d3 --- /dev/null +++ b/scripts/sh/generate_libvirt_xml.sh @@ -0,0 +1,63 @@ +#!/bin/sh + +menu() { + echo "1) Domain XML" + echo "2) Volume XML (not yet implemented)" + echo "3) Network XML (not yet implemented" + echo "x) Exit" + echo +} + +selection() { + local selection + echo "Enter [1|2|3|x] " + read selection + case $selection in + 1) domain ;; + 2) volume ;; + 3) network ;; + x) + echo "Aborting on user request." + exit 0 + ;; + *) echo -e "${RED}Invalid input.${STD}" + esac +} + +#trap '' SIGINT SIGQUIT SIGSTP + +domain() { + local name + local storelocation + local store + local storename + echo "Name of the new domain: " + read name + echo "Storage location of the disk: /mnt/" + read storelocation + echo "Storage name of the pool: /mnt/$storelocation/" + read store + echo + echo "Name: $name" + echo "Disk: /mnt/$storelocation/$store/$name.qcow2" + echo "Correct? [y|n|x] " + read confirmation + case $confirmation in + y | yes) echo "OK" ;; + n | no) echo "Starting over" && domain ;; + x | menu) menu + esac + + sed -e "s/%%NAME%%/$name/" -e "s/%%STORELOCATION%%/$storelocation/" -e "s/%%STORE%%/$store/" template.xml > $name.xml + + echo "Created $name.xml" + exit 1 +} + + +while true +do + menu + selection +done + -- cgit v1.2.3