You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.9 KiB
Bash

function print_installed_status () {
if [[ $2 -eq 0 ]]
then
printf "$BOLD%s$RESET %-$((65 - ${#1}))s ║ $LGREEN[ OK ]$RESET ║\n" "$1" "$3"
elif [[ $2 -eq 1 ]]
then
printf "$BOLD%s$RESET %-$((65 - ${#1}))s ║ $LBROWN[WARN]$RESET ║\n" "$1" "$3"
else
printf "$BOLD%s$RESET %-$((65 - ${#1}))s ║ $LRED$BLINK[FAIL]$RESET ║\n" "$1" "$3"
fi
}
function check_installed () {
if ! command -v $1 &> /dev/null
then
if [ $# -eq 1 ] || [ "$2" = "required" ]
then
print_installed_status $1 2 "is not installed"
else
print_installed_status $1 1 "is not installed"
fi
else
print_installed_status $1 0 "is installed"
fi
}
function check_docker_runnig () {
if ! command -v docker info > /dev/null 2>&1
then
print_installed_status "docker daemon" 2 "is not runnig"
else
print_installed_status "docker daemon" 0 "running"
fi
}
function env_check () {
clear
echo "╔═════════════════════════════════════════════════════════════════════════════╗"
echo -e "║ "$BOLD"Environment sanity check"$RESET" ║"
echo "╠════════════════════════════════════════════════════════════════════╦════════╣"
check_installed "docker"
check_docker_runnig
check_installed "docker-compose" "required"
check_installed "ctop" "optional"
echo "╚════════════════════════════════════════════════════════════════════╩════════╝"
}
CHUG_COMMAND_SET["env_check"]="env_check"