Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions commands/_internals/yq.sh
Original file line number Diff line number Diff line change
@@ -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 "$@" -
}
2 changes: 1 addition & 1 deletion commands/project/exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions commands/project/exec/root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion commands/project/fix-permissions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions commands/project/open.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion commands/project/shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion commands/project/shell/root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions commands/system/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
3 changes: 2 additions & 1 deletion commands/system/dde/install.sh
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion commands/system/dde/install/alias.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function system:dde:install:alias() {
fi

if [[ "${_rcFile}" == "" ]]; then
_logRed "unkown shell ${SHELL}"
_logRed "unknown shell ${SHELL}"
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion commands/system/dde/install/autocomplete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function system:dde:install:autocomplete() {
fi

if [[ "${_rcFile}" == "" ]]; then
_logRed "unkown shell ${SHELL}"
_logRed "unknown shell ${SHELL}"
exit 1
fi

Expand Down