This repository has been archived on 2024-03-20. You can view files and clone it, but cannot push or open issues or pull requests.
thelinuxlist/scripts/gogsinstall.sh

71 lines
2.2 KiB
Bash

#!/bin/bash
while true
do
read -r -p "Would you like to install Gogs? [Y/n] " input
case $input in
[yY][eE][sS]|[yY])
break
;;
[nN][oO]|[nN])
break
;;
*)
echo "That wasn't an option..."
;;
esac
done
sudo apt install wget git -y
GOGS_VER="0.12.10"
sudo wget -O linux_amd64.tar.gz https://dl.gogs.io/$GOGS_VER/gogs_"$GOGS_VER"_linux_amd64.tar.gz
sudo tar xvf linux_amd64.tar.gz
sudo adduser --system --shell /bin/bash --gecos 'Git Version Control' --group --disabled-password --home /home/git git
sudo mkdir /var/log/gogs
sudo chown -R git:git /var/log/gogs/
sudo echo "
[Unit]
Description=Gogs self-hosted Git service
After=syslog.target
After=network.target
After=mysql.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=git
Group=git
WorkingDirectory=/home/git
ExecStart=/home/git/gogs web
Restart=always
Environment=USER=git HOME=/home/git
# Some distributions may not support these hardening directives. If you cannot start the service due
# to an unknown option, comment out the ones not supported by your version of systemd.
ProtectSystem=full
PrivateDevices=yes
PrivateTmp=yes
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target
" >> /etc/systemd/system/gogs.service
sudo rsync -avz gogs/* /home/git/
sudo chown -R git:git /home/git/
sudo ufw allow 3000
sudo systemctl daemon-reload
sudo systemctl enable gogs
sudo systemctl start gogs
sudo rm -rf gogs linux_amd64.tar.gz
echo -e "=================================================================="
publicipaddress=$(curl -sS --connect-timeout 10 -m 60 https://ipv4.icanhazip.com/ || curl -sS --connect-timeout 10 -m 60 https://api.ipify.org )
intenalip=$(ip addr | grep -E -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -E -v "^127\.|^255\.|^0\." | head -n 1)
echo "Gogs Should be available at http://${intenalip}:3000"
echo "Or If you are using a VPS at http://${publicipaddress}:3000"
echo -e "=================================================================="