setColors() { COL_NC='\e[0m' # No Color COL_LIGHT_GREEN='\e[1;32m' COL_LIGHT_RED='\e[1;31m' TICK="[${COL_LIGHT_GREEN}✓${COL_NC}]" CROSS="[${COL_LIGHT_RED}✗${COL_NC}]" INFO="[i]" # shellcheck disable=SC2034 DONE="${COL_LIGHT_GREEN} done!${COL_NC}" OVER="\\r\\033[K" FETT='\e[1m' } prepare_screen() { screen_size=$(stty size 2>/dev/null || echo 24 80) rows=$(echo "$screen_size" | awk '{print $1}') columns=$(echo "$screen_size" | awk '{print $2}') # Divide by two so the dialogs take up half of the screen, which looks nice. r=$(( rows / 2 )) c=$(( columns / 2 )) # Unless the screen is tiny r=$(( r < 20 ? 20 : r )) c=$(( c < 70 ? 70 : c )) } show_ascii_berry() { echo -e " ${COL_LIGHT_GREEN}.;;,. .ccccc:,. :cccclll:. ..,, :ccccclll. ;ooodc 'ccll:;ll .oooodc .;cll.;;looo:. ${COL_LIGHT_RED}.. ','. .',,,,,,'. .',,,,,,,,,,. .',,,,,,,,,,,,.... ....''',,,,,,,'....... ......... .... ......... .......... .......... .......... .......... ......... .... ......... ........,,,,,,,'...... ....',,,,,,,,,,,,. .',,,,,,,,,'. .',,,,,,'. ..'''.${COL_NC} " } is_command() { # Checks to see if the given command (passed as a string argument) exists on the system. # The function returns 0 (success) if the command exists, and 1 if it doesn't. local check_command="$1" command -v "${check_command}" >/dev/null 2>&1 } package_manager_detect() { if is_command apt-get ; then PKG_MANAGER="apt-get" UPDATE_PKF_CACHE="${PKG_MANAGER} update" PKG_INSTALL=("${PKG_MANAGER}" -qq --no-install-recommends install) elif is_command rpm ; then if is_command dnf ; then PKG_MANAGER="dnf" else PKG_MANAGER="yum" fi PKG_INSTALL=("${PKG_MANAGER}" install -y) fi } install_dependencies() { declare -a installArray for i in "$@"; do printf " %b Checking for %s...\\n" "${INFO}" "${i}" if is_command ${i} ; then printf " %b Checking for %s\\n" "${TICK}" "${i}" else printf " %b Checking for %s (will be installed)\\n" "${CROSS}" "${i}" installArray+="${i}" fi done if [[ "${#installArray[@]}" -gt 0 ]]; then printf " %b Processing %s install(s) for: %s, please wait...\\n" "${INFO}" "${PKG_MANAGER}" "${installArray[*]}" "${SUDO}" "${PKG_INSTALL[@]}" "${installArray[@]}" fi }