-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cbf1a84
commit ac5ebb0
Showing
4 changed files
with
75 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
## Opens shell with user dde on first container | ||
# | ||
# Command | ||
# project:shell | ||
# p:s | ||
# shell | ||
|
||
# Arguments | ||
# service optional, open shell of service, default open first container | ||
function project:shell() { | ||
_checkProject | ||
local service=$(docker run --rm -v $(pwd):/workdir mikefarah/yq:3 yq r --printMode p docker-compose.yml 'services.*' | head -n1 | sed 's/.*\.//') | ||
|
||
if [[ "${1}" != "" ]]; then | ||
if _serviceExists ${1}; then | ||
service=${1} | ||
else | ||
_logRed "service ${1} does not exists in project" | ||
_existingServices | ||
return 1 | ||
fi | ||
fi | ||
|
||
if ! _serviceIsRunning ${service}; then | ||
_logYellow "Project is not running. Starting ..." | ||
project:up | ||
fi | ||
|
||
${DOCKER_COMPOSE} exec ${service} /bin/sh -c "if [ -f /usr/bin/doas ]; then doas -u dde sh; else gosu dde sh; fi" | ||
} | ||
|
||
function p:s() { | ||
project:shell ${1} | ||
} | ||
|
||
function shell() { | ||
project:shell ${1} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
## Opens privileged shell on first container | ||
# | ||
# Command | ||
# project:shell:root | ||
# s:e:r | ||
# shell-root | ||
|
||
function project:shell:root() { | ||
_checkProject | ||
local service=$(docker run --rm -v $(pwd):/workdir mikefarah/yq:3 yq r --printMode p docker-compose.yml 'services.*' | head -n1 | sed 's/.*\.//') | ||
|
||
if [[ "${1}" != "" ]]; then | ||
if _serviceExists ${1}; then | ||
service=${1} | ||
else | ||
_logRed "service ${1} does not exists in project" | ||
_existingServices | ||
return 1 | ||
fi | ||
fi | ||
|
||
if ! _serviceIsRunning ${service}; then | ||
_logYellow "Project is not running. Starting ..." | ||
project:up | ||
fi | ||
|
||
${DOCKER_COMPOSE} exec ${service} /bin/sh -c "sh" | ||
} | ||
|
||
function p:e:r() { | ||
project:shell:root | ||
} | ||
|
||
function shell-root() { | ||
project:shell:root | ||
} |