From dc446ad10966aa52ddb9705862b90917f8eb3e47 Mon Sep 17 00:00:00 2001 From: tteckster Date: Mon, 25 Apr 2022 10:20:22 -0400 Subject: [PATCH] Update create_lxc.sh --- ct/create_lxc.sh | 56 ++++++++++++++++++------------------------------ 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/ct/create_lxc.sh b/ct/create_lxc.sh index c0db635d..1f70d623 100644 --- a/ct/create_lxc.sh +++ b/ct/create_lxc.sh @@ -1,11 +1,4 @@ #!/usr/bin/env bash - -set -o errexit -set -o errtrace -set -o nounset -set -o pipefail -shopt -s expand_aliases -alias die='EXIT=$? LINE=$LINENO error_exit' YW=`echo "\033[33m"` BL=`echo "\033[36m"` RD=`echo "\033[01;31m"` @@ -14,40 +7,33 @@ CL=`echo "\033[m"` CM="${GN}✓${CL}" BFR="\\r\\033[K" HOLD="-" +set -o errexit +set -o errtrace +set -o nounset +set -o pipefail +shopt -s expand_aliases +alias die='EXIT=$? LINE=$LINENO error_exit' trap die ERR -function msg_info() { - local msg="$1" - echo -ne " ${HOLD} ${YW}${msg}..." -} - -function msg_ok() { - local msg="$1" - echo -e "${BFR} ${CM} ${GN}${msg}${CL}" -} - function error_exit() { trap - ERR - local DEFAULT='Unknown failure occured.' - local REASON="\e[97m${1:-$DEFAULT}\e[39m" - local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" - msg "$FLAG $REASON" 1>&2 + local reason="Unknown failure occured." + local msg="${1:-$reason}" + local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE" + echo -e "$flag $msg" 1>&2 exit $EXIT } -function warn() { - local REASON="\e[97m$1\e[39m" - local FLAG="\e[93m[WARNING]\e[39m" - msg "$FLAG $REASON" + +function msg_info() { + local msg="$1" + echo -ne " ${HOLD} ${YW}${msg}..." } -function info() { - local REASON="$1" - local FLAG="\e[36m[INFO]\e[39m" - msg "$FLAG $REASON" -} -function msg() { - local TEXT="$1" - echo -e "$TEXT" + +function msg_ok() { + local msg="$1" + echo -e "${BFR} ${CM} ${GN}${msg}${CL}" } + function select_storage() { local CLASS=$1 local CONTENT @@ -100,10 +86,10 @@ if pct status $CTID &>/dev/null; then fi TEMPLATE_STORAGE=$(select_storage template) || exit -msg_ok "Using ${BL}$TEMPLATE_STORAGE${CL} ${GN}for Template Storage." +msg_ok "Using ${BL}ℹ $TEMPLATE_STORAGE${CL} ${GN}for Template Storage." CONTAINER_STORAGE=$(select_storage container) || exit -msg_ok "Using ${BL}$CONTAINER_STORAGE${CL} ${GN}for Container Storage." +msg_ok "Using ${BL}ℹ $CONTAINER_STORAGE${CL} ${GN}for Container Storage." msg_info "Updating LXC Template List" pveam update >/dev/null