From c7a804f3f14788010bfc9526adf154c88a49da27 Mon Sep 17 00:00:00 2001 From: "Kevin Veen-Birkenbach [aka. Frantz]" Date: Sat, 2 May 2020 12:37:26 +0200 Subject: [PATCH] Optimized base.sh --- scripts/base.sh | 59 ++++++++++++++++++++++++++++------------- scripts/client/setup.sh | 7 ++--- 2 files changed, 45 insertions(+), 21 deletions(-) diff --git a/scripts/base.sh b/scripts/base.sh index 84c1740..668d9e7 100644 --- a/scripts/base.sh +++ b/scripts/base.sh @@ -4,6 +4,7 @@ # @author Kevin Veen-Birkenbach [aka. Frantz] # # shellcheck disable=SC2034 #Deactivate checking of unused variables + REPOSITORY_PATH=$(readlink -f "$(dirname "$(readlink -f "${0}")")/../") ENCRYPTED_PATH="$REPOSITORY_PATH/.encrypted"; DECRYPTED_PATH="$REPOSITORY_PATH/decrypted"; @@ -24,23 +25,45 @@ declare -a BACKUP_LIST=("$HOME/.ssh/" \ "$HOME/Documents/passwords/" \ "$HOME/Documents/licenses/"); - COLOR_RED=$(tput setaf 1) - COLOR_GREEN=$(tput setaf 2) - COLOR_YELLOW=$(tput setaf 3) - COLOR_BLUE=$(tput setaf 4) - COLOR_MAGENTA=$(tput setaf 5) - COLOR_CYAN=$(tput setaf 6) - COLOR_WHITE=$(tput setaf 7) - COLOR_RESET=$(tput sgr0) +COLOR_RED=$(tput setaf 1) +COLOR_GREEN=$(tput setaf 2) +COLOR_YELLOW=$(tput setaf 3) +COLOR_BLUE=$(tput setaf 4) +COLOR_MAGENTA=$(tput setaf 5) +COLOR_CYAN=$(tput setaf 6) +COLOR_WHITE=$(tput setaf 7) +COLOR_RESET=$(tput sgr0) - HEADER(){ - echo - echo "${COLOR_YELLOW}The" - base64 -d <<<"ICBfX19fXyAgICAgICAgICAgICAgICBfX19fXyAgICAgICAgICAgXyAgICAgICAgICAgICAgICAgCiAvIF9fX198ICAgICAgICAgICAgICAvIF9fX198ICAgICAgICAgfCB8ICAgICAgICAgICAgICAgIAp8IHwgICAgIF9fXyAgXyBfXyBfX198IChfX18gIF8gICBfIF9fX3wgfF8gX19fIF8gX18gX19fICAKfCB8ICAgIC8gXyBcfCAnX18vIF8gXFxfX18gXHwgfCB8IC8gX198IF9fLyBfIFwgJ18gYCBfIFwgCnwgfF9fX3wgKF8pIHwgfCB8ICBfXy9fX19fKSB8IHxffCBcX18gXCB8fCAgX18vIHwgfCB8IHwgfAogXF9fX19fXF9fXy98X3wgIFxfX198X19fX18vIFxfXywgfF9fXy9cX19cX19ffF98IHxffCB8X3wKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX18vIHwgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfF9fXy8gICAgICAgICAgICAgICAgICAgICAgIAo=" - echo "is an administration tool designed from and for Kevin Veen-Birkenbach." - echo - echo "Licensed under GNU GENERAL PUBLIC LICENSE Version 3" - echo "${COLOR_RESET}" - } +# FUNCTIONS - HEADER +message(){ + echo "$1[$2]:${COLOR_RESET} $3 "; +} + +question(){ + message "${COLOR_MAGENTA}" "QUESTION" "$1"; +} + +info(){ + message "${COLOR_BLUE}" "INFO" "$1"; +} + +warning(){ + message "${COLOR_YELLOW}" "WARNING" "$1"; +} + +success(){ + message "${COLOR_GREEN}" "SUCCESS" "$1"; +} + +HEADER(){ + echo + echo "${COLOR_YELLOW}The" + base64 -d <<<"ICBfX19fXyAgICAgICAgICAgICAgICBfX19fXyAgICAgICAgICAgXyAgICAgICAgICAgICAgICAgCiAvIF9fX198ICAgICAgICAgICAgICAvIF9fX198ICAgICAgICAgfCB8ICAgICAgICAgICAgICAgIAp8IHwgICAgIF9fXyAgXyBfXyBfX198IChfX18gIF8gICBfIF9fX3wgfF8gX19fIF8gX18gX19fICAKfCB8ICAgIC8gXyBcfCAnX18vIF8gXFxfX18gXHwgfCB8IC8gX198IF9fLyBfIFwgJ18gYCBfIFwgCnwgfF9fX3wgKF8pIHwgfCB8ICBfXy9fX19fKSB8IHxffCBcX18gXCB8fCAgX18vIHwgfCB8IHwgfAogXF9fX19fXF9fXy98X3wgIFxfX198X19fX18vIFxfXywgfF9fXy9cX19cX19ffF98IHxffCB8X3wKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX18vIHwgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfF9fXy8gICAgICAgICAgICAgICAgICAgICAgIAo=" + echo "is an administration tool designed from and for Kevin Veen-Birkenbach." + echo + echo "Licensed under GNU GENERAL PUBLIC LICENSE Version 3" + echo "${COLOR_RESET}" +} + +HEADER diff --git a/scripts/client/setup.sh b/scripts/client/setup.sh index 9b66642..bd06519 100644 --- a/scripts/client/setup.sh +++ b/scripts/client/setup.sh @@ -4,10 +4,11 @@ # @author Kevin Veen-Birkenbach [aka. Frantz] # # shellcheck source=/dev/null # Deactivate SC1090 -source "$(dirname "$(readlink -f "${0}")")/base.sh" || echo "Loading base.sh failed." && exit 1 +source "$(dirname "$(readlink -f "${0}")")/../base.sh" || (echo "Loading base.sh failed." && exit 1) SYSTEM_MEMORY_KB="$(grep MemTotal /proc/meminfo | awk '{print $2}')" -echo "Start setup of customized core software..." -echo "Copying templates to home folder..." +info "Start setup of customized core software..." +info "Copying templates to home folder..." +exit cp -rfv "$TEMPLATE_PATH/." "$HOME" echo "Synchronising packages..." sudo pacman -Syyu