7 Commits

Author SHA1 Message Date
663cf89639 fix: user list command
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-03-03 02:38:33 +01:00
ee803e538b fix: config file rights
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-03-03 02:34:21 +01:00
7e971433a7 feat: create admin user
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-03-03 02:29:04 +01:00
641ac4adb6 fix: forgejo web command
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-03-03 01:34:18 +01:00
bb55579880 fix: usermod command syntax
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-03-03 01:28:21 +01:00
c4adafb535 fix: add folders in make instal
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-03-03 01:11:39 +01:00
c0de29a266 feat: replace gitea by forgejo 2026-03-03 01:09:48 +01:00
6 changed files with 43 additions and 103 deletions

View File

@@ -3,6 +3,7 @@ VERSION = $(shell git describe --abbrev=0)
RELEASE = $(shell git rev-parse --short HEAD)
REFERENCE = $(if $(GIT_REFERENCE),$(GIT_REFERENCE),$(shell git branch --show-current))
ARCH = noarch
OWNER = samuel
RPM_RPMDIR = $(shell rpm --eval '%{_rpmdir}')
RPM_SBINDIR = $(shell rpm --eval '%{_sbindir}')
@@ -16,26 +17,30 @@ RPM_BUILD_PATH = $(RPM_RPMDIR)/$(BUILD_ARCH)/$(NAME)-$(VERSION)-$(RELEASE).$(BUI
.PHONY: name
name:
@echo "$(NAME)"
@echo $(NAME)
.PHONY: version
version:
@echo "$(VERSION)"
@echo $(VERSION)
.PHONY: release
release:
@echo "$(RELEASE)"
@echo $(RELEASE)
.PHONY: arch
arch:
@echo "$(ARCH)"
@echo $(ARCH)
.PHONY: owner
owner:
@echo $(OWNER)
.PHONY: install
install:
install --mode=755 --directory $(DESTDIR)$(RPM_SYSCONFDIR)/gitea $(DESTDIR)$(RPM_SYSCONFDIR)/nginx/conf.d $(DESTDIR)$(RPM_UNITDIR) $(DESTDIR)$(RPM_SHAREDSTATEDIR)/actrunners
install --mode=755 --directory $(DESTDIR)$(RPM_SYSCONFDIR)/nginx/conf.d $(DESTDIR)$(RPM_SYSCONFDIR)/forgejo/conf $(DESTDIR)$(RPM_UNITDIR)/forgejo.service.d
install --mode=644 --target-directory=$(DESTDIR)$(RPM_SYSCONFDIR)/nginx/conf.d/ files/nginx/git.netoik.io.conf
install --mode=640 --target-directory=$(DESTDIR)$(RPM_SYSCONFDIR)/gitea files/gitea/app.ini
install --mode=644 --target-directory=$(DESTDIR)$(RPM_UNITDIR) files/systemd/gitea.service files/systemd/actrunner@.service
install --mode=660 --target-directory=$(DESTDIR)$(RPM_SYSCONFDIR)/forgejo/conf files/forgejo/netoik_app.ini
install --mode=644 --target-directory=$(DESTDIR)$(RPM_UNITDIR)/forgejo.service.d files/systemd/forgejo.conf
$(RPM_TARBALL_PATH): *
git archive --format=tar.gz \
@@ -49,6 +54,4 @@ tarball: $(RPM_TARBALL_PATH)
.PHONY: upload
upload:
curl --fail-with-body --upload-file "$(RPM_BUILD_PATH)" --user "$(GIT_PACKAGES_USERNAME):$(GIT_PACKAGES_TOKEN)" https://git.netoik.io/api/packages/$(GIT_PACKAGES_USERNAME)/rpm/upload
curl --fail-with-body --upload-file "$(RPM_BUILD_PATH)" --user "$(OWNER):$(GIT_PACKAGES_TOKEN)" https://git.netoik.io/api/packages/$(OWNER)/rpm/upload

View File

@@ -2,9 +2,9 @@
# See official doc here: https://docs.gitea.com/next/administration/config-cheat-sheet
APP_NAME = Netoïk Git Server
RUN_USER = gitea
RUN_USER = forgejo
RUN_MODE = prod
WORK_PATH = /var/lib/gitea
WORK_PATH = /var/lib/forgejo
[server]
DOMAIN = git.netoik.io
@@ -17,17 +17,11 @@ SSH_PORT = 22222
[database]
DB_TYPE = postgres
HOST = /run/postgresql
NAME = gitea
USER = gitea
NAME = forgejo
USER = forgejo
[security]
INSTALL_LOCK = true
SECRET_KEY = $SECRET_KEY
INTERNAL_TOKEN = $INTERNAL_TOKEN
[service]
DISABLE_REGISTRATION = true
[session]
PROVIDER = redis
PROVIDER_CONFIG = /run/valkey/valkey.sock

View File

@@ -1,17 +0,0 @@
[Unit]
Description=Gitea Actions runner #%i
Documentation=https://gitea.com/gitea/act_runner
After=network.target gitea.service
[Service]
ExecStartPre=/usr/bin/rpmdev-setuptree
ExecStart=/usr/local/bin/act_runner daemon
ExecReload=/bin/kill -s HUP $MAINPID
WorkingDirectory=/var/lib//actrunners/actrunner%i
TimeoutSec=0
RestartSec=10
Restart=always
User=actrunner%i
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,3 @@
[Service]
ExecStart=
ExecStart=/usr/bin/forgejo web --config /etc/forgejo/conf/netoik_app.ini

View File

@@ -1,15 +0,0 @@
[Unit]
Description=Gitea (Git with a cup of tea)
After=network.target postgresql.service valkey.service
[Service]
RestartSec=2s
Type=simple
User=gitea
Group=gitea
WorkingDirectory=/var/lib/gitea/
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
[Install]
WantedBy=multi-user.target

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,35 @@ 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
# Create admin user
if ! runuser --user=forgejo -- forgejo --config %{_sysconfdir}/forgejo/conf/netoik_app.ini admin user list | grep samuel; then
runuser --user=forgejo -- forgejo --config %{_sysconfdir}/forgejo/conf/netoik_app.ini admin user create --username samuel --email "samuel.campos@netoik.io" --admin --random-password --random-password-length 30 --fullname "Samuel Campos"
fi
# 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(660, 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