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

View File

@ -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,8 +7,23 @@ 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 error_exit() {
trap - ERR
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 msg_info() {
local msg="$1"
echo -ne " ${HOLD} ${YW}${msg}..."
@ -26,28 +34,6 @@ function msg_ok() {
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
exit $EXIT
}
function warn() {
local REASON="\e[97m$1\e[39m"
local FLAG="\e[93m[WARNING]\e[39m"
msg "$FLAG $REASON"
}
function info() {
local REASON="$1"
local FLAG="\e[36m[INFO]\e[39m"
msg "$FLAG $REASON"
}
function msg() {
local TEXT="$1"
echo -e "$TEXT"
}
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