From 6303e3e45fa9e7f453b44264c4bbb967ae51c769 Mon Sep 17 00:00:00 2001 From: tteckster Date: Wed, 23 Feb 2022 13:34:58 -0500 Subject: [PATCH] Update mariadb-install.sh --- setup/mariadb-install.sh | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/setup/mariadb-install.sh b/setup/mariadb-install.sh index c9a18f8a..ba82d3b1 100644 --- a/setup/mariadb-install.sh +++ b/setup/mariadb-install.sh @@ -1,6 +1,27 @@ #!/usr/bin/env bash -set -e +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 "Script interrupted."' INT + +function error_exit() { + trap - ERR + local DEFAULT='Unknown failure occured.' + local REASON="\e[97m${1:-$DEFAULT}\e[39m" + local FLAG="\e[91m[ERROR:LXC] \e[93m$EXIT@$LINE" + msg "$FLAG $REASON" + exit $EXIT +} +function msg() { + local TEXT="$1" + echo -e "$TEXT" +} + CROSS='\033[1;31m\xE2\x9D\x8C\033[0m' RD=`echo "\033[01;31m"` BL=`echo "\033[36m"`