diff --git a/modules/services.sh b/modules/services.sh index 2e9426a9e..add2d1174 100644 --- a/modules/services.sh +++ b/modules/services.sh @@ -1,5 +1,15 @@ function services { - check_missing_binary docker-compose "docker-compose is missing\ninstall instructions can be found in\nhttps://github.com/docker/compose" + check_missing_binary docker "docker is missing\ninstallation instructions can be found at\nhttps://docs.docker.com/engine/install/" + + if which docker-compose > /dev/null 2>&1; then + dockercompose="docker-compose" + elif docker compose | grep -q "Usage"; then + dockercompose="docker compose" + else + echo "neither docker-compose nor docker compose found." + echo "installation instructions can be found at https://github.com/docker/compose" + exit 1 + fi local service_name command command_option service results installed local array running port_string found local_url tor_url @@ -124,7 +134,7 @@ function services { retries=0 while [ "$retries" -lt 5 ]; do - if ! docker-compose --project-directory /srv/$service_name -f /srv/${service_name}/${service_name}.yml pull ; then + if ! $dockercompose --project-directory /srv/$service_name -f /srv/${service_name}/${service_name}.yml pull ; then if [ "$retries" -lt 4 ]; then echo "retrying pull in 6 seconds" sleep 6 @@ -147,13 +157,13 @@ function services { checkargn $# 2 if [ "$service_name" = "planet" ]; then if [ -f /srv/planet/pwd/credentials.yml ]; then - if docker-compose -f /srv/planet/planet.yml -f /srv/planet/volumes.yml -f /srv/planet/pwd/credentials.yml -p planet up -d ; then + if $dockercompose -f /srv/planet/planet.yml -f /srv/planet/volumes.yml -f /srv/planet/pwd/credentials.yml -p planet up -d ; then echo "planet built and started" else log_and_exit1 "ERROR: cannot build planet" fi else - if docker-compose -f /srv/planet/planet.yml -f /srv/planet/volumes.yml -p planet up -d ; then + if $dockercompose -f /srv/planet/planet.yml -f /srv/planet/volumes.yml -p planet up -d ; then echo "planet built and started" else log_and_exit1 "ERROR: cannot build planet" @@ -176,7 +186,7 @@ function services { if [ ! -f /srv/${service_name}/${service_name}.yml ]; then echo "${service_name}.yml not found" else - docker-compose --project-directory /srv/$service_name -f /srv/${service_name}/${service_name}.yml down + $dockercompose --project-directory /srv/$service_name -f /srv/${service_name}/${service_name}.yml down remove_tor_port echo "${service_name} stopped and removed" fi @@ -187,7 +197,7 @@ function services { if [ ! -f /srv/${service_name}/${service_name}.yml ]; then log_comment_and_exit1 "ERROR: /srv/${service_name}/${service_name}.yml not found" "try running '$BASENAME services ${service_name} install' first" else - if docker-compose --project-directory /srv/$service_name -f /srv/${service_name}/${service_name}.yml start; then + if $dockercompose --project-directory /srv/$service_name -f /srv/${service_name}/${service_name}.yml start; then echo "${service_name} started" fi fi @@ -201,7 +211,7 @@ function services { if [ ! -f /srv/${service_name}/${service_name}.yml ]; then log_comment_and_exit1 "ERROR: /srv/${service_name}/${service_name}.yml not found" "try running '$BASENAME services ${service_name} install' first" else - if docker-compose --project-directory /srv/$service_name -f /srv/${service_name}/${service_name}.yml stop; then + if $dockercompose --project-directory /srv/$service_name -f /srv/${service_name}/${service_name}.yml stop; then echo "${service_name} stopped" fi fi @@ -338,7 +348,7 @@ function services { if [ ! -f /srv/${service_name}/${service_name}.yml ]; then log_comment_and_exit1 "ERROR: ${service_name}.yml not found" "try running '$BASENAME services ${service_name} install' first" else - docker-compose --project-directory /srv/$service_name -f /srv/${service_name}/${service_name}.yml --log-level ERROR down -v --rmi all --remove-orphans + $dockercompose --project-directory /srv/$service_name -f /srv/${service_name}/${service_name}.yml --log-level ERROR down -v --rmi all --remove-orphans echo "${service_name} stopped and removed" fi remove_tor_port @@ -359,7 +369,7 @@ function services { seperator="--------------------" case $command_option in "") - docker-compose --project-directory /srv/$service_name -f /srv/$service_name/$service_name.yml config + $dockercompose --project-directory /srv/$service_name -f /srv/$service_name/$service_name.yml config ;; "new") checkargn $# 4 @@ -546,7 +556,7 @@ function check_tor { function docker_compose_up { if [ ! -f /srv/${1}/${1}.yml ]; then log_comment_and_exit1 "ERROR: /srv/${1}/${1}.yml not found" "try running '$BASENAME services ${1} install' first" - elif docker-compose --project-directory /srv/${1} -f /srv/${1}/${1}.yml -p ${1} up -d ; then + elif $dockercompose --project-directory /srv/${1} -f /srv/${1}/${1}.yml -p ${1} up -d ; then echo "${1} built and started" else log_and_exit1 "ERROR: cannot build ${1}" diff --git a/package.json b/package.json index d13428761..f9e8d81db 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@treehouses/cli", - "version": "1.26.15", + "version": "1.26.16", "remote": "6000", "description": "Thin command-line interface for Raspberry Pi low level configuration.", "main": "cli.sh",