60 lines
1.9 KiB
Bash
Executable file
60 lines
1.9 KiB
Bash
Executable file
#!/usr/bin/bash
|
|
|
|
if [[ -z "$FORGEJO_ROOT" ]]; then
|
|
echo "Error: FORGEJO_ROOT must be defined in the environment."
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -z "$FORGEJO_RUNNER_ROOT" ]]; then
|
|
echo "Error: FORGEJO_RUNNER_ROOT must be defined in the environment."
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -z "$FORGEJO_RUNNER_CONFIG" ]]; then
|
|
echo "Using the default runner configuration."
|
|
fi
|
|
|
|
podman pod create \
|
|
-p 3000:3000 \
|
|
-p 2052:2222 \
|
|
--replace \
|
|
"code-forge"
|
|
|
|
# Start webapp.
|
|
|
|
podman run \
|
|
-td \
|
|
--name "code-forge_app" \
|
|
--pod "code-forge" \
|
|
-v "$FORGEJO_ROOT"/data:/var/lib/gitea \
|
|
-v "$FORGEJO_ROOT"/config:/etc/gitea \
|
|
-v /etc/timezone:/etc/timezone:ro \
|
|
-v /etc/localtime:/etc/localtime:ro \
|
|
--replace \
|
|
codeberg.org/forgejo/forgejo:1.21.8-0-rootless
|
|
|
|
# The runners require the app to be healthy before startup.
|
|
response=""
|
|
until [[ $response = *"200 OK"* ]]; do
|
|
response="$(curl localhost:3000 -s -i | head -1)"
|
|
echo "Waiting for app to respond..."
|
|
done
|
|
|
|
wget -O "$FORGEJO_RUNNER_ROOT"/forgejo-runner https://code.forgejo.org/forgejo/runner/releases/download/v3.3.0/forgejo-runner-3.3.0-linux-amd64
|
|
chmod +x "$FORGEJO_RUNNER_ROOT"/forgejo-runner
|
|
wget -O forgejo-runner.asc https://code.forgejo.org/forgejo/runner/releases/download/v3.3.0/forgejo-runner-3.3.0-linux-amd64.asc
|
|
gpg --keyserver keys.openpgp.org --recv EB114F5E6C0DC2BCDD183550A4B61A2DC5923710
|
|
gpg --verify forgejo-runner.asc "$FORGEJO_RUNNER_ROOT"/forgejo-runner
|
|
rm forgejo-runner.asc
|
|
|
|
|
|
if [ -f "$FORGEJO_RUNNER_ROOT/.runner" ]; then
|
|
echo "Found runner state."
|
|
(
|
|
cd "$FORGEJO_RUNNER_ROOT" || exit
|
|
"$FORGEJO_RUNNER_ROOT"/forgejo-runner --config "${FORGEJO_RUNNER_CONFIG:=./config.yml}" daemon &
|
|
)
|
|
else
|
|
echo "Use $FORGEJO_RUNNER_ROOT/forgejo-runner register ... to register the runner"
|
|
echo "Once registered, use $FORGEJO_RUNNER_ROOT/forgejo-runner --config <path-to-config> daemon & to start"
|
|
fi
|