Merge pull request #29 from samply/feature/robustcompose
Support docker compose as well as docker-compose
This commit is contained in:
commit
79fc157ad4
|
@ -58,15 +58,17 @@ 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 ..."
|
||||
checkRequirements
|
||||
hc_send log "Bridgehead $PROJECT startup: Requirements checked out. Now starting bridgehead ..."
|
||||
exec docker-compose -f ./$PROJECT/docker-compose.yml $OVERRIDE up --abort-on-container-exit
|
||||
exec $COMPOSE -f ./$PROJECT/docker-compose.yml $OVERRIDE up --abort-on-container-exit
|
||||
;;
|
||||
stop)
|
||||
exec docker-compose -f ./$PROJECT/docker-compose.yml $OVERRIDE down
|
||||
exec $COMPOSE -f ./$PROJECT/docker-compose.yml $OVERRIDE down
|
||||
;;
|
||||
update)
|
||||
exec ./lib/update-bridgehead.sh $PROJECT
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
source lib/functions.sh
|
||||
|
||||
detectCompose
|
||||
|
||||
if ! id "bridgehead" &>/dev/null; then
|
||||
log ERROR "User bridgehead does not exist. Please consult readme for installation."
|
||||
exit 1
|
||||
|
@ -12,7 +14,7 @@ checkOwner /etc/bridgehead bridgehead || exit 1
|
|||
|
||||
## Check if user is a su
|
||||
log INFO "Checking if all prerequisites are met ..."
|
||||
prerequisites="git docker docker-compose"
|
||||
prerequisites="git docker $COMPOSE"
|
||||
for prerequisite in $prerequisites; do
|
||||
$prerequisite --version 2>&1
|
||||
is_available=$?
|
||||
|
|
Loading…
Reference in New Issue