diff --git a/commands/_internals/yq.sh b/commands/_internals/yq.sh index 65a5bce..5210ff5 100644 --- a/commands/_internals/yq.sh +++ b/commands/_internals/yq.sh @@ -1,7 +1,7 @@ _yq() { - ${DOCKER_BIN} run --rm -i -v "${PWD}":/workdir mikefarah/yq "$@" + ${DOCKER_BIN} run --rm -i -v "${PWD}":/workdir mikefarah/yq:4 "$@" } _yq_stdin() { - ${DOCKER_BIN} run --rm -i -v "${PWD}":/workdir mikefarah/yq "$@" - + ${DOCKER_BIN} run --rm -i -v "${PWD}":/workdir mikefarah/yq:4 "$@" - } diff --git a/commands/project/exec.sh b/commands/project/exec.sh index de22ba5..f2a2129 100755 --- a/commands/project/exec.sh +++ b/commands/project/exec.sh @@ -13,7 +13,7 @@ function project:exec() { _checkProject # Determine the first service from composer file - service=$(${DOCKER_BIN} run --rm -v $(pwd):/workdir mikefarah/yq:3 yq r --printMode p ${COMPOSE_FILE} 'services.*' | head -n1 | sed 's/.*\.//') + service="$(${DOCKER_COMPOSE} config | _yq_stdin e '.services | keys | .[0]')" # Check if the provided service exists if _serviceExists "${1}"; then diff --git a/commands/project/exec/root.sh b/commands/project/exec/root.sh index 5e5dc2a..07da591 100644 --- a/commands/project/exec/root.sh +++ b/commands/project/exec/root.sh @@ -2,18 +2,18 @@ # # # Command -# project:exec -# p:e -# exec +# project:exec:root +# p:e:r +# exec-root # Arguments # service optional, open shell of service, default open first container -function project:exec() { +function project:exec:root() { _logYellow "Please note that the command exec has been renamed to 'shell' in the script." _checkProject # Determine the first service from composer file - service=$(${DOCKER_BIN} run --rm -v $(pwd):/workdir mikefarah/yq:3 yq r --printMode p ${COMPOSE_FILE} 'services.*' | head -n1 | sed 's/.*\.//') + service="$(${DOCKER_COMPOSE} config | _yq_stdin e '.services | keys | .[0]')" # Check if the provided service exists if _serviceExists "${1}"; then diff --git a/commands/project/fix-permissions.sh b/commands/project/fix-permissions.sh index f6f8d01..6fa185b 100644 --- a/commands/project/fix-permissions.sh +++ b/commands/project/fix-permissions.sh @@ -14,7 +14,8 @@ function project:fix-permissions() { _checkProject - local container=$(${DOCKER_BIN} run --rm -v $(pwd):/workdir mikefarah/yq:3 yq r --printMode p ${COMPOSE_FILE} 'services.*' | head -n1 | sed 's/.*\.//') + local container + container="$(${DOCKER_COMPOSE} config | _yq_stdin e '.services | keys | .[0]')" local permission="dde:dde" local path="/var/www" local user=$(id -u) diff --git a/commands/project/open.sh b/commands/project/open.sh index 17f2d45..e408124 100644 --- a/commands/project/open.sh +++ b/commands/project/open.sh @@ -13,13 +13,12 @@ function project:open() { for openUrl in $(${DOCKER_COMPOSE} config | _yq_stdin e '.services.*.environment.OPEN_URL | select(length>0)'); do _logGreen "open ${openUrl}" - echo "DDE_BROWSER ${DDE_BROWSER}" if [[ "${DDE_BROWSER}" != "" ]]; then ${DDE_BROWSER} "${openUrl}" & elif [[ "${OSTYPE}" == "linux-gnu" ]]; then xdg-open "${openUrl}" elif [[ "${OSTYPE}" == "darwin" ]]; then - open "${openUrl}" + command open "${openUrl}" fi done } diff --git a/commands/project/shell.sh b/commands/project/shell.sh index 9b277c3..b4ee93f 100755 --- a/commands/project/shell.sh +++ b/commands/project/shell.sh @@ -10,7 +10,8 @@ function project:shell() { _checkProject _loadProjectDotdde - local service=$(${DOCKER_BIN} run --rm -v $(pwd):/workdir mikefarah/yq:3 yq r --printMode p ${COMPOSE_FILE} 'services.*' | head -n1 | sed 's/.*\.//') + local service + service="$(${DOCKER_COMPOSE} config | _yq_stdin e '.services | keys | .[0]')" if [[ "${1}" != "" ]]; then if _serviceExists ${1}; then diff --git a/commands/project/shell/root.sh b/commands/project/shell/root.sh index 07623e5..15b03c6 100755 --- a/commands/project/shell/root.sh +++ b/commands/project/shell/root.sh @@ -8,7 +8,8 @@ function project:shell:root() { _checkProject _loadProjectDotdde - local service=$(${DOCKER_BIN} run --rm -v $(pwd):/workdir mikefarah/yq:3 yq r --printMode p ${COMPOSE_FILE} 'services.*' | head -n1 | sed 's/.*\.//') + local service + service="$(${DOCKER_COMPOSE} config | _yq_stdin e '.services | keys | .[0]')" if [[ "${1}" != "" ]]; then if _serviceExists ${1}; then diff --git a/commands/system/cleanup.sh b/commands/system/cleanup.sh index fe41fc5..a76ba28 100755 --- a/commands/system/cleanup.sh +++ b/commands/system/cleanup.sh @@ -6,11 +6,15 @@ function system:cleanup() { - _logYellow "Running docker-gc" - ${DOCKER_BIN} run --rm -v /var/run/docker.sock:/var/run/docker.sock -e REMOVE_VOLUMES=1 spotify/docker-gc sh -c "/docker-gc || true" + _logYellow "Pruning unused docker resources" + ${DOCKER_BIN} system prune -f --volumes - _logYellow "Shrinking down docker data" - ${DOCKER_BIN} run --rm -it --privileged --pid=host walkerlee/nsenter -t 1 -m -u -i -n fstrim /var/lib/docker + if [[ "$(uname)" == "Linux" ]]; then + _logYellow "Shrinking down docker data" + ${DOCKER_BIN} run --rm -it --privileged --pid=host walkerlee/nsenter -t 1 -m -u -i -n fstrim /var/lib/docker + else + _logYellow "Skipping fstrim (Linux only)" + fi _logGreen "Finished system cleanup" } diff --git a/commands/system/dde/install.sh b/commands/system/dde/install.sh index b094814..7a49d96 100755 --- a/commands/system/dde/install.sh +++ b/commands/system/dde/install.sh @@ -1,5 +1,6 @@ -## makes the setup for your shell +## installs the dde alias and autocomplete into your shell rc file function system:dde:install() { system:dde:install:alias + system:dde:install:autocomplete } diff --git a/commands/system/dde/install/alias.sh b/commands/system/dde/install/alias.sh index 8f2f1d5..ace7f23 100755 --- a/commands/system/dde/install/alias.sh +++ b/commands/system/dde/install/alias.sh @@ -12,7 +12,7 @@ function system:dde:install:alias() { fi if [[ "${_rcFile}" == "" ]]; then - _logRed "unkown shell ${SHELL}" + _logRed "unknown shell ${SHELL}" exit 1 fi diff --git a/commands/system/dde/install/autocomplete.sh b/commands/system/dde/install/autocomplete.sh index 123b27d..3e5af6e 100755 --- a/commands/system/dde/install/autocomplete.sh +++ b/commands/system/dde/install/autocomplete.sh @@ -12,7 +12,7 @@ function system:dde:install:autocomplete() { fi if [[ "${_rcFile}" == "" ]]; then - _logRed "unkown shell ${SHELL}" + _logRed "unknown shell ${SHELL}" exit 1 fi