first commit w/ functional install script and forgejo runner container unit
This commit is contained in:
commit
bc5c4f51db
4 changed files with 111 additions and 0 deletions
3
README.md
Normal file
3
README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Container Unit Files for Forgejo-Runner
|
||||
|
||||
To install them in the _rootless_ user directory, just execute `install` then reload systemd and start all the services.
|
23
forgejo-runner.container
Normal file
23
forgejo-runner.container
Normal file
|
@ -0,0 +1,23 @@
|
|||
[Unit]
|
||||
Description=Forgejo Runner
|
||||
Requires=podman.socket
|
||||
|
||||
[Container]
|
||||
ContainerName=forgejo-runner
|
||||
|
||||
User=0
|
||||
SecurityLabelDisable=true
|
||||
|
||||
Image=code.forgejo.org/forgejo/runner:3.3.0
|
||||
Exec=forgejo-runner --config config.yml daemon
|
||||
|
||||
Volume=forgejo-runner_data:/data
|
||||
Volume=/run/user/987/podman/podman.sock:/var/run/docker.sock:z
|
||||
|
||||
Network=pasta
|
||||
|
||||
[Service]
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
46
install
Executable file
46
install
Executable file
|
@ -0,0 +1,46 @@
|
|||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" # Retrieves script directory
|
||||
|
||||
source "${SCRIPT_DIR}/pretty_print" # Includes our nice print function
|
||||
|
||||
CONTAINERS_SYSTEMD_DIR="/var/lib/forgejo-runner/.config/containers/systemd"
|
||||
|
||||
FORGEJO_INSTANCE="https://git.archive.hostux.fr"
|
||||
|
||||
if [ "$1" = "--skip-init" ]; then
|
||||
pretty_print "Skipping the initial configuration." yellow bold
|
||||
elif [ -z "$1" ]; then
|
||||
pretty_print --no-newline "Enter the registration token from the Forgejo instance: " blue bold
|
||||
read FORGEJO_REGISTRATION_TOKEN
|
||||
|
||||
pretty_print "Generating the configuration..." blue bold
|
||||
podman run --rm -it \
|
||||
-v forgejo-runner_data:/data \
|
||||
-e FORGEJO_INSTANCE="$FORGEJO_INSTANCE" \
|
||||
-e FORGEJO_REGISTRATION_TOKEN="$FORGEJO_REGISTRATION_TOKEN" \
|
||||
code.forgejo.org/forgejo/runner:3.3.0 \
|
||||
sh -c '
|
||||
forgejo-runner register --no-interactive --token "$FORGEJO_REGISTRATION_TOKEN" --name forgejo-runner-on-norrsken --instance "$FORGEJO_INSTANCE" &&
|
||||
forgejo-runner generate-config > config.yml &&
|
||||
sed -i -e "s|network: .*|network: host|" config.yml &&
|
||||
sed -i -e "s|labels: \[\]|labels: \[\"docker:docker://alpine:3.19\"\]|" config.yml &&
|
||||
chown -R 1000:1000 /data
|
||||
'
|
||||
else
|
||||
echo "Usage: $0 [--skip-init]"
|
||||
fi
|
||||
|
||||
if [ ! -d "$CONTAINERS_SYSTEMD_DIR" ]; then
|
||||
pretty_print "Creating the containers units folder" blue bold
|
||||
mkdir -p "$CONTAINERS_SYSTEMD_DIR"
|
||||
fi
|
||||
|
||||
filename="forgejo-runner.container"
|
||||
destination_filename="$filename"
|
||||
|
||||
pretty_print "\nInstalling $filename..." blue bold
|
||||
cp -v $cp_do_not_overwrite_option "${SCRIPT_DIR}/$filename" "${CONTAINERS_SYSTEMD_DIR}/$destination_filename"
|
||||
|
||||
systemctl --user daemon-reload
|
||||
pretty_print "\nReloaded systemctl daemon. Done!" green bold
|
39
pretty_print
Executable file
39
pretty_print
Executable file
|
@ -0,0 +1,39 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Usage: pretty_print [--no-newline] <text> <color_name> [<bold>]
|
||||
pretty_print() {
|
||||
local colour=""
|
||||
local bold=""
|
||||
local newline="\n"
|
||||
|
||||
if [ "$1" = "--no-newline" ]; then
|
||||
newline=""
|
||||
shift
|
||||
fi
|
||||
if [ -n "$2" ]; then
|
||||
colour="$2"
|
||||
fi
|
||||
if [ "$3" = "bold" ]; then
|
||||
bold="\e[1m"
|
||||
fi
|
||||
|
||||
case "$colour" in
|
||||
red)
|
||||
colour="\e[31m"
|
||||
;;
|
||||
green)
|
||||
colour="\e[32m"
|
||||
;;
|
||||
yellow)
|
||||
colour="\e[33m"
|
||||
;;
|
||||
blue)
|
||||
colour="\e[34m"
|
||||
;;
|
||||
*)
|
||||
colour="\e[0m" # Reset
|
||||
;;
|
||||
esac
|
||||
echo -ne "${colour}${bold}$1\e[0m$newline"
|
||||
}
|
||||
|
Loading…
Reference in a new issue