Skip to content

Instantly share code, notes, and snippets.

@Belval
Last active November 16, 2021 23:03
Show Gist options
  • Save Belval/cbdec05bca7907d70b156662dbd7c811 to your computer and use it in GitHub Desktop.
Save Belval/cbdec05bca7907d70b156662dbd7c811 to your computer and use it in GitHub Desktop.
A script to install gitea and run it as a service on Ubuntu
#!/bin/sh
mkdir gitea
cd gitea/
# Replace this with whatever version is relevant now.
wget https://dl.gitea.io/gitea/1.4.1/gitea-1.4.1-linux-amd64
# Same here
mv gitea-1.4.1-linux-amd64 gitea
# Make the file executable
sudo chmod +x gitea
# Create the user that will be running gitea. Please don't use root :(
sudo useradd -m git
# Create the service file and move it to the systemd folder
echo "
[Unit]
Description=Gitea service
After=network.target
[Service]
Type=simple
User=git
Group=git
ExecStart=/home/git/gitea
[Install]
WantedBy=multi-user.target
" > ./gitea.service
sudo mv ./gitea.service /etc/systemd/system/
# Send the executable to our newly created user
sudo mv gitea /home/git/
cd /home/git/
# Give him some permission over it
sudo chown git:git gitea
# Make sure it won't comeback to haunt us
sudo usermod -s /sbin/nologin git
# Activate the service and start it!
sudo systemctl daemon-reload
sudo systemctl start gitea.service
# Open port in firewall
sudo ufw allow 3000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment