Beszel: Init

This commit is contained in:
Benoit 2025-02-16 18:06:45 +09:00
parent 418352efa1
commit fa5ff010d7
Signed by: Benoit
SSH key fingerprint: SHA256:kFsX94Kq6z/6CY0dX+7/FpAeJC0QlMhJVY+B7NYrOmA

68
cfg/jobs/beszel.run Executable file
View file

@ -0,0 +1,68 @@
#!/bin/env bash
# Upstream doc: https://beszel.dev/guide/hub-installation#binary
set -euxo pipefail
IMAGE="ubuntu/24.04"
DIST="${IMAGE%%/*}"
VER="${IMAGE#*/}"
VER="${VER%/*}"
VER="${VER//./-}"
UPSTREAM_VER="0.9.1"
UPSTREAM_VER_DASH="${UPSTREAM_VER//./-}"
UPSTREAM_NAME="beszel"
SERIAL="1benoitjpnet"
CNAME="$UPSTREAM_NAME-$UPSTREAM_VER_DASH-$SERIAL-$DIST-$VER"
ALIAS="$UPSTREAM_NAME-$UPSTREAM_VER-$SERIAL"
cd "$WORKSPACE"
incus launch images:$IMAGE "$CNAME" --quiet
wait_network "$CNAME"
incus config set "$CNAME" environment.DEBIAN_FRONTEND=noninteractive
incus config set "$CNAME" environment.DEBCONF_NONINTERACTIVE_SEEN=true
incus config set "$CNAME" environment.LC_ALL=C
incus exec "$CNAME" -- apt-get update
incus exec "$CNAME" -- apt-get upgrade -y
incus exec "$CNAME" -- apt-get install -y --no-install-recommends wget
incus exec "$CNAME" -- adduser \
--shell /bin/bash \
--gecos "Beszel Hub" \
--disabled-password \
--home /opt/beszel \
beszel
incus exec "$CNAME" -- wget --quiet \
https://github.com/henrygd/beszel/releases/download/v"$UPSTREAM_VER"/beszel_linux_amd64.tar.gz \
-O /tmp/
incus exec "$CNAME" -- tar -xzf \
/tmp/beszel_linux_amd64.tar.gz \
-C /opt/beszel/
incus exec "$CNAME" -- bash -c 'cat > /etc/systemd/system/beszel.service << EOF
[Unit]
Description=Beszel Hub
After=network.target
[Service]
Type=simple
Restart=always
RestartSec=3
User=beszel
WorkingDirectory=/opt/beszel
ExecStart=/opt/beszel/beszel serve --http "0.0.0.0:8090"
[Install]
WantedBy=multi-user.target
EOF'
incus exec "$CNAME" -- systemctl enable beszel.service
laminarc run incus_publish \
CNAME="$CNAME" \
UPSTREAM_NAME=$UPSTREAM_NAME \
UPSTREAM_VER=$UPSTREAM_VER \
IMAGE=$IMAGE \
SERIAL=$SERIAL \
ALIAS=$ALIAS