Move to functions.sh

This commit is contained in:
Martin Lablans 2022-10-28 10:12:21 +02:00
parent 5755baaf00
commit 2aef5f29c3
3 changed files with 11 additions and 6 deletions

View File

@ -58,6 +58,8 @@ if [ -f "$PROJECT/docker-compose.override.yml" ]; then
OVERRIDE+=" -f ./$PROJECT/docker-compose.override.yml"
fi
detectCompose
case "$ACTION" in
start)
hc_send log "Bridgehead $PROJECT startup: Checking requirements ..."

View File

@ -2,6 +2,15 @@
source lib/log.sh
detectCompose() {
if [[ "$(docker compose version 2>/dev/null)" == *"Docker Compose version"* ]]; then
COMPOSE="docker compose"
else
COMPOSE="docker-compose"
# This is intended to fail on startup in the next prereq check.
fi
}
exitIfNotRoot() {
if [ "$EUID" -ne 0 ]; then
log "ERROR" "Please run as root"

View File

@ -10,12 +10,6 @@ fi
checkOwner . bridgehead || exit 1
checkOwner /etc/bridgehead bridgehead || exit 1
if [[ "$(docker compose version 2>/dev/null)" == *"Docker Compose version"* ]]; then
COMPOSE="docker compose"
else
COMPOSE="docker-compose"
fi
## Check if user is a su
log INFO "Checking if all prerequisites are met ..."
prerequisites="git docker $COMPOSE"