Update create_lxc.sh

This commit is contained in:
tteckster 2022-04-25 10:20:22 -04:00 committed by GitHub
parent 785ca697b3
commit dc446ad109
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 35 deletions

View File

@ -1,11 +1,4 @@
#!/usr/bin/env bash #!/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"` YW=`echo "\033[33m"`
BL=`echo "\033[36m"` BL=`echo "\033[36m"`
RD=`echo "\033[01;31m"` RD=`echo "\033[01;31m"`
@ -14,40 +7,33 @@ CL=`echo "\033[m"`
CM="${GN}${CL}" CM="${GN}${CL}"
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD="-" 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 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() { function error_exit() {
trap - ERR trap - ERR
local DEFAULT='Unknown failure occured.' local reason="Unknown failure occured."
local REASON="\e[97m${1:-$DEFAULT}\e[39m" local msg="${1:-$reason}"
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
msg "$FLAG $REASON" 1>&2 echo -e "$flag $msg" 1>&2
exit $EXIT exit $EXIT
} }
function warn() {
local REASON="\e[97m$1\e[39m" function msg_info() {
local FLAG="\e[93m[WARNING]\e[39m" local msg="$1"
msg "$FLAG $REASON" echo -ne " ${HOLD} ${YW}${msg}..."
} }
function info() {
local REASON="$1" function msg_ok() {
local FLAG="\e[36m[INFO]\e[39m" local msg="$1"
msg "$FLAG $REASON" echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
}
function msg() {
local TEXT="$1"
echo -e "$TEXT"
} }
function select_storage() { function select_storage() {
local CLASS=$1 local CLASS=$1
local CONTENT local CONTENT
@ -100,10 +86,10 @@ if pct status $CTID &>/dev/null; then
fi fi
TEMPLATE_STORAGE=$(select_storage template) || exit 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 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" msg_info "Updating LXC Template List"
pveam update >/dev/null pveam update >/dev/null