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
This commit is contained in:
parent
95fb2cafff
commit
890778d33a
1 changed files with 14 additions and 13 deletions
|
@ -8,7 +8,7 @@ run_command() {
|
||||||
# Replace any --token <value> or --secret <value> with [REDACTED]
|
# Replace any --token <value> or --secret <value> with [REDACTED]
|
||||||
local safe_cmd=$(echo "$cmd" | sed -E 's/--(token|secret) [^ ]+/--\1 [REDACTED]/g')
|
local safe_cmd=$(echo "$cmd" | sed -E 's/--(token|secret) [^ ]+/--\1 [REDACTED]/g')
|
||||||
decho "Running command: $safe_cmd"
|
decho "Running command: $safe_cmd"
|
||||||
eval "$cmd"
|
eval $cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
decho() {
|
decho() {
|
||||||
|
@ -16,6 +16,7 @@ decho() {
|
||||||
echo "[entrypoint] $@"
|
echo "[entrypoint] $@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
decho $PWD
|
||||||
|
|
||||||
# Check if the script is running as root
|
# Check if the script is running as root
|
||||||
if [[ $(id -u) -eq 0 ]]; then
|
if [[ $(id -u) -eq 0 ]]; then
|
||||||
|
@ -25,7 +26,7 @@ fi
|
||||||
|
|
||||||
# Handle if `command` is passed, as command appends arguments to the entrypoint
|
# Handle if `command` is passed, as command appends arguments to the entrypoint
|
||||||
if [ "$#" -gt 0 ]; then
|
if [ "$#" -gt 0 ]; then
|
||||||
run_command "$@"
|
run_command $@
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -97,20 +98,20 @@ if [[ ! -s "${RUNNER_FILE}" ]]; then
|
||||||
# this is more flexible.
|
# this is more flexible.
|
||||||
while [[ $success -eq 0 ]] && [[ $try -lt ${MAX_REG_ATTEMPTS:-10} ]]; do
|
while [[ $success -eq 0 ]] && [[ $try -lt ${MAX_REG_ATTEMPTS:-10} ]]; do
|
||||||
if [[ ! -z "${FORGEJO_SECRET}" ]]; then
|
if [[ ! -z "${FORGEJO_SECRET}" ]]; then
|
||||||
run_command "forgejo-runner create-runner-file --connect \
|
run_command forgejo-runner create-runner-file --connect \
|
||||||
--instance \"${FORGEJO_URL:-http://forgejo:3000}\" \
|
--instance "${FORGEJO_URL:-http://forgejo:3000}" \
|
||||||
--name \"${RUNNER_NAME:-$(hostname)}\" \
|
--name "${RUNNER_NAME:-$(hostname)}" \
|
||||||
--secret \"${FORGEJO_SECRET}\" \
|
--secret "${FORGEJO_SECRET}" \
|
||||||
${CONFIG_ARG}\
|
${CONFIG_ARG}\
|
||||||
${EXTRA_ARGS} 2>&1 | tee /tmp/reg.log"
|
${EXTRA_ARGS} 2>&1 | tee /tmp/reg.log
|
||||||
else
|
else
|
||||||
run_command "forgejo-runner register \
|
run_command forgejo-runner register \
|
||||||
--instance \"${FORGEJO_URL:-http://forgejo:3000}\" \
|
--instance "${FORGEJO_URL:-http://forgejo:3000}" \
|
||||||
--name \"${RUNNER_NAME:-$(hostname)}\" \
|
--name "${RUNNER_NAME:-$(hostname)}" \
|
||||||
--token \"${RUNNER_TOKEN}\" \
|
--token "${RUNNER_TOKEN}" \
|
||||||
--no-interactive \
|
--no-interactive \
|
||||||
${CONFIG_ARG}\
|
${CONFIG_ARG}\
|
||||||
${EXTRA_ARGS} 2>&1 | tee /tmp/reg.log"
|
${EXTRA_ARGS} 2>&1 | tee /tmp/reg.log
|
||||||
fi
|
fi
|
||||||
cat /tmp/reg.log | grep -E 'connection successful|registered successfully' >/dev/null
|
cat /tmp/reg.log | grep -E 'connection successful|registered successfully' >/dev/null
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
|
@ -128,4 +129,4 @@ fi
|
||||||
unset RUNNER_TOKEN
|
unset RUNNER_TOKEN
|
||||||
unset FORGEJO_SECRET
|
unset FORGEJO_SECRET
|
||||||
|
|
||||||
run_command "forgejo-runner daemon ${CONFIG_ARG}"
|
run_command forgejo-runner daemon ${CONFIG_ARG}
|
||||||
|
|
Loading…
Reference in a new issue