From 15165f8a4d65d7966bf1c8efc79173f3322dd372 Mon Sep 17 00:00:00 2001 From: anki-code Date: Tue, 17 Mar 2020 14:17:37 +0300 Subject: [PATCH] 0.5.12 --- entrypoint.sh | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 938d357..66e46c3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,18 +5,20 @@ # # Support three arguments (this recommend but not required): -# -f Execute file on host, print the result and exit -# -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 +# -f Execute file on host, print the result and exit +# -c [Not recommended to use] Execute command on host, print the result and exit +# -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:b: option +while getopts f:c:C:v:e:b: option do case "${option}" in f) EXECUTE_FILE=${OPTARG};; c) EXECUTE_COMMAND=${OPTARG};; +C) EXECUTE_COMMAND_B64=${OPTARG};; v) VERBOSE=${OPTARG};; e) ENV+=("$OPTARG");; b) EBASH+=("$OPTARG");; @@ -54,14 +56,25 @@ done # exit 1 #fi -## Example command argument: -#if [[ $EXECUTE_COMMAND ]]; then -# EXECUTE_COMMAND=(-c "${EXECUTE_COMMAND}") -#fi -# -#if [[ $EXECUTE_FILE ]]; then -# EXECUTE_COMMAND="" -#fi +## Example command: +if [[ $EXECUTE_COMMAND ]]; then + EXECUTE_COMMAND=(-c "${EXECUTE_COMMAND}") +fi + +if [[ $EXECUTE_COMMAND_B64 ]]; then + EXECUTE_COMMAND=`echo $EXECUTE_COMMAND_B64 | base64 -d` + if [[ $XXH_VERBOSE == '1' || $XXH_VERBOSE == '2' ]]; then + echo Execute command base64: $EXECUTE_COMMAND_B64 + echo Execute command: $EXECUTE_COMMAND + fi + + EXECUTE_COMMAND=(-c "${EXECUTE_COMMAND}") +fi + + +if [[ $EXECUTE_FILE ]]; then + EXECUTE_COMMAND="" +fi ## Example of adding argument `-f` before #EXECUTE_FILE=`[ $EXECUTE_FILE ] && echo -n "-f $EXECUTE_FILE" || echo -n ""`