Files
healthchecks-ping/bashlib.sh

66 lines
1.0 KiB
Bash
Raw Normal View History

2025-04-14 09:31:10 +02:00
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
debug() {
2025-04-14 09:52:38 +02:00
if [[ -n "$DEBUG" ]]; then
local prompt=$1
shift
local messasge=$*
if [[ -n "$message" ]] ; then
message=": $message"
fi
echo -e "🐛 \033[0;36m[DEBUG] ${prompt}\033[0m${message}"
2025-04-14 09:31:10 +02:00
fi
}
error() {
2025-04-14 09:52:38 +02:00
local prompt=$1
2025-04-14 09:31:10 +02:00
shift
2025-04-14 09:52:38 +02:00
local messasge=$*
2025-04-14 09:31:10 +02:00
if [[ -n "$message" ]] ; then
message=": $message"
fi
echo -e "${RED}${prompt}:${NC}${message}"
exit 1
}
step() {
2025-04-14 09:52:38 +02:00
local prompt=$1
2025-04-14 09:31:10 +02:00
shift
2025-04-14 09:52:38 +02:00
local messasge=$*
2025-04-14 09:31:10 +02:00
if [[ -n "$message" ]] ; then
message=": $message"
fi
echo -e "${YELLOW}🔄 ${prompt}${NC}${message}"
}
success() {
2025-04-14 09:52:38 +02:00
local prompt=$1
2025-04-14 09:31:10 +02:00
shift
2025-04-14 09:52:38 +02:00
local messasge=$*
2025-04-14 09:31:10 +02:00
if [[ -n "$message" ]] ; then
message=": $message"
fi
echo -e "${GREEN}${prompt}${NC}${message}"
}
2025-04-14 09:52:38 +02:00
check_command() {
local command=$1
if [[ -z $(which ${command}) ]] ; then
2025-04-14 09:59:05 +02:00
error "Missing command" "${command}"
2025-04-14 09:52:38 +02:00
fi
}