#!/bin/bash # for testing only set -o pipefail shopt -s expand_aliases alias die='EXIT=$? LINE=$LINENO error_exit' trap die ERR function error_exit() { REASON=$1 MSG="\e[91mERROR: \e[93m$EXIT@" if [ -z "$REASON" ]; then MSG="$MSG$LINE:" REASON="Unknown failure occured." else MSG="$MSG`echo $(( $LINE - 1 ))`:" fi echo -e "$MSG \e[97m$REASON\e[39m\e[49m" exit $EXIT } function cleanup() { popd >/dev/null rm -rf $TMP } trap cleanup EXIT TMP=`mktemp -d` pushd $TMP >/dev/null VMID=$(cat<&/dev/null && \ qm importdisk $VMID ${FILE%".xz"} local 1>&/dev/null echo -e "Completed Successfully, New VM ID is $VMID \n"