diff options
author | Georg Pfuetzenreuter | 2022-05-25 14:35:24 +0200 |
---|---|---|
committer | Georg Pfuetzenreuter | 2022-05-25 14:35:24 +0200 |
commit | e029bd62317905cc965a4c2c49149a1752884926 (patch) | |
tree | c1e24b464d52124096632d62f6484eb54c7543bd /scripts/sh | |
parent | 48c935d283216bb96ded78c453186f6ab22ee201 (diff) | |
download | system-e029bd62317905cc965a4c2c49149a1752884926.tar.gz system-e029bd62317905cc965a4c2c49149a1752884926.tar.bz2 system-e029bd62317905cc965a4c2c49149a1752884926.zip |
Add libvirt XML generator
Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
Diffstat (limited to 'scripts/sh')
-rwxr-xr-x | scripts/sh/generate_libvirt_xml.sh | 63 |
1 files changed, 63 insertions, 0 deletions
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 + |