6 Commits

Author SHA1 Message Date
3048ea2716 fix: use postgres drop commands
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-06 09:24:18 +02:00
d04bdce2f7 fix: delete users only if exist
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-06 09:05:27 +02:00
b91099579e fix: syntax error in for
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-06 08:45:21 +02:00
729b4bdd6e fix: create gitea user first
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-04 08:24:51 +02:00
f193f5a305 fix: exclude images
Some checks failed
Continuous Delivery / build_n_upload (push) Has been cancelled
2026-04-04 08:13:34 +02:00
682d4bc35c fix: exclude tmp files 2026-04-04 08:00:25 +02:00

View File

@@ -22,6 +22,14 @@ Install the Git server called Gitea.
%make_install
%post
# Create gitea user
if ! id gitea >/dev/null 2>&1; then
useradd --base-dir %{_sharedstatedir} --create-home --shell $SHELL --system gitea
fi
runuser --user=gitea -- mkdir --parents %{_sharedstatedir}/gitea/{custom,data,log} %{_sharedstatedir}/gitea/custom/conf
runuser --user=gitea -- ln --symbolic --force %{_sysconfdir}/gitea/app.ini %{_sharedstatedir}/gitea/custom/conf/app.ini
usermod --groups postgres,valkey --append gitea
# Download and install gitea binary
export ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
export GITEA_BINARY=gitea-1.25.5-linux-$ARCH
@@ -41,16 +49,8 @@ envsubst < %{_sysconfdir}/gitea/app.ini > %{_sysconfdir}/gitea/.app.ini.new
mv %{_sysconfdir}/gitea/.app.ini.new %{_sysconfdir}/gitea/app.ini
chown root:gitea %{_sysconfdir}/gitea/app.ini
# Create gitea user
if ! id gitea >/dev/null 2>&1; then
useradd --base-dir %{_sharedstatedir} --create-home --shell $SHELL --system gitea
fi
runuser --user=gitea -- mkdir --parents %{_sharedstatedir}/gitea/{custom,data,log} %{_sharedstatedir}/gitea/custom/conf
runuser --user=gitea -- ln --symbolic --force %{_sysconfdir}/gitea/app.ini %{_sharedstatedir}/gitea/custom/conf/app.ini
usermod --groups postgres,valkey --append gitea
# Add lugit theme
wget -O %{_tmppath}/gitea-lugit-theme.tar.gz https://github.com/lucas-labs/gitea-lugit-theme/releases/download/v1.0.1/gitea-lugit-theme.tar.gz
wget --directory-prefix %{_tmppath} https://github.com/lucas-labs/gitea-lugit-theme/releases/download/v1.0.1/gitea-lugit-theme.tar.gz
runuser --user=gitea -- tar --extract --gzip --overwrite --directory=%{_sharedstatedir}/gitea/custom --file %{_tmppath}/gitea-lugit-theme.tar.gz
runuser --user=gitea -- mv %{_tmppath}/gitea_images/* %{_sharedstatedir}/gitea/custom/public/assets/img
rm --recursive %{_tmppath}/gitea_images
@@ -58,6 +58,8 @@ rm --recursive %{_tmppath}/gitea_images
# Create postgres user and db
if ! runuser --user=postgres -- psql --quiet --tuples-only --command='\du' | grep --quiet gitea; then
runuser --user=postgres -- createuser gitea
fi
if ! runuser --user=postgres -- psql --quiet --tuples-only --command='\l' | grep --quiet gitea; then
runuser --user=postgres -- createdb --owner=gitea gitea
fi
@@ -95,13 +97,27 @@ systemctl reenable gitea.service
systemctl restart gitea.service nginx.service
%postun
# If removing, delete users and db
# If uninstalling, then delete users and db
if [ $1 == 0 ]; then
# Remove gitea user if existing
if id gitea >/dev/null 2>&1; then
userdel --force --remove gitea
runuser --user=postgres -- psql --command='DROP DATABASE gitea; DROP USER gitea;'
for i in $(seq 1 4); then
fi
# Remove gitea database if existing
if runuser --user=postgres -- psql --quiet --tuples-only --command='\l' | grep --quiet gitea; then
runuser --user=postgres -- dropdb gitea
fi
if runuser --user=postgres -- psql --quiet --tuples-only --command='\du' | grep --quiet gitea; then
runuser --user=postgres -- dropuser gitea
fi
# Remove actrunner users if existing
for i in $(seq 1 4); do
if id actrunner$i >/dev/null 2>&1; then
userdel --force --remove actrunner$i
fi
done
fi
%files
@@ -115,6 +131,7 @@ fi
%ghost %attr(755, root, root) %{_sbindir}/gitea
%ghost %attr(755, root, root) %{_sbindir}/act_runner
%exclude %{_tmppath}/gitea_images/*
%changelog
%autochangelog