Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3048ea2716 | |||
| d04bdce2f7 | |||
| b91099579e | |||
| 729b4bdd6e |
@@ -22,6 +22,14 @@ Install the Git server called Gitea.
|
|||||||
%make_install
|
%make_install
|
||||||
|
|
||||||
%post
|
%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
|
# Download and install gitea binary
|
||||||
export ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
|
export ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
|
||||||
export GITEA_BINARY=gitea-1.25.5-linux-$ARCH
|
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
|
mv %{_sysconfdir}/gitea/.app.ini.new %{_sysconfdir}/gitea/app.ini
|
||||||
chown root:gitea %{_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
|
# 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 -- 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
|
runuser --user=gitea -- mv %{_tmppath}/gitea_images/* %{_sharedstatedir}/gitea/custom/public/assets/img
|
||||||
rm --recursive %{_tmppath}/gitea_images
|
rm --recursive %{_tmppath}/gitea_images
|
||||||
@@ -58,6 +58,8 @@ rm --recursive %{_tmppath}/gitea_images
|
|||||||
# Create postgres user and db
|
# Create postgres user and db
|
||||||
if ! runuser --user=postgres -- psql --quiet --tuples-only --command='\du' | grep --quiet gitea; then
|
if ! runuser --user=postgres -- psql --quiet --tuples-only --command='\du' | grep --quiet gitea; then
|
||||||
runuser --user=postgres -- createuser gitea
|
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
|
runuser --user=postgres -- createdb --owner=gitea gitea
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -95,13 +97,27 @@ systemctl reenable gitea.service
|
|||||||
systemctl restart gitea.service nginx.service
|
systemctl restart gitea.service nginx.service
|
||||||
|
|
||||||
%postun
|
%postun
|
||||||
# If removing, delete users and db
|
# If uninstalling, then delete users and db
|
||||||
if [ $1 == 0 ]; then
|
if [ $1 == 0 ]; then
|
||||||
userdel --force --remove gitea
|
# Remove gitea user if existing
|
||||||
runuser --user=postgres -- psql --command='DROP DATABASE gitea; DROP USER gitea;'
|
if id gitea >/dev/null 2>&1; then
|
||||||
for i in $(seq 1 4); then
|
userdel --force --remove gitea
|
||||||
userdel --force --remove actrunner$i
|
fi
|
||||||
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
|
fi
|
||||||
|
|
||||||
%files
|
%files
|
||||||
|
|||||||
Reference in New Issue
Block a user