2023-12-13 22:10:12 +00:00
|
|
|
#!/bin/dash
|
|
|
|
|
2023-12-13 23:33:08 +00:00
|
|
|
# Data Path : /srv/data
|
|
|
|
# Docker Path : /var/lib/docker
|
|
|
|
|
2023-12-13 22:10:12 +00:00
|
|
|
GITEA_INSTANCE_URL=""
|
|
|
|
GITEA_INSTANCE_URL=$(whiptail --title "GITEA_INSTANCE_URL" --inputbox "" 0 30 "${GITEA_INSTANCE_URL}" 3>&1 1>&2 2>&3)
|
|
|
|
GITEA_RUNNER_REGISTRATION_TOKEN=""
|
|
|
|
GITEA_RUNNER_REGISTRATION_TOKEN=$(whiptail --title "GITEA_RUNNER_REGISTRATION_TOKEN" --inputbox "" 0 30 "${GITEA_RUNNER_REGISTRATION_TOKEN}" 3>&1 1>&2 2>&3)
|
|
|
|
IMAGES=""
|
|
|
|
|
|
|
|
if [ "${GITEA_INSTANCE_URL}" = "" ] || [ "${GITEA_RUNNER_REGISTRATION_TOKEN}" = "" ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
apk add docker docker-compose
|
|
|
|
rc-update add docker boot
|
|
|
|
service docker start
|
|
|
|
|
|
|
|
mkdir -p /srv/compose
|
|
|
|
mkdir -p /srv/data
|
|
|
|
|
|
|
|
|
|
|
|
SelectImages() {
|
|
|
|
SEL=$(whiptail --title "Images" --checklist "" 0 0 0 \
|
2023-12-13 22:21:14 +00:00
|
|
|
"alpine" "" on \
|
2023-12-13 22:10:12 +00:00
|
|
|
"debian-bookworm" "" on \
|
|
|
|
"debian-bookworm-slim" "" on \
|
|
|
|
"debian-bullseye" "" on \
|
|
|
|
"debian-bullseye-slim" "" on \
|
|
|
|
"debian-buster" "" on \
|
|
|
|
"debian-buster-slim" "" on \
|
2023-12-16 20:27:46 +00:00
|
|
|
"node-16-bullseye" "" on \
|
|
|
|
"node-18-bookworm" "" on \
|
|
|
|
"node-20-bookworm" "" on \
|
2023-12-13 22:10:12 +00:00
|
|
|
"archlinux" "" on \
|
|
|
|
"archlinux-base-devel" "" on 3>&1 1>&2 2>&3)
|
|
|
|
# shellcheck disable=SC2181
|
|
|
|
if [ "${?}" = "0" ]; then
|
|
|
|
for ITM in ${SEL}; do
|
|
|
|
# shellcheck disable=SC3000-SC4000
|
|
|
|
case ${ITM//\"/} in
|
2023-12-13 22:21:14 +00:00
|
|
|
"alpine") IMAGES=${IMAGES}'"alpine:docker://alpine",';;
|
|
|
|
"debian-bookworm") IMAGES=${IMAGES}'"debian-bookworm:docker://debian:bookworm",';;
|
|
|
|
"debian-bookworm-slim") IMAGES=${IMAGES}'"debian-bookworm-slim:docker://debian:bookworm-slim",';;
|
|
|
|
"debian-bullseye") IMAGES=${IMAGES}'"debian-bullseye:docker://debian:bullseye",';;
|
|
|
|
"debian-bullseye-slim") IMAGES=${IMAGES}'"debian-bullseye-slim:docker://debian:bullseye-slim",';;
|
|
|
|
"debian-buster") IMAGES=${IMAGES}'"debian-buster:docker://debian:buster",';;
|
|
|
|
"debian-buster-slim") IMAGES=${IMAGES}'"debian-buster-slim:docker://debian:buster-slim",';;
|
2023-12-16 20:27:46 +00:00
|
|
|
"node-16") IMAGES=${IMAGES}'"node-16:docker://node:16-bullseye",';;
|
|
|
|
"node-18") IMAGES=${IMAGES}'"node-18:docker://node:18-bookworm",';;
|
|
|
|
"node-20") IMAGES=${IMAGES}'"node-20:docker://node:20-bookworm",';;
|
2023-12-13 22:21:14 +00:00
|
|
|
"archlinux") IMAGES=${IMAGES}'"archlinux:docker://archlinux",';;
|
|
|
|
"archlinux-base-devel") IMAGES=${IMAGES}'"archlinux-base-devel:docker://archlinux:base-devel",';;
|
2023-12-13 22:10:12 +00:00
|
|
|
esac
|
|
|
|
done
|
2023-12-13 22:31:59 +00:00
|
|
|
# shellcheck disable=SC3057
|
|
|
|
IMAGES=${IMAGES::-1}
|
2023-12-13 22:10:12 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
SelectImages
|
|
|
|
|
|
|
|
{
|
|
|
|
echo "runner:"
|
2023-12-13 23:15:00 +00:00
|
|
|
echo " insecure: true"
|
2023-12-13 22:21:14 +00:00
|
|
|
echo " labels: [${IMAGES}]"
|
2023-12-13 22:10:12 +00:00
|
|
|
} > /srv/data/config.yaml
|
|
|
|
|
|
|
|
{
|
|
|
|
echo "services:"
|
|
|
|
echo " runner:"
|
|
|
|
echo " container_name: gitea-act_runner"
|
|
|
|
echo " image: gitea/act_runner:latest"
|
|
|
|
echo " restart: unless-stopped"
|
|
|
|
echo " volumes:"
|
|
|
|
echo " - /srv/data:/data"
|
|
|
|
echo " - /var/run/docker.sock:/var/run/docker.sock"
|
|
|
|
echo " environment:"
|
|
|
|
echo " - CONFIG_FILE=/data/config.yaml"
|
|
|
|
echo " - GITEA_INSTANCE_URL=${GITEA_INSTANCE_URL}"
|
|
|
|
echo " - GITEA_RUNNER_REGISTRATION_TOKEN=${GITEA_RUNNER_REGISTRATION_TOKEN}"
|
|
|
|
} > /srv/compose/compose.yaml
|
|
|
|
|
|
|
|
cd /srv/compose || exit 1
|
|
|
|
docker-compose up -d
|