aboutsummaryrefslogtreecommitdiffstats
path: root/mcp
diff options
context:
space:
mode:
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>2018-01-26 03:50:10 +0100
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>2018-02-05 01:12:06 +0100
commit30d5ba634a5c249697509d7c4f29f4aca0597457 (patch)
tree64f736c03ae335f9ddeedf3074deaea651031d9e /mcp
parent965310d4c0fee5739b6a6a8ff4a40b2ee6c9c0c5 (diff)
deploy.sh: Move notify() to globals.sh
Extend `notify` to 4 variants: - notify_i = inline (no newline) colored output; - notify = `notify_i` + trailing '\n'; - notify_n = `notify` + extra '\n' before and after; - notify_e = `notify` + stderr output + exit; This allows us to remove '\n' and cleanup the code a bit. While at it, fix some 'NOTE' messages going to stderr instead of stdout. Change-Id: I682e3344ae9e307c4a68ab31c7766bc91b12ee58 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
Diffstat (limited to 'mcp')
-rw-r--r--mcp/scripts/globals.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/mcp/scripts/globals.sh b/mcp/scripts/globals.sh
index fe8d7a3f9..ace1de3a1 100644
--- a/mcp/scripts/globals.sh
+++ b/mcp/scripts/globals.sh
@@ -17,3 +17,31 @@ export MAAS_IP=${MAAS_IP:-${SALT_MASTER%.*}.3}
# Derivated from above global vars
export SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ${SSH_KEY}"
export SSH_SALT="${SALT_MASTER_USER}@${SALT_MASTER}"
+
+##############################################################################
+# BEGIN of colored notification wrappers
+#
+function notify() {
+ local msg=${1}; shift
+ notify_i "${msg}\n" "$@"
+}
+
+function notify_i() {
+ tput setaf "${2:-1}" || true
+ echo -en "${1:-"[WARN] Unsupported opt arg: $3\\n"}"
+ tput sgr0
+}
+
+function notify_n() {
+ local msg=${1}; shift
+ notify_i "\n${msg}\n\n" "$@"
+}
+
+function notify_e() {
+ local msg=${1}; shift
+ notify_i "\n${msg}\n\n" "$@" 1>&2
+ exit 1
+}
+#
+# END of colored notification wrapper
+##############################################################################