|
|
|
@@ -22,15 +22,16 @@ Install the Git server called Gitea.
|
|
|
|
%make_install
|
|
|
|
%make_install
|
|
|
|
|
|
|
|
|
|
|
|
%post
|
|
|
|
%post
|
|
|
|
# Download and verify 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/')
|
|
|
|
wget -O %{_tmppath}/gitea https://dl.gitea.com/gitea/1.25.5/gitea-1.25.5-linux-$ARCH
|
|
|
|
export GITEA_BINARY=gitea-1.25.5-linux-$ARCH
|
|
|
|
wget -O %{_tmppath}/gitea.asc https://dl.gitea.com/gitea/1.25.5/gitea-1.25.5-linux-$ARCH.asc
|
|
|
|
wget --directory-prefix %{_tmppath} https://dl.gitea.com/gitea/1.25.5/$GITEA_BINARY
|
|
|
|
|
|
|
|
wget --directory-prefix %{_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.asc %{_tmppath}/gitea
|
|
|
|
gpg --verify %{_tmppath}/$GITEA_BINARY.asc %{_tmppath}/$GITEA_BINARY
|
|
|
|
rm %{_tmppath}/gitea.asc
|
|
|
|
rm %{_tmppath}/$GITEA_BINARY.asc
|
|
|
|
chmod 755 gitea
|
|
|
|
chmod 755 %{_tmppath}/$GITEA_BINARY
|
|
|
|
mv %{_tmppath}/gitea %{_sbindir}/gitea
|
|
|
|
mv %{_tmppath}/$GITEA_BINARY.asc %{_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,14 +42,16 @@ 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
|
|
|
|
# Create gitea user
|
|
|
|
useradd --base-dir %{_sharedstatedir} --create-home --shell $SHELL --system gitea
|
|
|
|
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 -- 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
|
|
|
|
runuser --user=gitea -- ln --symbolic --force %{_sysconfdir}/gitea/app.ini %{_sharedstatedir}/gitea/custom/conf/app.ini
|
|
|
|
usermod --groups postgres,valkey --append gitea
|
|
|
|
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 -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
|
|
|
|
runuser --user=gitea -- tar --extract --gzip --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
|
|
|
|
|
|
|
|
|
|
|
|
@@ -59,20 +62,46 @@ if ! runuser --user=postgres -- psql --quiet --tuples-only --command='\du' | gre
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Create admin user
|
|
|
|
# Create admin user
|
|
|
|
if ! runuser --user=gitea -- gitea admin user list | grep samuel; then
|
|
|
|
if ! runuser --user=gitea -- gitea admin user list | grep --quiet samuel; then
|
|
|
|
runuser --user=gitea -- gitea admin user create --username samuel --email "samuel.campos@netoik.io" --admin --random-password --random-password-length 30 --fullname "Samuel Campos"
|
|
|
|
runuser --user=gitea -- gitea admin user create --username samuel --email "samuel.campos@netoik.io" --admin --random-password --random-password-length 30 --fullname "Samuel Campos"
|
|
|
|
runuser --user=gitea -- gitea admin user must-change-password samuel
|
|
|
|
runuser --user=gitea -- gitea admin user must-change-password samuel
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Download and install act_runner binary
|
|
|
|
|
|
|
|
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 --directory-prefix %{_tmppath} https://gitea.com/gitea/act_runner/releases/download/v0.3.0/$ACTRUNNER_BINARY.xz.sha256
|
|
|
|
|
|
|
|
cat %{_tmppath}/$ACTRUNNER_BINARY.xz.sha256 | sha256sum --check --status
|
|
|
|
|
|
|
|
unxz %{_tmppath}/$ACTRUNNER_BINARY.xz
|
|
|
|
|
|
|
|
chmod 755 $ACTRUNNER_BINARY
|
|
|
|
|
|
|
|
mv $ACTRUNNER_BINARY %{_sbindir}/act_runner
|
|
|
|
|
|
|
|
rm %{_tmppath}/$ACTRUNNER_BINARY.*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Create 4 actrunner users
|
|
|
|
|
|
|
|
export ACTRUNNER_TOKEN=$(runuser --user=gitea -- gitea actions generate-token-runner --scope samuel)
|
|
|
|
|
|
|
|
for i in $(seq 1 4); do
|
|
|
|
|
|
|
|
if ! id actrunner$i >/dev/null 2>&1; then
|
|
|
|
|
|
|
|
useradd --base-dir %{_sharedstatedir} --create-home --shell $SHELL --system actrunner$i
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
runuser --user=actrunner$i -- rpmdev-setuptree
|
|
|
|
|
|
|
|
runuser --user=actrunner$i -- act_runner register --instance https://git.netoik.io --labels self-hosted --name actrunner$i --no-interactive --token $ACTRUNNER_TOKEN
|
|
|
|
|
|
|
|
systemctl reenable actrunner@$i.service
|
|
|
|
|
|
|
|
systemctl restart actrunner@$i.service
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
# Restart gitea and nginx services
|
|
|
|
# Restart gitea and nginx services
|
|
|
|
systemctl daemon-reload
|
|
|
|
systemctl daemon-reload
|
|
|
|
systemctl reenable gitea.service
|
|
|
|
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 [ $1 == 0 ]; then
|
|
|
|
if [ $1 == 0 ]; then
|
|
|
|
userdel --force --remove gitea
|
|
|
|
userdel --force --remove gitea
|
|
|
|
runuser --user=postgres -- psql --command='DROP DATABASE gitea; DROP USER gitea;'
|
|
|
|
runuser --user=postgres -- psql --command='DROP DATABASE gitea; DROP USER gitea;'
|
|
|
|
|
|
|
|
for i in $(seq 1 4); then
|
|
|
|
|
|
|
|
userdel --force --remove actrunner$i
|
|
|
|
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
%files
|
|
|
|
%files
|
|
|
|
@@ -82,8 +111,10 @@ fi
|
|
|
|
%attr(644, root, root) %{_sysconfdir}/nginx/conf.d/git.netoik.io.conf
|
|
|
|
%attr(644, root, root) %{_sysconfdir}/nginx/conf.d/git.netoik.io.conf
|
|
|
|
|
|
|
|
|
|
|
|
%attr(644, root, root) %{_unitdir}/gitea.service
|
|
|
|
%attr(644, root, root) %{_unitdir}/gitea.service
|
|
|
|
|
|
|
|
%attr(644, root, root) %{_unitdir}/actrunner@.service
|
|
|
|
|
|
|
|
|
|
|
|
%attr(755, root, root) %{_sbindir}/gitea
|
|
|
|
%ghost %attr(755, root, root) %{_sbindir}/gitea
|
|
|
|
|
|
|
|
%ghost %attr(755, root, root) %{_sbindir}/act_runner
|
|
|
|
|
|
|
|
|
|
|
|
%changelog
|
|
|
|
%changelog
|
|
|
|
%autochangelog
|
|
|
|
%autochangelog
|
|
|
|
|