mirror of
https://github.com/casjaysdevdocker/gitea
synced 2024-11-22 05: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,7 +239,6 @@ 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/}")"
|
||||||
@ -247,6 +246,7 @@ EOF
|
|||||||
[ -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"; }
|
||||||
@ -257,15 +257,15 @@ EOF
|
|||||||
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
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
done 2>"/dev/stderr" | tee -p -a "$LOG_DIR/init.txt" >/dev/null
|
done 2>"/dev/stderr" | tee -p -a "$LOG_DIR/init.txt" >/dev/null
|
||||||
fi
|
|
||||||
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