From 26ae0ff6fd5db8c756d0912de9170bc4b368352f Mon Sep 17 00:00:00 2001 From: samuel Date: Sun, 12 Apr 2026 10:40:51 +0200 Subject: [PATCH] fix: set unit with type notify --- .gitea/workflows/ci.yaml | 10 ++++------ Makefile | 5 +++-- files/sbin/gitea_web_notify | 12 ++++++++++++ files/systemd/gitea.service | 7 ++++--- netoik-git.spec | 2 ++ 5 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 files/sbin/gitea_web_notify diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 8f8e07e..31ec98f 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -9,12 +9,10 @@ jobs: lint_n_build: runs-on: self-hosted steps: - - name: Git checkout - uses: actions/checkout@v6 + - uses: actions/checkout@v6 with: fetch-depth: 0 fetch-tags: true - - name: Build tarball - run: make tarball - - name: Build rpm file - run: rpmbuild -ba "$(make name).spec" + - run: shellcheck files/sbin/netoik_web_notify + - run: make tarball + - run: rpmbuild -ba "$(make name).spec" diff --git a/Makefile b/Makefile index ee9ec0a..1580556 100644 --- a/Makefile +++ b/Makefile @@ -74,11 +74,12 @@ install: ## Install files into rpm dest (requires env var DESTDIR) printf "[CRITICAL] Missing env var DESTDIR\n[CRITICAL] This command is designed to be called by rpmbuild only!\n" 1>&2; \ exit 1; \ fi - install --mode=755 --directory $(DESTDIR)$(RPM_SYSCONFDIR)/nginx/conf.d $(DESTDIR)$(RPM_SYSCONFDIR)/gitea $(DESTDIR)$(RPM_UNITDIR) $(DESTDIR)$(RPM_TMPPATH)/gitea_images + install --mode=755 --directory $(DESTDIR)$(RPM_SYSCONFDIR)/nginx/conf.d $(DESTDIR)$(RPM_SYSCONFDIR)/gitea $(DESTDIR)$(RPM_UNITDIR) $(DESTDIR)$(RPM_TMPPATH)/gitea_images $(DESTDIR)$(RPM_SBINDIR) 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=644 --target-directory=$(DESTDIR)$(RPM_TMPPATH)/gitea_images files/img/* + install --mode=644 --target-directory=$(DESTDIR)$(RPM_TMPPATH)/gitea_images files/img/{favicon,logo}.{svg,png} + install --mode=755 --target-directory=$(DESTDIR)$(RPM_SBINDIR) files/sbin/gitea_web_notify .PHONY: upload upload: ## Upload rpm package to Gitea repository (requires env var PKG_TOKEN) diff --git a/files/sbin/gitea_web_notify b/files/sbin/gitea_web_notify new file mode 100644 index 0000000..cdbb069 --- /dev/null +++ b/files/sbin/gitea_web_notify @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# Display commands, exit on error and enable job control +set -xem + +gitea web & +until curl --fail --head http://localhost:3000 +do + sleep 1 +done +systemd-notify --ready +fg %1 diff --git a/files/systemd/gitea.service b/files/systemd/gitea.service index b38dc72..537495e 100644 --- a/files/systemd/gitea.service +++ b/files/systemd/gitea.service @@ -4,13 +4,14 @@ After=network.target postgresql.service valkey.service [Service] RestartSec=2s -Type=simple +Type=notify User=gitea Group=gitea WorkingDirectory=/var/lib/gitea/ -Environment=USER=gitea HOME=/var/lib/gitea GITEA_WORK_DIR=/var/lib/gitea -ExecStart=/usr/sbin/gitea web +Environment=GITEA_WORK_DIR=/var/lib/gitea +ExecStart=/usr/sbin/gitea_web_notify Restart=always +NotifyAccess=all [Install] WantedBy=multi-user.target diff --git a/netoik-git.spec b/netoik-git.spec index d119012..e77470b 100644 --- a/netoik-git.spec +++ b/netoik-git.spec @@ -148,5 +148,7 @@ fi %dir %attr(755, root, root) %{_tmppath}/gitea_images %attr(644, root, root) %{_tmppath}/gitea_images/{favicon,logo}.{png,svg} +%attr(755, root, root) %{_sbindir}/gitea_web_notify + %changelog %autochangelog