🗃️ Committing everything that changed 🗃️

rootfs/usr/local/etc/docker/init.d/zz-act_runner.sh
This commit is contained in:
casjay 2024-08-11 16:49:37 -04:00
parent d8fd77402e
commit 54f23f7449
Signed by untrusted user who does not match committer: jason
GPG Key ID: 1AB309F42A764145

View File

@ -208,7 +208,7 @@ __run_pre_execute_checks() {
if [ ! -f "$CONF_DIR/reg/default.sample" ]; then if [ ! -f "$CONF_DIR/reg/default.sample" ]; then
cat <<EOF >"$CONF_DIR/reg/default.sample" cat <<EOF >"$CONF_DIR/reg/default.sample"
# Edit this file and execute it # Edit this file and execute it
RUNNER_NAME="sample" RUNNER_NAME="gitea"
RUNNER_HOME="$CONF_DIR" RUNNER_HOME="$CONF_DIR"
RUNNER_LABELS="$RUNNER_LABELS" RUNNER_LABELS="$RUNNER_LABELS"
RUNNER_AUTH_TOKEN="${RUNNER_AUTH_TOKEN:-$SYS_AUTH_TOKEN}" RUNNER_AUTH_TOKEN="${RUNNER_AUTH_TOKEN:-$SYS_AUTH_TOKEN}"
@ -225,24 +225,24 @@ EOF
fi fi
SYS_AUTH_TOKEN="${SYS_AUTH_TOKEN:-$(sudo -u gitea gitea --config /config/gitea/app.ini actions generate-runner-token 2>/dev/null | grep -v '\.\.\.')}" SYS_AUTH_TOKEN="${SYS_AUTH_TOKEN:-$(sudo -u gitea gitea --config /config/gitea/app.ini actions generate-runner-token 2>/dev/null | grep -v '\.\.\.')}"
if [ ! -f "$CONF_DIR/reg/default.reg" ]; then if [ ! -f "$CONF_DIR/reg/default.reg" ]; then
cat <<EOF >"$CONF_DIR/reg/default.reg" cat <<EOF >"$CONF_DIR/reg/runner-1.reg"
# Settings for the default gitea runner # Settings for the default gitea runner
RUNNER_NAME="gitea" RUNNER_NAME="runner-1"
RUNNER_HOME="$CONF_DIR/multi/$RUNNER_NAME" RUNNER_HOME="$CONF_DIR/multi/runner-1"
RUNNER_LABELS="$RUNNER_LABELS" RUNNER_LABELS="$RUNNER_LABELS"
RUNNER_AUTH_TOKEN="${RUNNER_AUTH_TOKEN:-$SYS_AUTH_TOKEN}" RUNNER_AUTH_TOKEN="${RUNNER_AUTH_TOKEN:-$SYS_AUTH_TOKEN}"
RUNNER_HOSTNAME="${CONTAINER_IP4_ADDRESS:-http://127.0.0.1:8000}" RUNNER_HOSTNAME="http://${HOSTNAME:-127.0.0.1:8000}"
CONTAINER_IP4_ADDRESS="${CONTAINER_IP4_ADDRESS}" CONTAINER_IP4_ADDRESS="${HOSTNAME}"
EOF EOF
cat <<EOF >"$CONF_DIR/reg/runner.reg" cat <<EOF >"$CONF_DIR/reg/runner-2.reg"
# Settings for the default local runner # Settings for the default local runner
RUNNER_NAME="local" RUNNER_NAME="runner-2"
RUNNER_HOME="$CONF_DIR/multi/$RUNNER_NAME" RUNNER_HOME="$CONF_DIR/multi/runner-2"
RUNNER_LABELS="$RUNNER_LABELS" RUNNER_LABELS="$RUNNER_LABELS"
RUNNER_AUTH_TOKEN="${RUNNER_AUTH_TOKEN:-$SYS_AUTH_TOKEN}" RUNNER_AUTH_TOKEN="${RUNNER_AUTH_TOKEN:-$SYS_AUTH_TOKEN}"
RUNNER_HOSTNAME="${CONTAINER_IP4_ADDRESS:-http://127.0.0.1:8000}" RUNNER_HOSTNAME="http://${HOSTNAME:-127.0.0.1:8000}"
CONTAINER_IP4_ADDRESS="${CONTAINER_IP4_ADDRESS}" CONTAINER_IP4_ADDRESS="${HOSTNAME}"
EOF EOF
fi fi
@ -252,8 +252,6 @@ EOF
while :; do while :; do
[ -f "$runner" ] && . "$runner" [ -f "$runner" ] && . "$runner"
[ -f "$RUN_DIR/act_runner.$RUNNER_NAME.pid" ] && break [ -f "$RUN_DIR/act_runner.$RUNNER_NAME.pid" ] && break
RUNNER_HOME="${RUNNER_HOME:-$CONF_DIR/multi/$RUNNER_NAME}"
mkdir -p "$RUNNER_HOME"
if [ -z "$RUNNER_AUTH_TOKEN" ]; then if [ -z "$RUNNER_AUTH_TOKEN" ]; then
[ -f "$CONF_DIR/tokens/system" ] && RUNNER_AUTH_TOKEN="$(<"$CONF_DIR/tokens/system")" [ -f "$CONF_DIR/tokens/system" ] && RUNNER_AUTH_TOKEN="$(<"$CONF_DIR/tokens/system")"
[ -f "$CONF_DIR/tokens/$RUNNER_NAME" ] && RUNNER_AUTH_TOKEN="$(<"$CONF_DIR/tokens/$RUNNER_NAME")" || { [ -n "$SYS_AUTH_TOKEN" ] && echo "$SYS_AUTH_TOKEN" >"$CONF_DIR/tokens/$RUNNER_NAME"; } [ -f "$CONF_DIR/tokens/$RUNNER_NAME" ] && RUNNER_AUTH_TOKEN="$(<"$CONF_DIR/tokens/$RUNNER_NAME")" || { [ -n "$SYS_AUTH_TOKEN" ] && echo "$SYS_AUTH_TOKEN" >"$CONF_DIR/tokens/$RUNNER_NAME"; }
@ -267,11 +265,13 @@ EOF
if [ -f "$RUNNER_HOME/runners" ]; then if [ -f "$RUNNER_HOME/runners" ]; then
continue continue
else else
cp -Rf "$CONF_DIR/multi.yaml" "$RUNNER_HOME/$RUNNER_NAME.yaml" [ -f "$runner" ] && . "$runner"
RUNNER_HOME="${RUNNER_HOME:-$CONF_DIR/multi/$RUNNER_NAME}"
mkdir -p "$RUNNER_HOME"
cp -Rf "$CONF_DIR/multi.yaml" "$RUNNER_HOME/daemon.yaml"
__replace "REPLACE_RUNNER_TEMP" "$TMP_DIR/$RUNNER_NAME" "$RUNNER_HOME/$RUNNER_NAME.yaml" __replace "REPLACE_RUNNER_TEMP" "$TMP_DIR/$RUNNER_NAME" "$RUNNER_HOME/$RUNNER_NAME.yaml"
__replace "REPLACE_RUNNER_HOME" "$RUNNER_HOME" "$RUNNER_HOME/$RUNNER_NAME.yaml" __replace "REPLACE_RUNNER_HOME" "$RUNNER_HOME" "$RUNNER_HOME/$RUNNER_NAME.yaml"
act_runner register --config "$RUNNER_HOME/$RUNNER_NAME.yaml" --labels "$RUNNER_LABELS" --name "$RUNNER_NAME" --instance "http://$CONTAINER_IP4_ADDRESS:8000" --token "$RUNNER_AUTH_TOKEN" --no-interactive && exitStatus=0 || exitStatus=1 act_runner register --config "$RUNNER_HOME/$RUNNER_NAME.yaml" --labels "$RUNNER_LABELS" --name "$RUNNER_NAME" --instance "http://$CONTAINER_IP4_ADDRESS:8000" --token "$RUNNER_AUTH_TOKEN" --no-interactive && exitStatus=0 || exitStatus=1
exitStatus=$?
if [ $exitStatus -eq 0 ]; then if [ $exitStatus -eq 0 ]; then
exitStatus=0 exitStatus=0
cp -Rf "$runner" "$RUNNER_HOME/$RUNNER_NAME.reg" cp -Rf "$runner" "$RUNNER_HOME/$RUNNER_NAME.reg"
@ -379,8 +379,8 @@ __post_execute() {
if [ -n "$multi" ] && [ -d "$multi" ]; then if [ -n "$multi" ] && [ -d "$multi" ]; then
unset pid is_running name unset pid is_running name
name="$(basename "$multi")" name="$(basename "$multi")"
if [ -f "$multi/$name.yaml" ] && [ -f "$multi/runners" ]; then if [ -f "$multi/daemon.yaml" ] && [ -f "$multi/runners" ]; then
act_runner daemon --config $multi/$name.yaml & act_runner daemon --config $multi/daemon.yaml &
local pid=$! local pid=$!
sleep 5 && ps ax | awk '{print $1}' | grep -v grep | grep -q "$pid$" && is_running="yes" sleep 5 && ps ax | awk '{print $1}' | grep -v grep | grep -q "$pid$" && is_running="yes"
if [ "$is_running" = "yes" ]; then if [ "$is_running" = "yes" ]; then