advanced scripting capability

This commit is contained in:
Michael Bradley, Jr 2018-08-01 21:32:47 -05:00
parent 0288f14b21
commit 00add9f6cc
1 changed files with 32 additions and 5 deletions

37
run.sh
View File

@ -68,13 +68,40 @@ run_embark () {
fi fi
fi fi
local -a cmd=( "$@" )
local -a extra_run_opts=( $EMBARK_DOCKER_EXTRA_RUN_OPTS ) local -a extra_run_opts=( $EMBARK_DOCKER_EXTRA_RUN_OPTS )
local -a cmd=( "$@" ) if [[ -z "$EMBARK_DOCKER_RUN" ]]; then
case $1 in case $1 in
-V|--version|-h|--help|new|demo|build|run|blockchain|simulator|test|\ -V|--version|-h|--help|new|demo|build|run|blockchain|simulator|test|\
reset|graph|upload|version) cmd=( "embark" "$cmd" ) ;; reset|graph|upload|version) cmd=( "embark" "$cmd" ) ;;
esac esac
else
local i_flag=
if [[ $EMBARK_DOCKER_RUN_INTERACTIVE = true ]]; then
i_flag='i'
else
i_flag=''
fi
local run_script=$(< "$EMBARK_DOCKER_RUN")
# do not remove empty lines below
# do not add indentation to lines below
run_script="exec bash -s $@ << 'SCRIPT'
td=\$(mktemp -d)
cat << 'RUN' > \$td/run_script
$run_script
RUN
chmod +x \$td/run_script
exec \$td/run_script $@
SCRIPT
"
# do not remove empty lines above
# do not add indentation to lines above
cmd=( "bash" "-${i_flag}c" "$run_script" )
fi
docker run \ docker run \
-it \ -it \