Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3048ea2716 | |||
| d04bdce2f7 | |||
| b91099579e | |||
| 729b4bdd6e | |||
| f193f5a305 | |||
| 682d4bc35c |
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user