1
0
Fork 0
mirror of https://github.com/overleaf/toolkit.git synced 2025-04-19 07:18:06 +02:00

Added -e for environment variables

This commit is contained in:
mserranom 2024-07-31 11:28:53 +02:00
parent 97c2a195dd
commit d4e1002674

View file

@ -18,20 +18,33 @@ fi
function usage() {
echo "Usage:
bin/run-script [SCRIPT...] [SCRIPT_ARGS..]
bin/run-script [-e 'VAR1=value VAR2=value'] [SCRIPT...] [SCRIPT_ARGS..]
bin/run-script [OPTIONS]
Options:
help prints this help
ls prints a list of all available scripts
-e space-separated list of environment variables (optional)
Examples:
bin/run-script scripts/create_project.js --user-id=649c3f45711ad101a13de737
bin/run-script -e 'PROJECT_ID=5ac1011aa13de547c3fd' scripts/delete_dangling_file_refs.js
bin/run-script ls"
}
function __main__() {
local env_vars=''
while getopts ":e:" opt
do
case $opt in
e ) env_vars="${OPTARG}" ;;
\?) usage && exit ;;
: ) usage && exit ;;
esac
done
shift $(( OPTIND -1 ))
if [[ "${1:-null}" == "null" ]] \
|| [[ "${1:-null}" == "help" ]] \
|| [[ "${1:-null}" == "--help" ]] ; then
@ -45,7 +58,8 @@ function __main__() {
exit
fi
local run_cmd="cd /overleaf/services/web; node $@"
local container_env="source /etc/overleaf/env.sh || source /etc/sharelatex/env.sh && source /etc/container_environment.sh"
local run_cmd="${container_env} && cd /overleaf/services/web && ${env_vars} node $@"
exec "$TOOLKIT_ROOT/bin/docker-compose" exec sharelatex bash -c "$run_cmd"
}