Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7e971433a7 | |||
| 641ac4adb6 | |||
| bb55579880 | |||
| c4adafb535 | |||
| c0de29a266 | |||
| e19760d37e | |||
| 89837bef2b | |||
| 3334a877d7 | |||
| bdfe38f896 | |||
| de28f71901 | |||
| c313318eb0 | |||
| 13ed7bfcd8 |
33
Makefile
33
Makefile
@@ -2,7 +2,8 @@ NAME = netoik-git
|
||||
VERSION = $(shell git describe --abbrev=0)
|
||||
RELEASE = $(shell git rev-parse --short HEAD)
|
||||
REFERENCE = $(if $(GIT_REFERENCE),$(GIT_REFERENCE),$(shell git branch --show-current))
|
||||
BUILD_ARCH = noarch
|
||||
ARCH = noarch
|
||||
OWNER = samuel
|
||||
|
||||
RPM_RPMDIR = $(shell rpm --eval '%{_rpmdir}')
|
||||
RPM_SBINDIR = $(shell rpm --eval '%{_sbindir}')
|
||||
@@ -11,31 +12,35 @@ RPM_SHAREDSTATEDIR = $(shell rpm --eval '%{_sharedstatedir}')
|
||||
RPM_SYSCONFDIR = $(shell rpm --eval '%{_sysconfdir}')
|
||||
RPM_UNITDIR = $(shell rpm --eval '%{_unitdir}')
|
||||
|
||||
RPM_TARBALL_PATH = $(RPM_SOURCEDIR)/$(NAME)-$(VERSION).tar.gz
|
||||
RPM_TARBALL_PATH = $(RPM_SOURCEDIR)/$(NAME)-$(VERSION)-$(RELEASE).tar.gz
|
||||
RPM_BUILD_PATH = $(RPM_RPMDIR)/$(BUILD_ARCH)/$(NAME)-$(VERSION)-$(RELEASE).$(BUILD_ARCH).rpm
|
||||
|
||||
.PHONY: name
|
||||
name:
|
||||
@echo "$(NAME)"
|
||||
@echo $(NAME)
|
||||
|
||||
.PHONY: version
|
||||
version:
|
||||
@echo "$(VERSION)"
|
||||
@echo $(VERSION)
|
||||
|
||||
.PHONY: release
|
||||
release:
|
||||
@echo "$(RELEASE)"
|
||||
@echo $(RELEASE)
|
||||
|
||||
.PHONY: build_arch
|
||||
build_arch:
|
||||
@echo "$(BUILD_ARCH)"
|
||||
.PHONY: arch
|
||||
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=644 --target-directory=$(DESTDIR)$(RPM_SYSCONFDIR)/nginx/conf.d/ 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=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)/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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
3
files/systemd/forgejo.conf
Normal file
3
files/systemd/forgejo.conf
Normal file
@@ -0,0 +1,3 @@
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=/usr/bin/forgejo web --config /etc/forgejo/conf/netoik_app.ini
|
||||
@@ -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
|
||||
@@ -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}.tar.gz
|
||||
Buildarch: %(make build_arch)
|
||||
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,64 +22,35 @@ Install the Git UI server called Gitea.
|
||||
%make_install
|
||||
|
||||
%post
|
||||
# Download gitea bin and verify gpg signature
|
||||
wget --output-document %{_tmppath}/gitea "$GITEA_BIN_URL"
|
||||
wget --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
|
||||
|
||||
# Create gitea user
|
||||
useradd --system --create-home --bade-dir %{_sharedstatedir} gitea
|
||||
runuser --user gitea -- mkdir --parents %{_sharedstatedir}/gitea/{data,custom}
|
||||
# Add user forgejo to db groups
|
||||
usermod --groups postgres,valkey --append forgejo
|
||||
|
||||
# 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
|
||||
chmod 600 %{_sysconfdir}/gitea/app.ini
|
||||
|
||||
# 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"
|
||||
# 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
|
||||
done
|
||||
|
||||
# Start gitea service
|
||||
systemctl daemon-reload
|
||||
systemctl reenable gitea.service
|
||||
systemctl restart gitea.service
|
||||
|
||||
%preun
|
||||
# Backup gitea data in case of problem
|
||||
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
|
||||
# Create admin user
|
||||
if ! runuser --user forgejo -- forgejo --config %{_sysconfdir}/forgejo/conf/netoik_app.ini admin user list | grep $(make owner); 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 forgejo.service
|
||||
systemctl restart forgejo.service
|
||||
systemctl restart nginx.service
|
||||
|
||||
%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, gitea) %{_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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user