Add some useful systemd commands
This commit is contained in:
parent
43b6760978
commit
07b2594d46
1 changed files with 104 additions and 100 deletions
|
@ -1,101 +1,105 @@
|
||||||
# Creating a new ForgeJo Runner Host
|
# Creating a new ForgeJo Runner Host
|
||||||
|
|
||||||
## Machine Setup
|
## Machine Setup
|
||||||
|
|
||||||
### 1. Install Ubuntu (24.04)
|
### 1. Install Ubuntu (24.04)
|
||||||
|
|
||||||
For example on the Hetzner cloud.
|
For example on the Hetzner cloud.
|
||||||
|
|
||||||
### 2. Create a new user for the runner
|
### 2. Create a new user for the runner
|
||||||
|
|
||||||
Since we don't want to the new forgejo runner to be ``root`` on out machine, we create a new user for it:
|
Since we don't want to the new forgejo runner to be ``root`` on out machine, we create a new user for it:
|
||||||
```bash
|
```bash
|
||||||
# As root
|
# As root
|
||||||
useradd -s /bin/bash --create-home forgejo-runner
|
useradd -s /bin/bash --create-home forgejo-runner
|
||||||
loginctl enable-linger forgejo-runner
|
loginctl enable-linger forgejo-runner
|
||||||
```
|
```
|
||||||
|
|
||||||
### 3. Install podman (rootless)
|
### 3. Install podman (rootless)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# As root
|
# As root
|
||||||
apt install -y podman
|
apt install -y podman
|
||||||
echo "forgejo-runner:10000:12000" >> /etc/subuid
|
echo "forgejo-runner:10000:12000" >> /etc/subuid
|
||||||
echo "forgejo-runner:10000:12000" >> /etc/subgid
|
echo "forgejo-runner:10000:12000" >> /etc/subgid
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Enable Podman docker-socket on user
|
#### Enable Podman docker-socket on user
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# As root
|
# As root
|
||||||
apt install -y systemd-container
|
apt install -y systemd-container
|
||||||
machinectl shell --uid forgejo-runner # <-- This is basically "sudo -Hi XXX" but makes sure the systemd container is switched too.
|
machinectl shell --uid forgejo-runner # <-- This is basically "sudo -Hi XXX" but makes sure the systemd container is switched too.
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
systemctl enable --user podman.socket
|
systemctl enable --user podman.socket
|
||||||
echo 'export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/podman/podman.sock' >> ~/.profile
|
echo 'export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/podman/podman.sock' >> ~/.profile
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Automatic podman cleanup on reboot
|
#### Automatic podman cleanup on reboot
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
crontab -e
|
crontab -e
|
||||||
```
|
```
|
||||||
```cronexp
|
```cronexp
|
||||||
@reboot podman system cleanup --all --force
|
@reboot podman system cleanup --all --force
|
||||||
```
|
```
|
||||||
|
|
||||||
### 4. Install the forgejo-runner
|
### 4. Install the forgejo-runner
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# As forgejo-runner
|
# As forgejo-runner
|
||||||
# Verify these URLs are still the version you want to install!!!
|
# Verify these URLs are still the version you want to install!!!
|
||||||
DOWNLOAD_URL="https://code.forgejo.org/forgejo/runner/releases/download/v5.0.4/forgejo-runner-5.0.4-linux-amd64"
|
DOWNLOAD_URL="https://code.forgejo.org/forgejo/runner/releases/download/v5.0.4/forgejo-runner-5.0.4-linux-amd64"
|
||||||
SIG_URL="https://code.forgejo.org/forgejo/runner/releases/download/v5.0.4/forgejo-runner-5.0.4-linux-amd64.asc"
|
SIG_URL="https://code.forgejo.org/forgejo/runner/releases/download/v5.0.4/forgejo-runner-5.0.4-linux-amd64.asc"
|
||||||
gpg --keyserver keys.openpgp.org --recv EB114F5E6C0DC2BCDD183550A4B61A2DC5923710 # Installs the signing key used by forgejo for their releases
|
gpg --keyserver keys.openpgp.org --recv EB114F5E6C0DC2BCDD183550A4B61A2DC5923710 # Installs the signing key used by forgejo for their releases
|
||||||
wget -O forgejo-runner "$DOWNLOAD_URL"
|
wget -O forgejo-runner "$DOWNLOAD_URL"
|
||||||
wget -O forgejo-runner.asc "$SIG_URL"
|
wget -O forgejo-runner.asc "$SIG_URL"
|
||||||
gpg --verify forgejo-runner.asc forgejo-runner
|
gpg --verify forgejo-runner.asc forgejo-runner
|
||||||
# The output should now contain the following:
|
# The output should now contain the following:
|
||||||
# Good signature from "Forgejo <contact@forgejo.org>"
|
# Good signature from "Forgejo <contact@forgejo.org>"
|
||||||
# aka "Forgejo Releases <release@forgejo.org>"
|
# aka "Forgejo Releases <release@forgejo.org>"
|
||||||
|
|
||||||
mkdir -p ~/.local/bin
|
mkdir -p ~/.local/bin
|
||||||
mv ./forgejo-runner ~/.local/bin/forgejo-runner
|
mv ./forgejo-runner ~/.local/bin/forgejo-runner
|
||||||
chmod 750 ~/.local/bin/forgejo-runner
|
chmod 750 ~/.local/bin/forgejo-runner
|
||||||
```
|
```
|
||||||
|
|
||||||
### 5. Configure and register the forgejo-runner
|
### 5. Configure and register the forgejo-runner
|
||||||
|
|
||||||
__The official runner registration is__ [here](https://forgejo.org/docs/v8.0/admin/runner-installation/#standard-registration)
|
__The official runner registration is__ [here](https://forgejo.org/docs/v8.0/admin/runner-installation/#standard-registration)
|
||||||
Or, if you're volunteering another runner for our instance, please contact us to receive the necessary registration information. :)
|
Or, if you're volunteering another runner for our instance, please contact us to receive the necessary registration information. :)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# As forgejo-runner
|
# As forgejo-runner
|
||||||
forgejo-runner generate-config > config.yml
|
forgejo-runner generate-config > config.yml
|
||||||
|
|
||||||
# We're about to enter secrets into the terminal, disable history:
|
# We're about to enter secrets into the terminal, disable history:
|
||||||
set +o history
|
set +o history
|
||||||
RUNNER_INST_URL="https://git.forsaken-ashbirds.net"
|
RUNNER_INST_URL="https://git.forsaken-ashbirds.net"
|
||||||
RUNNER_NAME="<PLEASE ENTER A UNIQUE NAME FOR YOUR RUNNER HERE!!!>"
|
RUNNER_NAME="<PLEASE ENTER A UNIQUE NAME FOR YOUR RUNNER HERE!!!>"
|
||||||
RUNNER_TOKEN="<The token from the UI>"
|
RUNNER_TOKEN="<The token from the UI>"
|
||||||
RUNNER_LABELS="ubuntu-24.04,docker,podman,self-hosted" # Update these labels if you intend to change stuff!
|
RUNNER_LABELS="ubuntu-24.04,docker,podman,self-hosted" # Update these labels if you intend to change stuff!
|
||||||
|
|
||||||
# Re-enable history :)
|
# Re-enable history :)
|
||||||
set -o history
|
set -o history
|
||||||
forgejo-runner register --instance "$RUNNER_INST_URL" --name "$RUNNER_NAME" --token "$RUNNER_TOKEN" --labels "$RUNNER_LABELS" --no-interactive
|
forgejo-runner register --instance "$RUNNER_INST_URL" --name "$RUNNER_NAME" --token "$RUNNER_TOKEN" --labels "$RUNNER_LABELS" --no-interactive
|
||||||
# You should see the following afterwards:
|
# You should see the following afterwards:
|
||||||
# INFO Runner registered successfully
|
# INFO Runner registered successfully
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Check the runner is working
|
#### Check the runner is working
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# As forgejo-runner
|
# As forgejo-runner
|
||||||
mkdir -p ~/.config/systemd/user
|
mkdir -p ~/.config/systemd/user
|
||||||
# Download the file "docs/forgejo-runner.service" from this repository to "~/.config/systemd/user"
|
# Download the file "docs/forgejo-runner.service" from this repository to "~/.config/systemd/user"
|
||||||
systemctl --user enable --now forgejo-runner
|
systemctl --user enable --now forgejo-runner
|
||||||
```
|
# View logs by using:
|
||||||
|
journalctl -xe --user-unit=forgejo-runner
|
||||||
|
# View status by using:
|
||||||
|
systemctl --user status forgejo-runner
|
||||||
|
```
|
||||||
|
|
||||||
__Go into Forgejo and check that your runner is shown as UP__.
|
__Go into Forgejo and check that your runner is shown as UP__.
|
Loading…
Add table
Reference in a new issue