Init forgejo job
This commit is contained in:
parent
5ffce9340c
commit
df38fa9be7
1 changed files with 71 additions and 0 deletions
71
jobs/forgejo.run
Normal file
71
jobs/forgejo.run
Normal file
|
@ -0,0 +1,71 @@
|
|||
#!/bin/env bash
|
||||
# Upstream doc: https://forgejo.org/docs/latest/admin/installation-binary/
|
||||
set -euxo pipefail
|
||||
|
||||
IMAGE="ubuntu/24.04"
|
||||
DIST="${IMAGE%%/*}"
|
||||
VER="${IMAGE#*/}"
|
||||
VER="${VER%/*}"
|
||||
VER="${VER//./-}"
|
||||
UPSTREAM_VER="8.0.3"
|
||||
UPSTREAM_VER_DASH="${UPSTREAM_VER//./-}"
|
||||
UPSTREAM_NAME="forgejo"
|
||||
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
|
||||
sleep 5
|
||||
|
||||
# Forgejo
|
||||
incus exec $CNAME -- mkdir /etc/esh
|
||||
incus exec $CNAME -- apt update
|
||||
incus exec $CNAME -- apt upgrade -y
|
||||
incus exec $CNAME -- apt install -y --no-install-recommends wget git git-lfs redis-server
|
||||
incus exec $CNAME -- \
|
||||
wget --quiet \
|
||||
https://codeberg.org/forgejo/forgejo/releases/download/v${UPSTREAM_VER}/forgejo-${UPSTREAM_VER}-linux-amd64 \
|
||||
-O /usr/local/bin/forgejo
|
||||
incus exec $CNAME -- chmod +x /usr/local/bin/forgejo
|
||||
incus exec $CNAME -- adduser --system --shell /bin/bash --gecos 'Git Version Control' --group --disabled-password --home /home/git git
|
||||
incus exec $CNAME -- mkdir /var/lib/forgejo
|
||||
incus exec $CNAME -- chown git:git /var/lib/forgejo
|
||||
incus exec $CNAME -- chmod 750 /var/lib/forgejo
|
||||
incus exec $CNAME -- mkdir /etc/forgejo
|
||||
incus exec $CNAME -- chown root:git /etc/forgejo
|
||||
incus exec $CNAME -- chmod 770 /etc/forgejo
|
||||
incus exec $CNAME -- \
|
||||
wget --quiet \
|
||||
-O /etc/systemd/system/forgejo.service \
|
||||
https://codeberg.org/forgejo/forgejo/raw/branch/forgejo/contrib/systemd/forgejo.service
|
||||
#incus file push setup.sh $CNAME/usr/local/bin/
|
||||
|
||||
# Clean
|
||||
incus exec $CNAME -- \
|
||||
rm -rf \
|
||||
/etc/machine-id \
|
||||
/var/cache/apt \
|
||||
/var/log/journal
|
||||
|
||||
# Publish
|
||||
incus stop $CNAME
|
||||
incus config metadata show $CNAME > $ARCHIVE/metadata.yaml
|
||||
# Get the current Unix timestamp
|
||||
current_timestamp=$(date +%s)
|
||||
# Calculate expiry date as current timestamp + 1 week (604800 seconds)
|
||||
expiry_date=$(($current_timestamp + 604800))
|
||||
# Update metadata values
|
||||
sed -i \
|
||||
-e "s/creation_date: .*/creation_date: $current_timestamp/" \
|
||||
-e "s/expiry_date: .*/expiry_date: $expiry_date/" \
|
||||
-e "s#description: .*#description: $UPSTREAM_NAME v$UPSTREAM_VER on $IMAGE release $SERIAL#" \
|
||||
-e "s/name: .*/name: $CNAME/" \
|
||||
-e "s/serial: .*/serial: $SERIAL/" \
|
||||
$ARCHIVE/metadata.yaml
|
||||
|
||||
incus config metadata edit $CNAME < $ARCHIVE/metadata.yaml
|
||||
incus publish $CNAME --alias $ALIAS --public --quiet
|
||||
incus rm $CNAME
|
Loading…
Add table
Reference in a new issue