-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.exec.cunt.sh
More file actions
executable file
·45 lines (34 loc) · 1.02 KB
/
script.exec.cunt.sh
File metadata and controls
executable file
·45 lines (34 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
set -eu
######################## INTERFACE
DOCS_URI='https://github.com/nirv-ai/docs/tree/main/scripts'
SCRIPTS_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]%/}")" &>/dev/null && pwd)"
SCRIPTS_DIR_PARENT="$(dirname $SCRIPTS_DIR)"
######################## UTILS
for util in $SCRIPTS_DIR/utils/*.sh; do
source $util
done
######################## FNS
exec_into_container() {
cunt_id=$(get_cunt_id $1)
if test -z "$cunt_id"; then
echo_err "\ncouldnt find container with name $1 or ${CUNT_PREFIX}${1}"
exit 1
fi
local exec_args='-it'
local as_user=${2:-''}
if ! test -z $as_user; then
exec_args="$exec_args -u $as_user"
fi
local args="\n$1: $cunt_id\nargs: $exec_args"
echo_debug "trying to exec with bash\n$args"
if ! docker exec $exec_args "$cunt_id" bash; then
echo
echo_debug "trying to exec with sh\n$args"
docker exec $exec_args "$cunt_id" sh
fi
}
cunt_name=${1:?'container name is required'}
case $cunt_name in
*) exec_into_container ${cunt_name} ${2:-''} ;;
esac