From 64f10c135037bdc8b3b640f2841870a45788b94c Mon Sep 17 00:00:00 2001 From: fabian Date: Sun, 26 Feb 2023 20:45:39 +0100 Subject: [PATCH] unified and reworked docker container actions --- scripts/dockerContainerAction.sh | 22 ++++++++++++++++++++++ scripts/downContainers.sh | 18 +++--------------- scripts/upContainers.sh | 22 +++------------------- 3 files changed, 28 insertions(+), 34 deletions(-) create mode 100644 scripts/dockerContainerAction.sh diff --git a/scripts/dockerContainerAction.sh b/scripts/dockerContainerAction.sh new file mode 100644 index 0000000..fbfa78a --- /dev/null +++ b/scripts/dockerContainerAction.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -euo pipefail + +upDownContainers() { + # evaluate options through given arguments + docker_root=~/docker; + while [[ $# > 0 ]]; do + case $1 in + -d | --dir) docker_root=$2; shift 2;; + * ) break ;; # Anything else stops command line processing. + esac + done + + for subdir in $docker_root/*; do + if [[ !(-d $subdir) ]]; then + continue; + fi + cd $subdir; + docker-compose $@; + done +} + diff --git a/scripts/downContainers.sh b/scripts/downContainers.sh index e1ccfcc..3e9875d 100755 --- a/scripts/downContainers.sh +++ b/scripts/downContainers.sh @@ -1,19 +1,7 @@ #!/usr/bin/env bash set -euo pipefail -if [[ $# > 0 ]]; then - DOCKER_ROOT=$1; -else - DOCKER_ROOT=$(pwd); -fi -# echo $DOCKER_ROOT; +source ./dockerContainerAction.sh -for subdir in $DOCKER_ROOT/*; do - if [[ !(-d $subdir) || ${subdir##*/} == "matrix_synapse" || ${subdir##*/} == "pydio_cells" || ${subdir##*/} == "mattermost" ]]; then - continue; - fi - # echo $subdir; - cd $subdir; - # echo $(pwd); - docker-compose down; -done +# FIXME!!! implement possibility to pass down directory +upDownContainers down diff --git a/scripts/upContainers.sh b/scripts/upContainers.sh index b709db8..b4862e4 100755 --- a/scripts/upContainers.sh +++ b/scripts/upContainers.sh @@ -1,23 +1,7 @@ #!/usr/bin/env bash set -euo pipefail -# evaluate options through given arguments -docker_root= -while [[ $# > 0 ]]; do - case $1 in - -d | --dir) docker_root=$2; shift 2;; - * ) break ;; # Anything else stops command line processing. - esac -done +source ./dockerContainerAction.sh -if [[ -z $docker_root ]]; then - docker_root=~/docker; -fi - -for subdir in $docker_root/*; do - if [[ !(-d $subdir) ]]; then - continue; - fi - cd $subdir; - docker-compose up -d; -done +# FIXME!!! implement possibility to pass down directory +upDownContainers up -d