Skip to content

Commit

Permalink
Update start command to run setup if required otherwise resume services
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorbayless committed Sep 13, 2023
1 parent 72c2d0a commit d7acbc9
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions lila-docker
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
set -e

show_help() {
echo "Usage: $0 [start|stop|down|resume]"
echo "Usage: $0 [start|stop|down]"
}

run_start() {
run_setup() {
touch .env
docker compose run --rm -it lila_docker_rs bash -c "cd /mnt && cargo run"

Expand Down Expand Up @@ -35,6 +35,18 @@ run_start() {
fi
}

run_start() {
if [ -z "$(docker compose ps -a --services | xargs)" ]; then
run_setup
else
if [ ! -z "$(docker compose ps -a --services --status=exited | xargs)" ]; then
docker compose start
else
echo "There are no stopped services to resume"
fi
fi
}

run_stop() {
COMPOSE_PROFILES=$(all_profiles) docker compose stop
}
Expand All @@ -43,14 +55,6 @@ run_down() {
COMPOSE_PROFILES=$(all_profiles) docker compose down -v
}

run_resume() {
if [ ! -z "$(docker compose ps -a --services --status=exited | xargs)" ]; then
docker compose start
else
echo "There are no stopped services to resume"
fi
}

all_profiles() {
# return all Docker Compose profiles as a comma-separated string
docker compose config --profiles | xargs | sed -e 's/ /,/g'
Expand Down Expand Up @@ -89,9 +93,6 @@ case $1 in
down)
run_down
;;
resume)
run_resume
;;
*)
show_help
exit 1
Expand Down

0 comments on commit d7acbc9

Please sign in to comment.