feat: replace gitea by forgejo

This commit is contained in:
2026-03-03 01:09:48 +01:00
parent e19760d37e
commit c0de29a266
6 changed files with 38 additions and 97 deletions

View File

@@ -5,15 +5,15 @@ Version: %(make version)
Release: %(make release)
Summary: Netoik Reverse Proxy
License: MIT
URL: https://git.netoik.io/samuel/%(make name)
URL: https://git.netoik.io/%(make owner)/%(make name)
Source0: %{name}-%{version}-%{release}.tar.gz
Buildarch: %(make arch)
BuildRequires: make
Requires: netoik-rp netoik-db netoik-cache git
Requires: netoik-rp netoik-db netoik-cache forgejo
%description
Install the Git UI server called Gitea.
Install the Git UI server called Forgejo (fork of Gitea).
%prep
%autosetup -v
@@ -22,63 +22,30 @@ Install the Git UI server called Gitea.
%make_install
%post
# Download gitea bin and verify gpg signature
wget --quiet --output-document %{_tmppath}/gitea "$GITEA_BIN_URL"
wget --quiet --output-document %{_tmppath}/gitea.asc "$GITEA_ASC_URL"
gpg --keyserver "$GITEA_GPG_KEYSERVER" --recv "$GITEA_GPG_RECV"
gpg --verify %{_tmppath}/gitea.asc %{_tmppath}/gitea
mv %{_tmppath}/gitea %{_sbindir}
chmod 755 %{_sbindir}/gitea
rm %{_tmppath}/gitea.asc
# Change rights on config file
chgrp forgejo %{_sysconfdir}/forgejo/conf/netoik_app.ini
# Generate internal token and secret key
INTERNAL_TOKEN="$(gitea generate secret INTERNAL_TOKEN)"
SECRET_KEY="$(gitea generate secret SECRET_KEY)"
envsubst < %{_sysconfdir}/gitea/app.ini > %{_sysconfdir}/gitea/app.ini.new
mv %{_sysconfdir}/gitea/app.ini.new %{_sysconfdir}/gitea/app.ini
# Add user forgejo to db groups
usermod --groups postgres valkey --append forgejo
# Create gitea user
useradd --system --create-home --base-dir %{_sharedstatedir} gitea
runuser --user gitea -- mkdir --parents %{_sharedstatedir}/gitea/{data,custom}
chgrp gitea %{_sysconfdir}/gitea/app.ini
# Create postgres user and db
if ! runuser --user=postgres -- psql --quiet --tuples-only --command='\du' | grep --quiet forgejo; then
runuser --user=postgres -- createuser forgejo
runuser --user=postgres -- createdb --owner=forgejo forgejo
fi
# Start gitea and nginx services
# Restart forgejo and nginx services
systemctl daemon-reload
systemctl reenable gitea.service
systemctl restart gitea.service
systemctl reenable forgejo.service
systemctl restart forgejo.service
systemctl restart nginx.service
# Create actrunners
for i in $(seq 1 $GITEA_ACT_RUNNERS); do
if ! id "actrunner$i"; then
useradd --system --create-home --base-dir %{_sharedstatedir}/actrunners "actrunner$i"
systemctl daemon-reload
systemctl reenable "actrunner@$i"
systemctl restart "actrunner@$i"
fi
done
%preun
# Backup gitea data in case of problem
runuser --user gitea -- gitea dump --config %{_sysconfdir}/gitea/app.ini --tempdir %{_tmppath}
%postun
# Remove gitea user after uninstall
#if [ %1 == 0 ]; then
# systemctl stop gitea.service
# userdel --force --remove gitea
#fi
%files
%attr(640, root, -) %{_sysconfdir}/forgejo/conf/netoik_app.ini
%attr(644, root, root) %{_sysconfdir}/nginx/conf.d/git.netoik.io.conf
%dir %attr(755, root, root) %{_sysconfdir}/gitea
%attr(640, root, -) %{_sysconfdir}/gitea/app.ini
%attr(644, root, root) %{_unitdir}/gitea.service
%attr(644, root, root) %{_unitdir}/actrunner@.service
%dir %attr(755, root, root) %{_sharedstatedir}/actrunners
%dir %attr(755, root, root) %{_unitdir}/forgejo.service.d
%attr(644, root, root) %{_unitdir}/forgejo.service.d/forgejo.conf
%changelog
%autochangelog