From b4361d455e48404bd13c3fccdcffc80d36dc5774 Mon Sep 17 00:00:00 2001 From: Severin Kaderli Date: Tue, 17 Sep 2019 18:50:16 +0200 Subject: [PATCH] Update install script and utils Signed-off-by: Severin Kaderli --- install | 22 +++++++++++----------- system/.local/bin/utils | 22 ++++++++++------------ 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/install b/install index 6960444..b5e3831 100755 --- a/install +++ b/install @@ -266,7 +266,7 @@ print_section "Creating directories" for dir in "${DIRECTORIES[@]}" do - print_log "Creating directory ${YELLOW}${HOME}/${dir}${RESET}" + print_log "Creating directory ${YELLOW}${HOME}/${dir}${DEFAULT}" mkdir -p "${HOME}/${dir}" done @@ -286,13 +286,13 @@ fi print_section "Creating symlinks" for file in "${LINKED_FILES_HOME[@]}"; do - print_log "Linking ${YELLOW}${HOME}/${file}${RESET} to ${YELLOW}${SYSTEM_DIR}/${file}${RESET}" + print_log "Linking ${YELLOW}${HOME}/${file}${DEFAULT} to ${YELLOW}${SYSTEM_DIR}/${file}${DEFAULT}" rm -rf "${HOME:?}/${file}" ln -fs "${SYSTEM_DIR}/${file}" "${HOME}/${file}" done for file in "${!LINKED_FILES[@]}"; do - print_log "Linking ${YELLOW}${file}${RESET} to ${YELLOW}${LINKED_FILES[${file}]}${RESET}" + print_log "Linking ${YELLOW}${file}${DEFAULT} to ${YELLOW}${LINKED_FILES[${file}]}${DEFAULT}" rm -rf "${file}" ln -fs "${LINKED_FILES[${file}]}" "${file}" done @@ -303,9 +303,9 @@ done ############################################################################### print_section "Giving permissions" for permission in "${!PERMISSIONS[@]}"; do - print_log "Changing owner of ${YELLOW}${permission}${RESET} to ${YELLOW}${USER}${RESET}" + print_log "Changing owner of ${YELLOW}${permission}${DEFAULT} to ${YELLOW}${USER}${DEFAULT}" sudo chown -R "${USER}" "${permission}" - print_log "Changing permission of ${YELLOW}${permission}${RESET} to ${YELLOW}${PERMISSIONS[${permission}]}${RESET}" + print_log "Changing permission of ${YELLOW}${permission}${DEFAULT} to ${YELLOW}${PERMISSIONS[${permission}]}${DEFAULT}" sudo chmod -R "${PERMISSIONS[${permission}]}" "${permission}" done @@ -316,7 +316,7 @@ done print_section "Adding user to groups" for group in "${ADD_GROUPS[@]}" do - print_log "Adding user ${YELLOW}${USER}${RESET} to group ${YELLOW}${group}${RESET}" + print_log "Adding user ${YELLOW}${USER}${DEFAULT} to group ${YELLOW}${group}${DEFAULT}" sudo gpasswd -a "${USER}" "${group}" > /dev/null 2>&1 done @@ -327,7 +327,7 @@ done print_section "Copying systemd services" for file in "${SYSTEM_DIR}/etc/systemd/system/"* do - print_log "Copying ${YELLOW}$(basename "${file}")${RESET} to ${YELLOW}/etc/systemd/system${RESET}" + print_log "Copying ${YELLOW}$(basename "${file}")${DEFAULT} to ${YELLOW}/etc/systemd/system${DEFAULT}" sudo install -m 644 "${file}" "/etc/systemd/system" done @@ -338,13 +338,13 @@ done print_section "Enabling systemd services" for service in "${SYSTEMD_SERVICES[@]}" do - print_log "Enabling service ${YELLOW}${service}${RESET}" + print_log "Enabling service ${YELLOW}${service}${DEFAULT}" sudo systemctl enable "${service}" done for service in "${SYSTEMD_USER_SERVICES[@]}" do - print_log "Enabling service ${YELLOW}${service}${RESET}" + print_log "Enabling service ${YELLOW}${service}${DEFAULT}" systemctl --user enable "${service}" done @@ -355,7 +355,7 @@ done print_section "Copying custom udev rules" for file in "${SYSTEM_DIR}/etc/udev/rules.d/"*.rules do - print_log "Copying ${YELLOW}$(basename "${file}")${RESET} to ${YELLOW}/etc/udev/rules.d/${RESET}" + print_log "Copying ${YELLOW}$(basename "${file}")${DEFAULT} to ${YELLOW}/etc/udev/rules.d/${DEFAULT}" sudo cp "${file}" "/etc/udev/rules.d/" done sudo udevadm control --reload-rules @@ -366,7 +366,7 @@ sudo udevadm control --reload-rules ############################################################################### print_section "Copying root files" for file in "${!COPY_ROOT_FILES[@]}"; do - print_log "Copying ${YELLOW}${file}${RESET}" + print_log "Copying ${YELLOW}${file}${DEFAULT}" sudo install -Dm "${COPY_ROOT_FILES[${file}]}" "${SYSTEM_DIR}${file}" "${file}" done diff --git a/system/.local/bin/utils b/system/.local/bin/utils index 22c5411..ec05106 100755 --- a/system/.local/bin/utils +++ b/system/.local/bin/utils @@ -22,13 +22,13 @@ PACKAGES_DIR="${DIR}/packages" ####################################### # Bash color code variables ####################################### -RESET='\033[0m' -GREEN='\033[32m' -RED='\033[31m' -BLUE='\033[34m' -YELLOW='\033[33m' +RESET="$(tput sgr0)" +GREEN="$(tput setaf 2)" +RED="$(tput setaf 1)" +BLUE="$(tput setaf 4)" +DEFAULT="$(tput op)" +YELLOW="$(tput setaf 3)" BOLD="$(tput bold)" -NORMAL="$(tput sgr0)" ####################################### # Helper functions @@ -44,23 +44,21 @@ function print_time_log() { # USAGE: print_notify TITLE MESSAGE function print_notify() { notify-send "${1}" "${2}" - echo -e "${YELLOW}[$(date "+%T")] ${1} ${2}${RESET}" + echo -e "${YELLOW}[$(date "+%T")] ${1} ${2}${DEFAULT}" } # Prints a section title. # USAGE: print_section TITLE function print_section() { - echo -e "${YELLOW}${BOLD}┌──────────────────────────────────────────────────────────────────────────────┐" - echo -e "│ $(printf "%-77s" "${1}")│" - echo -e "└──────────────────────────────────────────────────────────────────────────────┘${RESET}" + echo -e "${BOLD}${BLUE}::${DEFAULT} ${1}${RESET}" } function print_log() { - echo -e " • $1" + echo -e " ${BLUE}->${DEFAULT} ${1}" } function ask_prompt() { - read -p "${BOLD}${1} (y/n): ${NORMAL}" -n 1 -r + read -p "${BOLD}${BLUE}::${DEFAULT} ${1} [Y/n] ${RESET}" -n 1 -r echo "" if [[ ${REPLY} =~ ^[^yY]$ ]]; then