mirror of
https://github.com/casjaysdevdocker/gitea
synced 2024-11-24 23:23:07 -05:00
🗃️ Committing everything that changed 🗃️
rootfs/usr/local/etc/docker/init.d/zz-act_runner.sh
This commit is contained in:
parent
e599a9210b
commit
827f0aa206
@ -239,33 +239,33 @@ RUNNER_HOSTNAME="${INSTANCE_HOSTNAME:-http://127.0.0.1:8000}"
|
|||||||
CONTAINER_IP4_ADDRESS="${CONTAINER_IP4_ADDRESS}"
|
CONTAINER_IP4_ADDRESS="${CONTAINER_IP4_ADDRESS}"
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
if [ ! -f "$CONF_DIR/runners" ]; then
|
for runner in "$CONF_DIR/reg"/*.reg; do
|
||||||
for runner in "$CONF_DIR/reg"/*.reg; do
|
exitStatus=0
|
||||||
exitStatus=0
|
RUNNER_NAME="$(basename "${runner//.reg/}")"
|
||||||
RUNNER_NAME="$(basename "${runner//.reg/}")"
|
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}"
|
||||||
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"; }
|
||||||
chmod -Rf 600 "$CONF_DIR/tokens/system" "$CONF_DIR/tokens/$RUNNER_NAME" 2>/dev/null
|
chmod -Rf 600 "$CONF_DIR/tokens/system" "$CONF_DIR/tokens/$RUNNER_NAME" 2>/dev/null
|
||||||
chown -Rf "$SERVICE_USER":"$SERVICE_GROUP" "$CONF_DIR" "$ETC_DIR" "$DATA_DIR" 2>/dev/null
|
chown -Rf "$SERVICE_USER":"$SERVICE_GROUP" "$CONF_DIR" "$ETC_DIR" "$DATA_DIR" 2>/dev/null
|
||||||
echo "Error: RUNNER_AUTH_TOKEN is not set - visit $INSTANCE_HOSTNAME/admin/actions/runners" >&2
|
echo "Error: RUNNER_AUTH_TOKEN is not set - visit $INSTANCE_HOSTNAME/admin/actions/runners" >&2
|
||||||
echo "Then edit $runner or set in $CONF_DIR/tokens/$RUNNER_NAME" >&2
|
echo "Then edit $runner or set in $CONF_DIR/tokens/$RUNNER_NAME" >&2
|
||||||
sleep 120
|
sleep 120
|
||||||
else
|
else
|
||||||
echo "RUNNER_AUTH_TOKEN has been set: trying to register $RUNNER_NAME"
|
echo "RUNNER_AUTH_TOKEN has been set: trying to register $RUNNER_NAME"
|
||||||
|
if [ ! -f "$RUNNER_HOME/runners" ]; then
|
||||||
|
cp -Rf "$CONF_DIR/multi.yaml" "$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
|
||||||
echo "$!" >"$RUN_DIR/act_runner.$RUNNER_NAME.pid"
|
echo "$!" >"$RUN_DIR/act_runner.$RUNNER_NAME.pid"
|
||||||
if [ $exitStatus -eq 0 ]; then
|
if [ $exitStatus -eq 0 ]; then
|
||||||
exitStatus=0
|
exitStatus=0
|
||||||
mv -fv "$runner" "$RUNNER_HOME/$RUNNER_NAME.reg"
|
cp -Rf "$runner" "$RUNNER_HOME/$RUNNER_NAME.reg"
|
||||||
cp -Rf "$CONF_DIR/multi.yaml" "$RUNNER_HOME/$RUNNER_NAME.yaml"
|
|
||||||
__replace "REPLACE_RUNNER_HOME" "$RUNNER_HOME" "$RUNNER_HOME/$RUNNER_NAME.yaml"
|
|
||||||
chown -Rf "$SERVICE_USER":"$SERVICE_GROUP" "$RUNNER_HOME"
|
chown -Rf "$SERVICE_USER":"$SERVICE_GROUP" "$RUNNER_HOME"
|
||||||
act_runner daemon --config $RUNNER_HOME/$RUNNER_NAME.yaml
|
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
[ -f "$RUN_DIR/act_runner.$RUNNER_NAME.pid" ] && rm -f "$RUN_DIR/act_runner.$RUNNER_NAME.pid"
|
[ -f "$RUN_DIR/act_runner.$RUNNER_NAME.pid" ] && rm -f "$RUN_DIR/act_runner.$RUNNER_NAME.pid"
|
||||||
@ -273,9 +273,9 @@ EOF
|
|||||||
sleep 20
|
sleep 20
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
fi
|
||||||
done 2>"/dev/stderr" | tee -p -a "$LOG_DIR/init.txt" >/dev/null
|
done
|
||||||
fi
|
done 2>"/dev/stderr" | tee -p -a "$LOG_DIR/init.txt" >/dev/null
|
||||||
echo "$$" >"$RUN_DIR/act_runner.pid"
|
echo "$$" >"$RUN_DIR/act_runner.pid"
|
||||||
echo "$(date)" >"$CONF_DIR/.runner"
|
echo "$(date)" >"$CONF_DIR/.runner"
|
||||||
return $exitStatus
|
return $exitStatus
|
||||||
@ -363,6 +363,13 @@ __post_execute() {
|
|||||||
# show message
|
# show message
|
||||||
__banner "$postMessageST"
|
__banner "$postMessageST"
|
||||||
# commands to execute
|
# commands to execute
|
||||||
|
for multi in "$CONF_DIR/multi"/*; do
|
||||||
|
name="$(basename "$multi")"
|
||||||
|
if [ -f "$$multi/$name.yaml" ] && [ -f "$multi/runners" ]; then
|
||||||
|
act_runner daemon --config $multi/$name.yaml
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
act_runner cache-server --config $CONF_DIR/daemon.yaml -s 0.0.0.0 -p $SERVICE_PORT 2>>/dev/stderr | tee -a -p "$LOG_DIR/act_runner_cache.log" &
|
act_runner cache-server --config $CONF_DIR/daemon.yaml -s 0.0.0.0 -p $SERVICE_PORT 2>>/dev/stderr | tee -a -p "$LOG_DIR/act_runner_cache.log" &
|
||||||
execPid=$!
|
execPid=$!
|
||||||
sleep 5 && ps ax | awk '{print $1}' | grep -v grep | grep -q "$execPid$" && return 0 || return 2
|
sleep 5 && ps ax | awk '{print $1}' | grep -v grep | grep -q "$execPid$" && return 0 || return 2
|
||||||
|
Loading…
Reference in New Issue
Block a user