From 5cb831e15b1abc9eaafe83b74297b3950cf684a2 Mon Sep 17 00:00:00 2001 From: Marcus Date: Mon, 1 May 2023 12:00:55 +0200 Subject: [PATCH] colors for the installer --- src/root/install_nanodesk.sh | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/root/install_nanodesk.sh b/src/root/install_nanodesk.sh index 9ad7b17..90d9148 100755 --- a/src/root/install_nanodesk.sh +++ b/src/root/install_nanodesk.sh @@ -10,12 +10,41 @@ CHROOTCMD="chroot /mnt/" -message () { - echo "== " $1 +##message () { +## echo "== " $1 +##} + +# colors for colored output 8) +RED="\e[31m" +GREEN="\e[32m" +YELLOW="\e[33m" +ENDCOLOR="\e[0m" + +function message() { + case $1 in + warn) + MESSAGE_TYPE="${YELLOW}WARN${ENDCOLOR}" + ;; + error) + MESSAGE_TYPE="${RED}ERROR${ENDCOLOR}" + ;; + info|*) + MESSAGE_TYPE="${GREEN}INFO${ENDCOLOR}" + ;; + esac + + if [ "$1" == "info" ] || [ "$1" == "error" ] + then + MESSAGE=$2 + else + MESSAGE=$1 + fi + + echo -e "[${MESSAGE_TYPE}] $MESSAGE" } error () { - message "ERROR!" + message error "ERROR!" exit 1 }