wahrnehmungsanlass.de: Gemischtes Gehacktes in Blogform
Institut für nichtzielgerichtete Forschung und experimentelle Informatik

This little script does the following things:

  • add gitea user
  • make needed directories, adjust owner
  • download binary dist, make file executable
  • create gitea.service for systemd and enable/start it.
#!/bin/bash
#
# installgitea.sh
#
GVERSION='1.6.2'
#
set -e
if [[ `id -u` -ne 0 ]] ; then echo "ERROR: Please run this as root." ; exit 1 ; fi
#
# add user
#

adduser --system --shell /bin/bash --gecos 'Gitea' --group \
--disabled-login --home /var/lib/gitea gitea

#
# make dirs, adjust owner
#

mkdir -p /var/log/gitea
dpkg-statoverride --list "/var/log/gitea" >/dev/null \
|| dpkg-statoverride --add --force --quiet \
--update gitea adm 0750 /var/log/gitea
mkdir -p /var/lib/gitea
mkdir -p /etc/gitea/conf
chown -R gitea:gitea /var/lib/gitea
chown -R gitea:gitea /etc/gitea

#
# download binary
#

cd /usr/local/bin

wget https://dl.gitea.io/gitea/${GVERSION}/gitea-${GVERSION}-linux-amd64
chmod 755 gitea-${GVERSION}-linux-amd64
ln -s gitea-${GVERSION}-linux-amd64 gitea

#
# create service
#

cat >/etc/systemd/system/gitea.service <<__END_OF_FILE__
[Unit]
Description=Gitea (Git with a cup of tea)
Documentation=man:gitea(1)
# syslog is "socket activated"
#After=syslog.target
After=network.target
#After=mysqld.service
#After=postgresql.service
#After=memcached.service
#After=redis.service

[Service]
# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
###
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
Type=simple
User=gitea
Group=gitea
WorkingDirectory=/var/lib/gitea
ExecStart=/usr/local/bin/gitea web
Restart=always
RestartSec=10
Environment=USER=gitea HOME=/var/lib/gitea GITEA_WORK_DIR=/var/lib/gitea

[Install]
WantedBy=multi-user.target
__END_OF_FILE__

#
# tell systemd about it
#

systemctl enable gitea
systemctl restart gitea

After first run, edit app.ini:

vi /var/lib/gitea/custom/conf/app.ini
systemctl restart gitea.service

See also

https://git.T42.de/