Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4d85b2a212 | |||
| 3048ea2716 | |||
| d04bdce2f7 | |||
| b91099579e | |||
| 729b4bdd6e | |||
| f193f5a305 | |||
| 682d4bc35c |
@@ -22,16 +22,25 @@ 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
|
||||||
wget --directory-prefix %{_tmppath} https://dl.gitea.com/gitea/1.25.5/$GITEA_BINARY
|
cd %{_tmppath}
|
||||||
wget --directory-prefix %{_tmppath} https://dl.gitea.com/gitea/1.25.5/$GITEA_BINARY.asc
|
wget --output-document $GITEA_BINARY https://dl.gitea.com/gitea/1.25.5/$GITEA_BINARY
|
||||||
|
wget --output-document $GITEA_BINARY.asc %{_tmppath} https://dl.gitea.com/gitea/1.25.5/$GITEA_BINARY.asc
|
||||||
gpg --keyserver hkps://keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2
|
gpg --keyserver hkps://keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2
|
||||||
gpg --verify %{_tmppath}/$GITEA_BINARY.asc %{_tmppath}/$GITEA_BINARY
|
gpg --verify $GITEA_BINARY.asc $GITEA_BINARY
|
||||||
rm %{_tmppath}/$GITEA_BINARY.asc
|
rm $GITEA_BINARY.asc
|
||||||
chmod 755 %{_tmppath}/$GITEA_BINARY
|
chmod 755 $GITEA_BINARY
|
||||||
mv %{_tmppath}/$GITEA_BINARY.asc %{_sbindir}/gitea
|
mv $GITEA_BINARY %{_sbindir}/gitea
|
||||||
|
|
||||||
# Replace secrets in app.ini
|
# Replace secrets in app.ini
|
||||||
export INTERNAL_TOKEN=$(runuser --user=gitea -- gitea generate secret INTERNAL_TOKEN)
|
export INTERNAL_TOKEN=$(runuser --user=gitea -- gitea generate secret INTERNAL_TOKEN)
|
||||||
@@ -41,23 +50,18 @@ 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
|
export GITEA_LUGIT_THEME=gitea-lugit-theme
|
||||||
runuser --user=gitea -- tar --extract --gzip --overwrite --directory=%{_sharedstatedir}/gitea/custom --file %{_tmppath}/gitea-lugit-theme.tar.gz
|
wget --output-document $GITEA_LUGIT_THEME.tar.gz 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
|
runuser --user=gitea -- mv %{_tmppath}/gitea_images/* %{_sharedstatedir}/gitea/custom/public/assets/img
|
||||||
rm --recursive %{_tmppath}/gitea_images
|
rm --recursive 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
|
||||||
|
|
||||||
@@ -69,13 +73,14 @@ fi
|
|||||||
|
|
||||||
# Download and install act_runner binary
|
# Download and install act_runner binary
|
||||||
export ACTRUNNER_BINARY=act_runner-0.3.0-linux-$ARCH
|
export ACTRUNNER_BINARY=act_runner-0.3.0-linux-$ARCH
|
||||||
wget --directory-prefix %{_tmppath} https://gitea.com/gitea/act_runner/releases/download/v0.3.0/$ACTRUNNER_BINARY.xz
|
wget --output-document $ACTRUNNER_BINARY.xz https://gitea.com/gitea/act_runner/releases/download/v0.3.0/$ACTRUNNER_BINARY.xz
|
||||||
wget --directory-prefix %{_tmppath} https://gitea.com/gitea/act_runner/releases/download/v0.3.0/$ACTRUNNER_BINARY.xz.sha256
|
wget --output-docutment $ACTRUNNER_BINARY.xz.sha256 https://gitea.com/gitea/act_runner/releases/download/v0.3.0/$ACTRUNNER_BINARY.xz.sha256
|
||||||
cat %{_tmppath}/$ACTRUNNER_BINARY.xz.sha256 | sha256sum --check --status
|
cat $ACTRUNNER_BINARY.xz.sha256 | sha256sum --check --status
|
||||||
unxz %{_tmppath}/$ACTRUNNER_BINARY.xz
|
unxz $ACTRUNNER_BINARY.xz
|
||||||
chmod 755 $ACTRUNNER_BINARY
|
chmod 755 $ACTRUNNER_BINARY
|
||||||
mv $ACTRUNNER_BINARY %{_sbindir}/act_runner
|
mv $ACTRUNNER_BINARY %{_sbindir}/act_runner
|
||||||
rm %{_tmppath}/$ACTRUNNER_BINARY.*
|
rm $ACTRUNNER_BINARY.xz
|
||||||
|
rm $ACTRUNNER_BINARY.xz.sha256
|
||||||
|
|
||||||
# Create 4 actrunner users
|
# Create 4 actrunner users
|
||||||
export ACTRUNNER_TOKEN=$(runuser --user=gitea -- gitea actions generate-token-runner --scope samuel)
|
export ACTRUNNER_TOKEN=$(runuser --user=gitea -- gitea actions generate-token-runner --scope samuel)
|
||||||
@@ -95,13 +100,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
|
||||||
|
# Remove gitea user if existing
|
||||||
|
if id gitea >/dev/null 2>&1; then
|
||||||
userdel --force --remove gitea
|
userdel --force --remove gitea
|
||||||
runuser --user=postgres -- psql --command='DROP DATABASE gitea; DROP USER gitea;'
|
fi
|
||||||
for i in $(seq 1 4); then
|
|
||||||
|
# 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
|
userdel --force --remove actrunner$i
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
%files
|
%files
|
||||||
@@ -115,6 +134,7 @@ fi
|
|||||||
|
|
||||||
%ghost %attr(755, root, root) %{_sbindir}/gitea
|
%ghost %attr(755, root, root) %{_sbindir}/gitea
|
||||||
%ghost %attr(755, root, root) %{_sbindir}/act_runner
|
%ghost %attr(755, root, root) %{_sbindir}/act_runner
|
||||||
|
%exclude %{_tmppath}/gitea_images/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
%autochangelog
|
%autochangelog
|
||||||
|
|||||||
Reference in New Issue
Block a user