Add git role

This commit is contained in:
polyfloyd 2024-04-21 19:15:10 +02:00
parent 303e188e24
commit 5dd519d88a
9 changed files with 215 additions and 0 deletions

View file

@ -0,0 +1,22 @@
#!/bin/bash
# {{ ansible_managed }}
set -euo pipefail
install="{{ git_server_working_dir }}"
arch="linux-amd64"
version=$(curl -s https://forgejo.org/releases/rss.xml | xq -x '//rss/channel/item[1]/title' | sed 's/^v//')
if [[ ! $version =~ ^[0-9]+\.[0-9]+\.[0-9\-]+$ ]]; then
echo "invalid version: $version"
exit 1
fi
ofile="$install/forgejo-$version"
if [ ! -e "$ofile" ]; then
curl -s "https://codeberg.org/forgejo/forgejo/releases/download/v$version/forgejo-$version-$arch" > "$ofile"
chmod 755 "$ofile"
ln -sf "$ofile" "$install/forgejo"
systemctl restart forgejo.service
fi