From d2269de4adc5acc3c6aa3609f7e79420ca16ed22 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sat, 23 May 2020 18:25:00 +0100 Subject: [PATCH] Claenup docker util scripts --- .../files/docker-utils/{ctop.sh => ctop} | 0 ansible/roles/docker-cleanup/files/docker-utils/dc | 5 +++++ .../files/docker-utils/{pull-all.sh => dc-all} | 2 +- .../files/docker-utils/hard-reset-all.sh | 13 ------------- .../files/docker-utils/hard-restart-all | 12 ++++++++++++ ansible/roles/docker-cleanup/files/docker-utils/occ | 5 +++++ .../roles/docker-cleanup/files/docker-utils/occ.sh | 5 ----- .../docker-cleanup/files/docker-utils/start-all.sh | 11 ----------- .../docker-cleanup/files/docker-utils/stop-all.sh | 11 ----------- 9 files changed, 23 insertions(+), 41 deletions(-) rename ansible/roles/docker-cleanup/files/docker-utils/{ctop.sh => ctop} (100%) create mode 100755 ansible/roles/docker-cleanup/files/docker-utils/dc rename ansible/roles/docker-cleanup/files/docker-utils/{pull-all.sh => dc-all} (62%) delete mode 100755 ansible/roles/docker-cleanup/files/docker-utils/hard-reset-all.sh create mode 100755 ansible/roles/docker-cleanup/files/docker-utils/hard-restart-all create mode 100755 ansible/roles/docker-cleanup/files/docker-utils/occ delete mode 100644 ansible/roles/docker-cleanup/files/docker-utils/occ.sh delete mode 100755 ansible/roles/docker-cleanup/files/docker-utils/start-all.sh delete mode 100755 ansible/roles/docker-cleanup/files/docker-utils/stop-all.sh diff --git a/ansible/roles/docker-cleanup/files/docker-utils/ctop.sh b/ansible/roles/docker-cleanup/files/docker-utils/ctop similarity index 100% rename from ansible/roles/docker-cleanup/files/docker-utils/ctop.sh rename to ansible/roles/docker-cleanup/files/docker-utils/ctop diff --git a/ansible/roles/docker-cleanup/files/docker-utils/dc b/ansible/roles/docker-cleanup/files/docker-utils/dc new file mode 100755 index 0000000..8a79c17 --- /dev/null +++ b/ansible/roles/docker-cleanup/files/docker-utils/dc @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -e + +exec docker-compose -f "/opt/$1/docker-compose.yml" "${@:2}" diff --git a/ansible/roles/docker-cleanup/files/docker-utils/pull-all.sh b/ansible/roles/docker-cleanup/files/docker-utils/dc-all similarity index 62% rename from ansible/roles/docker-cleanup/files/docker-utils/pull-all.sh rename to ansible/roles/docker-cleanup/files/docker-utils/dc-all index 28e90c2..78d4c68 100755 --- a/ansible/roles/docker-cleanup/files/docker-utils/pull-all.sh +++ b/ansible/roles/docker-cleanup/files/docker-utils/dc-all @@ -3,5 +3,5 @@ set -e for compose_file in /opt/**/docker-compose.yml; do - docker-compose -f $compose_file pull --parallel + docker-compose -f "$compose_file" "$@" done diff --git a/ansible/roles/docker-cleanup/files/docker-utils/hard-reset-all.sh b/ansible/roles/docker-cleanup/files/docker-utils/hard-reset-all.sh deleted file mode 100755 index 37fbbda..0000000 --- a/ansible/roles/docker-cleanup/files/docker-utils/hard-reset-all.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -set -e - -for compose_file in /opt/**/docker-compose.yml; do - if [[ $(docker-compose -f $compose_file ps -q) ]]; then - docker-compose -f $compose_file down --remove-orphans - docker-compose -f $compose_file up -d - else - echo "> Skipping $compose_file as it's not running." - fi - -done diff --git a/ansible/roles/docker-cleanup/files/docker-utils/hard-restart-all b/ansible/roles/docker-cleanup/files/docker-utils/hard-restart-all new file mode 100755 index 0000000..ebc85d7 --- /dev/null +++ b/ansible/roles/docker-cleanup/files/docker-utils/hard-restart-all @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -e + +for compose_file in /opt/**/docker-compose.yml; do + if [[ $(docker-compose -f "$compose_file" ps -q) ]]; then + docker-compose -f "$compose_file" down --remove-orphans + docker-compose -f "$compose_file" up -d + else + echo "> Skipping $compose_file as it's not running." + fi +done diff --git a/ansible/roles/docker-cleanup/files/docker-utils/occ b/ansible/roles/docker-cleanup/files/docker-utils/occ new file mode 100755 index 0000000..5ad4e32 --- /dev/null +++ b/ansible/roles/docker-cleanup/files/docker-utils/occ @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -e + +exec docker-compose -f /opt/nextcloud/docker-compose.yml exec -u abc nextcloud php /config/www/nextcloud/occ "$@" diff --git a/ansible/roles/docker-cleanup/files/docker-utils/occ.sh b/ansible/roles/docker-cleanup/files/docker-utils/occ.sh deleted file mode 100644 index 66fb2f7..0000000 --- a/ansible/roles/docker-cleanup/files/docker-utils/occ.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -e - -docker-compose -f /opt/nextcloud/docker-compose.yml exec -u abc nextcloud php /config/www/nextcloud/occ $@ diff --git a/ansible/roles/docker-cleanup/files/docker-utils/start-all.sh b/ansible/roles/docker-cleanup/files/docker-utils/start-all.sh deleted file mode 100755 index cc838b2..0000000 --- a/ansible/roles/docker-cleanup/files/docker-utils/start-all.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -set -e - -for compose_file in /opt/**/docker-compose.yml; do - if [[ ! $(docker-compose -f $compose_file ps -q) ]]; then - docker-compose -f $compose_file up -d - else - echo "> Skipping $compose_file as it's running." - fi -done diff --git a/ansible/roles/docker-cleanup/files/docker-utils/stop-all.sh b/ansible/roles/docker-cleanup/files/docker-utils/stop-all.sh deleted file mode 100755 index c3849cb..0000000 --- a/ansible/roles/docker-cleanup/files/docker-utils/stop-all.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -set -e - -for compose_file in /opt/**/docker-compose.yml; do - if [[ $(docker-compose -f $compose_file ps -q) ]]; then - docker-compose -f $compose_file down --remove-orphans - else - echo "> Skipping $compose_file as it's not running." - fi -done