From 890778d33ad275cf8dabc2b0e18c004ed2b46f8f Mon Sep 17 00:00:00 2001 From: merith-xyz Date: Fri, 27 Sep 2024 11:08:56 -0700 Subject: [PATCH] resolve tag Kind/Breaks Docker treats "command" as an agument to an entrypoint if it exists, now the entrypoint runs arguments as if they were a command --- entrypoint.sh | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index db9291f..712227e 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -8,7 +8,7 @@ run_command() { # Replace any --token or --secret with [REDACTED] local safe_cmd=$(echo "$cmd" | sed -E 's/--(token|secret) [^ ]+/--\1 [REDACTED]/g') decho "Running command: $safe_cmd" - eval "$cmd" + eval $cmd } decho() { @@ -16,6 +16,7 @@ decho() { echo "[entrypoint] $@" fi } +decho $PWD # Check if the script is running as root if [[ $(id -u) -eq 0 ]]; then @@ -25,7 +26,7 @@ fi # Handle if `command` is passed, as command appends arguments to the entrypoint if [ "$#" -gt 0 ]; then - run_command "$@" + run_command $@ exit fi @@ -97,20 +98,20 @@ if [[ ! -s "${RUNNER_FILE}" ]]; then # this is more flexible. while [[ $success -eq 0 ]] && [[ $try -lt ${MAX_REG_ATTEMPTS:-10} ]]; do if [[ ! -z "${FORGEJO_SECRET}" ]]; then - run_command "forgejo-runner create-runner-file --connect \ - --instance \"${FORGEJO_URL:-http://forgejo:3000}\" \ - --name \"${RUNNER_NAME:-$(hostname)}\" \ - --secret \"${FORGEJO_SECRET}\" \ + run_command forgejo-runner create-runner-file --connect \ + --instance "${FORGEJO_URL:-http://forgejo:3000}" \ + --name "${RUNNER_NAME:-$(hostname)}" \ + --secret "${FORGEJO_SECRET}" \ ${CONFIG_ARG}\ - ${EXTRA_ARGS} 2>&1 | tee /tmp/reg.log" + ${EXTRA_ARGS} 2>&1 | tee /tmp/reg.log else - run_command "forgejo-runner register \ - --instance \"${FORGEJO_URL:-http://forgejo:3000}\" \ - --name \"${RUNNER_NAME:-$(hostname)}\" \ - --token \"${RUNNER_TOKEN}\" \ + run_command forgejo-runner register \ + --instance "${FORGEJO_URL:-http://forgejo:3000}" \ + --name "${RUNNER_NAME:-$(hostname)}" \ + --token "${RUNNER_TOKEN}" \ --no-interactive \ ${CONFIG_ARG}\ - ${EXTRA_ARGS} 2>&1 | tee /tmp/reg.log" + ${EXTRA_ARGS} 2>&1 | tee /tmp/reg.log fi cat /tmp/reg.log | grep -E 'connection successful|registered successfully' >/dev/null if [[ $? -eq 0 ]]; then @@ -128,4 +129,4 @@ fi unset RUNNER_TOKEN unset FORGEJO_SECRET -run_command "forgejo-runner daemon ${CONFIG_ARG}" +run_command forgejo-runner daemon ${CONFIG_ARG}