From 985beaa815699addeac2ccccab48c9cf89d5d33c Mon Sep 17 00:00:00 2001 From: Foxlet Date: Mon, 6 May 2019 05:40:00 -0400 Subject: [PATCH] [TOOLS] virsh XML generator. --- make.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 make.sh diff --git a/make.sh b/make.sh new file mode 100755 index 0000000..5f6d2de --- /dev/null +++ b/make.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# make.sh: Generate customized libvirt XML. +# by Foxlet + +VMDIR=$PWD +OUT="template.xml" + +print_usage() { + echo + echo "Usage: $0" + echo + echo " -a, --add Add XML to virsh (uses sudo)." + echo +} + +error() { + local error_message="$@" + echo "${error_message}" 1>&2; +} + +generate(){ + sed -e "s|VMDIR|$VMDIR|g" tools/template.xml.in > $OUT + echo "$OUT has been generated in $VMDIR" +} + +generate + +argument="$1" +case $argument in + -a|--add) + sudo virsh define $OUT + ;; + -h|--help) + print_usage + ;; +esac