feat: add actrunners
This commit is contained in:
@@ -10,7 +10,7 @@ URL: https://git.netoik.io/samuel/%(make name)
|
||||
Source0: %{name}-%{version}.tar.gz
|
||||
Buildarch: %(make build_arch)
|
||||
BuildRequires: make
|
||||
Requires: netoik-db git
|
||||
Requires: netoik-db netoik-cache git
|
||||
|
||||
%description
|
||||
Install the Git UI server called Gitea.
|
||||
@@ -22,6 +22,51 @@ 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
|
||||
|
||||
# Create gitea user
|
||||
useradd --system --create-home --bade-dir %{_sharedstatedir} gitea
|
||||
runuser --user gitea -- mkdir --parents %{_sharedstatedir}/gitea/{data,custom}
|
||||
|
||||
# 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 $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
|
||||
|
||||
# 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
|
||||
fi
|
||||
|
||||
%files
|
||||
%dir %attr(755, root, root) %{_sysconfdir}/gitea
|
||||
@@ -30,7 +75,7 @@ Install the Git UI server called Gitea.
|
||||
%attr(644, root, root) %{_unitdir}/gitea.service
|
||||
%attr(644, root, root) %{_unitdir}/actrunner@.service
|
||||
|
||||
%dir %attr(755, root, root) /opt/actrunners
|
||||
%dir %attr(755, root, root) %{_shared_statedir}/actrunners
|
||||
|
||||
%changelog
|
||||
%autochangelog
|
||||
|
||||
Reference in New Issue
Block a user