-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker-entrypoint.sh
executable file
·79 lines (66 loc) · 2 KB
/
docker-entrypoint.sh
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
set -exuo pipefail
bin_path="/usr/local/bin"
prep_next_arg(){
tmp_str=''
export tmp_str
}
append_str(){
tmp_str="${tmp_str} + ${1}"
export tmp_str
}
parse(){
# this function is to parse bashfuscation arguments, because docker
# doesn't allow quotes from being passed through unless it is env variables
# which would dissrupt the flow of this application too much instead
# of treating it like how it supposed to do and keep appending
# TODO: Implement reading from stdin
# body: Need to work on trying to check for the parser function if input
# can be read from stdin from a docker container, I am thinking yes if
# someone does `-- <(file_path)` at the end of running a container, but
# need to validate this later down the road.
# TODO: use bind mount to access file
# body: use the `-v` option to bind mount a file to be allowed to be read
# by bashfuscator, so that way the file can be accessed from within the
# docker container. Throw error if not mounted
parsed_string=()
tmp_str=''
oldIFS="${IFS}"
IFS=' '
for given_string in "${@}" ; do
# first argument getting passed to bashfuscator is a flag indicating what
# you want to invoke the obfuscation on (i.e. enter in a command (-c) in
# from a file (-f), list this options (-l)
case "${given_string}" in
-c)
if [[ -z "${tmp_str}" ]] ; then
parsed_string+=("${given_string}")
else
append_str "${given_string}"
fi
esac
done
IFS="${oldIFS}"
export parsed_string
}
main(){
case "$1" in
bashrc)
/usr/local/bin/register-python-argcomplete bashfuscator
;;
--help)
"${bin_path}/bashfuscator" "$@"
# printf "If you want to be able to copy this to your clipboard append the following to normal execution: "
# printf "-"
;;
bash)
"${bin_path}/bashfuscator" "$@"
;;
*)
echo "${@}"
parse "${@}"
# "${bin_path}/bashfuscator" "$@"
;;
esac
}
main "${@}"