From f9c65d780697e23a8e5b55cb49d550ebd46a01ac Mon Sep 17 00:00:00 2001 From: anki-code Date: Sun, 15 Mar 2020 17:24:53 +0300 Subject: [PATCH] 0.5.11 --- entrypoint.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 1e4d694..938d357 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -9,8 +9,9 @@ # -c Execute command on host, print the result and exit # -v Verbose mode: 1 - verbose, 2 - super verbose # -e -e ... Environement variables (B64 is base64 encoded string) +# -b -b ... Base64 encoded bash command # -while getopts f:c:v:e: option +while getopts f:c:v:e:b: option do case "${option}" in @@ -18,6 +19,7 @@ f) EXECUTE_FILE=${OPTARG};; c) EXECUTE_COMMAND=${OPTARG};; v) VERBOSE=${OPTARG};; e) ENV+=("$OPTARG");; +b) EBASH+=("$OPTARG");; esac done @@ -30,13 +32,22 @@ for env in "${ENV[@]}"; do val="$( cut -d '=' -f 2- <<< "$env" )"; val=`echo $val | base64 -d` - if [[ $XXH_VERBOSE == '1' ]]; then + if [[ $XXH_VERBOSE == '1' || $XXH_VERBOSE == '2' ]]; then echo Environment variable "$env": name=$name, value=$val fi export $name="$val" done +for eb in "${EBASH[@]}"; do + bash_command=`echo $eb | base64 -d` + + if [[ $XXH_VERBOSE == '1' || $XXH_VERBOSE == '2' ]]; then + echo Entrypoint bash execute: $bash_command + fi + eval $bash_command +done + ## Example disabling option: #if [[ $EXECUTE_COMMAND ]]; then # echo ' entrypoint is not support command execution.' @@ -71,4 +82,4 @@ export XXH_HOME=`realpath -m $CURRENT_DIR/../../../../` ./your_portable_shell # Example: -# ./your_portable_shell $EXECUTE_FILE "${EXECUTE_COMMAND[@]}" \ No newline at end of file +# ./your_portable_shell $EXECUTE_FILE "${EXECUTE_COMMAND[@]}"