fix: create gitea user in %pre
This commit is contained in:
@@ -21,6 +21,11 @@ Install the Git UI server called Gitea.
|
|||||||
%install
|
%install
|
||||||
%make_install
|
%make_install
|
||||||
|
|
||||||
|
%pre
|
||||||
|
# Create gitea user
|
||||||
|
useradd --system --create-home --bade-dir %{_sharedstatedir} gitea
|
||||||
|
runuser --user gitea -- mkdir --parents %{_sharedstatedir}/gitea/{data,custom}
|
||||||
|
|
||||||
%post
|
%post
|
||||||
# Download gitea bin and verify gpg signature
|
# Download gitea bin and verify gpg signature
|
||||||
wget --output-document %{_tmppath}/gitea "$GITEA_BIN_URL"
|
wget --output-document %{_tmppath}/gitea "$GITEA_BIN_URL"
|
||||||
@@ -31,10 +36,6 @@ mv %{_tmppath}/gitea %{_sbindir}
|
|||||||
chmod 755 %{_sbindir}/gitea
|
chmod 755 %{_sbindir}/gitea
|
||||||
rm %{_tmppath}/gitea.asc
|
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
|
# Generate internal token and secret key
|
||||||
INTERNAL_TOKEN="$(gitea generate secret INTERNAL_TOKEN)"
|
INTERNAL_TOKEN="$(gitea generate secret INTERNAL_TOKEN)"
|
||||||
SECRET_KEY="$(gitea generate secret SECRET_KEY)"
|
SECRET_KEY="$(gitea generate secret SECRET_KEY)"
|
||||||
@@ -43,6 +44,11 @@ mv %{_sysconfdir}/gitea/app.ini.new %{_sysconfdir}/gitea/app.ini
|
|||||||
chgrp gitea %{_sysconfdir}/gitea/app.ini
|
chgrp gitea %{_sysconfdir}/gitea/app.ini
|
||||||
chmod 640 %{_sysconfdir}/gitea/app.ini
|
chmod 640 %{_sysconfdir}/gitea/app.ini
|
||||||
|
|
||||||
|
# Start gitea service
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl reenable gitea.service
|
||||||
|
systemctl restart gitea.service
|
||||||
|
|
||||||
# Create actrunners
|
# Create actrunners
|
||||||
for i in $(seq 1 $GITEA_ACT_RUNNERS); do
|
for i in $(seq 1 $GITEA_ACT_RUNNERS); do
|
||||||
if ! id "actrunner$i"; then
|
if ! id "actrunner$i"; then
|
||||||
@@ -53,11 +59,6 @@ for i in $(seq 1 $GITEA_ACT_RUNNERS); do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Start gitea service
|
|
||||||
systemctl daemon-reload
|
|
||||||
systemctl reenable gitea.service
|
|
||||||
systemctl restart gitea.service
|
|
||||||
|
|
||||||
%preun
|
%preun
|
||||||
# Backup gitea data in case of problem
|
# Backup gitea data in case of problem
|
||||||
runuser --user gitea -- gitea dump --config %{_sysconfdir}/gitea/app.ini --tempdir %{_tmppath}
|
runuser --user gitea -- gitea dump --config %{_sysconfdir}/gitea/app.ini --tempdir %{_tmppath}
|
||||||
|
|||||||
Reference in New Issue
Block a user