mirror of
https://github.com/casjaysdevdocker/gitea
synced 2026-08-14 14:01:17 -04:00
🐛 Add version stamp and grep -- guards in zz-act_runner.sh 🐛
Added `VERSION="202608031200-git"` matching the existing `##@Version` header, and added `--` before the pattern argument on all 15 grep invocations in the file (the header/version mismatch and several of the missing `--` guards were flagged by the `script-lint` agent; completeness check found the pattern repeated across the whole file, not just the originally-flagged subset). Also quoted the previously bare `grep` pattern at the former line 544 (`grep -v grep` -> `grep -v -- 'grep'`). - rootfs/usr/local/etc/docker/init.d/zz-act_runner.sh: version stamp + grep -- fixes - TODO.AI.md: marked this finding fixed
This commit is contained in:
@@ -8,6 +8,15 @@ Verified clean by `script-lint` agent after fix.
|
|||||||
`[[ "$SERVER_ADDRESS" != *"://"* ]]`; grep call removed entirely so the missing `--` no longer
|
`[[ "$SERVER_ADDRESS" != *"://"* ]]`; grep call removed entirely so the missing `--` no longer
|
||||||
applies.
|
applies.
|
||||||
|
|
||||||
|
## Lint cleanup done — version stamp and grep -- fixed (zz-act_runner.sh)
|
||||||
|
|
||||||
|
Verified clean by `script-lint` agent after fix.
|
||||||
|
|
||||||
|
- `rootfs/usr/local/etc/docker/init.d/zz-act_runner.sh`: added `VERSION="202608031200-git"`
|
||||||
|
matching the existing `##@Version` header; added `--` before the pattern argument on all 15 grep
|
||||||
|
invocations in the file (not just the subset originally enumerated); quoted the bare `grep`
|
||||||
|
pattern at the former line 544 (now `grep -v -- 'grep'`).
|
||||||
|
|
||||||
## New lint finding — line-length violation (start-runners)
|
## New lint finding — line-length violation (start-runners)
|
||||||
|
|
||||||
Found by `script-lint` while verifying the fixes above; unrelated to those fixes, not yet actioned.
|
Found by `script-lint` while verifying the fixes above; unrelated to those fixes, not yet actioned.
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
|
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
VERSION="202608031200-git"
|
||||||
set -e
|
set -e
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# run trap command on exit
|
# run trap command on exit
|
||||||
@@ -121,17 +122,17 @@ __gen_auth_token() {
|
|||||||
token_dir="$CONF_DIR/tokens"
|
token_dir="$CONF_DIR/tokens"
|
||||||
gitea_bin="$(command -v gitea)"
|
gitea_bin="$(command -v gitea)"
|
||||||
mkdir -p "$token_dir" >/dev/null 2>&1
|
mkdir -p "$token_dir" >/dev/null 2>&1
|
||||||
conf_file="$(find "/config" "/etc" -type f -name '*.ini' 2>/dev/null | grep -E 'git/app.ini|gitea/app.ini|gitea.ini' | head -n1 | grep '^')"
|
conf_file="$(find "/config" "/etc" -type f -name '*.ini' 2>/dev/null | grep -E -- 'git/app.ini|gitea/app.ini|gitea.ini' | head -n1 | grep -- '^')"
|
||||||
if [ -n "$SYS_AUTH_TOKEN" ]; then
|
if [ -n "$SYS_AUTH_TOKEN" ]; then
|
||||||
auth_token="$SYS_AUTH_TOKEN"
|
auth_token="$SYS_AUTH_TOKEN"
|
||||||
elif [ -s "$CONF_DIR/tokens/system" ]; then
|
elif [ -s "$CONF_DIR/tokens/system" ]; then
|
||||||
auth_token="$(<"$CONF_DIR/tokens/system")"
|
auth_token="$(<"$CONF_DIR/tokens/system")"
|
||||||
fi
|
fi
|
||||||
auth_token="$(echo "$auth_token" | grep -vE '# |^$')"
|
auth_token="$(echo "$auth_token" | grep -vE -- '# |^$')"
|
||||||
if [ -z "$auth_token" ] && [ -n "$gitea_bin" ] && [ -n "$conf_file" ]; then
|
if [ -z "$auth_token" ] && [ -n "$gitea_bin" ] && [ -n "$conf_file" ]; then
|
||||||
# Only attempt token generation if gitea is fully installed (INSTALL_LOCK = true)
|
# Only attempt token generation if gitea is fully installed (INSTALL_LOCK = true)
|
||||||
if grep -qiE 'INSTALL_LOCK\s*=\s*true' "$conf_file" 2>/dev/null; then
|
if grep -qiE -- 'INSTALL_LOCK\s*=\s*true' "$conf_file" 2>/dev/null; then
|
||||||
auth_token="$(gosu $user $gitea_bin --config "$conf_file" --work-path /data/gitea --custom-path /config/gitea/custom actions generate-runner-token 2>/dev/null | grep -oE '[A-Za-z0-9]{20,}' | tail -n1)"
|
auth_token="$(gosu $user $gitea_bin --config "$conf_file" --work-path /data/gitea --custom-path /config/gitea/custom actions generate-runner-token 2>/dev/null | grep -oE -- '[A-Za-z0-9]{20,}' | tail -n1)"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -n "$auth_token" ]; then
|
if [ -n "$auth_token" ]; then
|
||||||
@@ -366,7 +367,7 @@ __run_precopy() {
|
|||||||
ln -sf "$CONF_DIR" "$ETC_DIR"
|
ln -sf "$CONF_DIR" "$ETC_DIR"
|
||||||
fi
|
fi
|
||||||
# allow custom functions
|
# allow custom functions
|
||||||
if builtin type -t __run_precopy_local | grep -q 'function'; then __run_precopy_local; fi
|
if builtin type -t __run_precopy_local | grep -q -- 'function'; then __run_precopy_local; fi
|
||||||
}
|
}
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Custom prerun functions - IE setup WWW_ROOT_DIR
|
# Custom prerun functions - IE setup WWW_ROOT_DIR
|
||||||
@@ -387,7 +388,7 @@ __execute_prerun() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
# allow custom functions
|
# allow custom functions
|
||||||
if builtin type -t __execute_prerun_local | grep -q 'function'; then __execute_prerun_local; fi
|
if builtin type -t __execute_prerun_local | grep -q -- 'function'; then __execute_prerun_local; fi
|
||||||
}
|
}
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
# Run any pre-execution checks
|
# Run any pre-execution checks
|
||||||
@@ -435,7 +436,7 @@ __run_pre_execute_checks() {
|
|||||||
__script_exit 1
|
__script_exit 1
|
||||||
fi
|
fi
|
||||||
# allow custom functions
|
# allow custom functions
|
||||||
if builtin type -t __run_pre_execute_checks_local | grep -q 'function'; then __run_pre_execute_checks_local; fi
|
if builtin type -t __run_pre_execute_checks_local | grep -q -- 'function'; then __run_pre_execute_checks_local; fi
|
||||||
# exit function
|
# exit function
|
||||||
return $exitStatus
|
return $exitStatus
|
||||||
}
|
}
|
||||||
@@ -465,7 +466,7 @@ __update_conf_files() {
|
|||||||
# Mark config as fully initialised so __run_precopy skips re-seeding on restart
|
# Mark config as fully initialised so __run_precopy skips re-seeding on restart
|
||||||
touch "$CONF_DIR/.initialized" 2>/dev/null || true
|
touch "$CONF_DIR/.initialized" 2>/dev/null || true
|
||||||
# allow custom functions
|
# allow custom functions
|
||||||
if builtin type -t __update_conf_files_local | grep -q 'function'; then __update_conf_files_local; fi
|
if builtin type -t __update_conf_files_local | grep -q -- 'function'; then __update_conf_files_local; fi
|
||||||
# exit function
|
# exit function
|
||||||
return $exitCode
|
return $exitCode
|
||||||
}
|
}
|
||||||
@@ -487,7 +488,7 @@ __pre_execute() {
|
|||||||
# Lets wait a few seconds before continuing
|
# Lets wait a few seconds before continuing
|
||||||
sleep 2
|
sleep 2
|
||||||
# allow custom functions
|
# allow custom functions
|
||||||
if builtin type -t __pre_execute_local | grep -q 'function'; then __pre_execute_local; fi
|
if builtin type -t __pre_execute_local | grep -q -- 'function'; then __pre_execute_local; fi
|
||||||
# exit function
|
# exit function
|
||||||
return $exitCode
|
return $exitCode
|
||||||
}
|
}
|
||||||
@@ -522,7 +523,7 @@ __post_execute() {
|
|||||||
act_runner daemon --config "$RUNNER_DEFAULT_HOME/$RUNNER_CONFIG_NAME" >>"$RUNNER_DAEMON_LOG" 2>/dev/stderr &
|
act_runner daemon --config "$RUNNER_DEFAULT_HOME/$RUNNER_CONFIG_NAME" >>"$RUNNER_DAEMON_LOG" 2>/dev/stderr &
|
||||||
pid=$!
|
pid=$!
|
||||||
sleep 5
|
sleep 5
|
||||||
if ps ax | awk '{print $1}' | grep -v 'grep' | grep -q "$pid$"; then
|
if ps ax | awk '{print $1}' | grep -v -- 'grep' | grep -q -- "$pid$"; then
|
||||||
echo "$(date)" >"$CONF_DIR/.runner"
|
echo "$(date)" >"$CONF_DIR/.runner"
|
||||||
echo "$pid" >"$RUN_DIR/act_runner.gitea.pid"
|
echo "$pid" >"$RUN_DIR/act_runner.gitea.pid"
|
||||||
echo "Runner: gitea has been started with pid: $pid" | tee -a -p "$LOG_DIR/init.txt"
|
echo "Runner: gitea has been started with pid: $pid" | tee -a -p "$LOG_DIR/init.txt"
|
||||||
@@ -541,7 +542,7 @@ __post_execute() {
|
|||||||
act_runner cache-server --config "$CACHE_CONFIG_FILE" 2>>/dev/stderr >>"$CACHE_LOG_FILE" &
|
act_runner cache-server --config "$CACHE_CONFIG_FILE" 2>>/dev/stderr >>"$CACHE_LOG_FILE" &
|
||||||
execPid=$!
|
execPid=$!
|
||||||
sleep 5
|
sleep 5
|
||||||
if ps ax | awk '{print $1}' | grep -v grep | grep -q "$execPid$"; then
|
if ps ax | awk '{print $1}' | grep -v -- 'grep' | grep -q -- "$execPid$"; then
|
||||||
echo "Cache server has been started and is listening on $RUNNER_CACHE_PORT"
|
echo "Cache server has been started and is listening on $RUNNER_CACHE_PORT"
|
||||||
else
|
else
|
||||||
echo "Failed to start the cache server" >&2
|
echo "Failed to start the cache server" >&2
|
||||||
@@ -555,7 +556,7 @@ __post_execute() {
|
|||||||
# fire-and-forget: backgrounded subshell always succeeds at launch
|
# fire-and-forget: backgrounded subshell always succeeds at launch
|
||||||
retVal=0
|
retVal=0
|
||||||
# allow custom functions
|
# allow custom functions
|
||||||
if builtin type -t __post_execute_local | grep -q 'function'; then __post_execute_local; fi
|
if builtin type -t __post_execute_local | grep -q -- 'function'; then __post_execute_local; fi
|
||||||
# exit function
|
# exit function
|
||||||
return $retVal
|
return $retVal
|
||||||
}
|
}
|
||||||
@@ -567,7 +568,7 @@ __pre_message() {
|
|||||||
# execute commands
|
# execute commands
|
||||||
|
|
||||||
# allow custom functions
|
# allow custom functions
|
||||||
if builtin type -t __pre_message_local | grep -q 'function'; then __pre_message_local; fi
|
if builtin type -t __pre_message_local | grep -q -- 'function'; then __pre_message_local; fi
|
||||||
# exit function
|
# exit function
|
||||||
return $exitCode
|
return $exitCode
|
||||||
}
|
}
|
||||||
@@ -580,7 +581,7 @@ __update_ssl_conf() {
|
|||||||
# execute commands
|
# execute commands
|
||||||
|
|
||||||
# allow custom functions
|
# allow custom functions
|
||||||
if builtin type -t __update_ssl_conf_local | grep -q 'function'; then __update_ssl_conf_local; fi
|
if builtin type -t __update_ssl_conf_local | grep -q -- 'function'; then __update_ssl_conf_local; fi
|
||||||
# set exitCode
|
# set exitCode
|
||||||
return $exitCode
|
return $exitCode
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user