Skip to content

Instantly share code, notes, and snippets.

@jniltinho
Last active August 9, 2024 22:53
Show Gist options
  • Save jniltinho/bf31011d19fc5570be53db77d1114a7e to your computer and use it in GitHub Desktop.
Save jniltinho/bf31011d19fc5570be53db77d1114a7e to your computer and use it in GitHub Desktop.
Install Gitea Ubuntu
#!/bin/bash
#
# https://docs.gitea.com/
# https://docs.gitea.com/usage/actions/act-runner
# https://dl.gitea.com/gitea/
# https://dl.gitea.com/act_runner/
# https://docs.gitea.com/administration/reverse-proxies
# https://www.rosehosting.com/blog/how-to-install-gitea-on-ubuntu-22-04/
# https://hostnextra.com/learn/tutorials/how-to-install-gitea-on-ubuntu
# https://gist.github.com/MitchRatquest/dadc9484e07a627fa73b1c7bbcf609f4
# https://gist.github.com/typebrook/08ffabbe92457acc7117a7dca8619d40
VERSION=1.22.1
apt update && apt upgrade
apt install mariadb-server
cat <<EOF > create_db.sql
CREATE DATABASE gitea;
GRANT ALL PRIVILEGES ON gitea.* to 'gitea'@'localhost' IDENTIFIED BY 'Strong-Password';
FLUSH PRIVILEGES;
EOF
mysql -u root -p < create_db.sql
adduser --system --shell /bin/bash --group --disabled-password --home /home/git git
wget https://dl.gitea.com/gitea/$VERSION/gitea-$VERSION-linux-amd64 -O /usr/local/bin/gitea
chmod +x /usr/local/bin/gitea
mkdir -p /etc/gitea /home/git/gitea/{custom,data,indexers,public,log}
chown git:git /etc/gitea /home/git/gitea/{custom,data,indexers,public,log}
chmod 750 /home/git/gitea/{data,indexers,log}
chmod 770 /etc/gitea
cat <<EOF > /etc/systemd/system/gitea.service
[Unit]
Description=Gitea
After=syslog.target
After=network.target
[Service]
RestartSec=3s
Type=simple
User=git
Group=git
WorkingDirectory=/home/git/gitea/
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/home/git/gitea
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload && systemctl enable gitea && systemctl start gitea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment