2017-09-19 10:10:53 +00:00
|
|
|
COLOR_RED="\033[0;31m"
|
|
|
|
COLOR_GREEN="\033[0;32m"
|
|
|
|
COLOR_CYAN="\033[0;36m"
|
2018-02-02 09:54:00 +00:00
|
|
|
COLOR_YELLOW="\033[0;33m"
|
2017-09-19 10:10:53 +00:00
|
|
|
COLOR_PLAIN="\033[0m"
|
2020-09-06 11:35:43 +00:00
|
|
|
COLOR_PURPLE="\033[35m"
|
2017-09-19 10:10:53 +00:00
|
|
|
|
2018-12-13 15:49:43 +00:00
|
|
|
function check_util() {
|
|
|
|
which ${1} >/dev/null 2>&1 || fail "Missing ${1} util"
|
|
|
|
}
|
|
|
|
|
2020-09-06 11:35:43 +00:00
|
|
|
function debug() {
|
|
|
|
[[ ${DEBUG:-false} != false ]] || return 0
|
|
|
|
echo -e "${COLOR_PURPLE}$@${COLOR_PLAIN}"
|
|
|
|
}
|
|
|
|
|
2018-03-10 11:47:55 +00:00
|
|
|
function error() {
|
2018-10-07 12:41:29 +00:00
|
|
|
echo -e "${COLOR_RED}$@${COLOR_PLAIN}" >&2
|
2017-09-19 10:10:53 +00:00
|
|
|
}
|
|
|
|
|
2018-03-10 11:47:55 +00:00
|
|
|
function fail() {
|
2018-10-07 12:41:29 +00:00
|
|
|
error "$@"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function fatal() {
|
|
|
|
fail "$@"
|
2017-09-19 10:10:53 +00:00
|
|
|
}
|
|
|
|
|
2018-03-10 11:47:55 +00:00
|
|
|
function info() {
|
2018-10-07 12:41:29 +00:00
|
|
|
echo -e "${COLOR_CYAN}$@${COLOR_PLAIN}" >&2
|
2017-09-19 10:10:53 +00:00
|
|
|
}
|
|
|
|
|
2018-03-10 11:47:55 +00:00
|
|
|
function step() {
|
2018-12-13 15:49:43 +00:00
|
|
|
info "[$(date +%H:%M:%S)] $(printf "%${script_level:-0}s" '' | tr ' ' '+')$@"
|
2017-09-19 10:10:53 +00:00
|
|
|
}
|
2017-09-19 10:55:43 +00:00
|
|
|
|
2018-03-10 11:47:55 +00:00
|
|
|
function success() {
|
2018-10-07 12:41:29 +00:00
|
|
|
echo -e "${COLOR_GREEN}$@${COLOR_PLAIN}" >&2
|
2017-09-19 10:55:43 +00:00
|
|
|
}
|
2018-02-02 09:54:00 +00:00
|
|
|
|
2018-03-10 11:47:55 +00:00
|
|
|
function warn() {
|
2018-10-07 12:41:29 +00:00
|
|
|
echo -e "${COLOR_YELLOW}$@${COLOR_PLAIN}" >&2
|
2018-02-02 09:54:00 +00:00
|
|
|
}
|