2022-10-21 02:59:13 -07:00
|
|
|
#!/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
|
2022-10-21 03:05:17 -07:00
|
|
|
|
2023-01-19 20:52:52 -08:00
|
|
|
sudo apt install wget git -y
|
2022-10-21 03:16:07 -07:00
|
|
|
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
|
2023-01-19 20:52:52 -08:00
|
|
|
sudo tar xvf linux_amd64.tar.gz
|
2022-10-21 03:02:15 -07:00
|
|
|
sudo adduser --system --shell /bin/bash --gecos 'Git Version Control' --group --disabled-password --home /home/git git
|
2022-10-21 02:59:13 -07:00
|
|
|
sudo mkdir /var/log/gogs
|
|
|
|
sudo chown -R git:git /var/log/gogs/
|
2023-01-30 09:05:00 -08:00
|
|
|
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
|
2022-10-21 02:59:13 -07:00
|
|
|
sudo rsync -avz gogs/* /home/git/
|
|
|
|
sudo chown -R git:git /home/git/
|
2022-10-21 03:00:43 -07:00
|
|
|
sudo ufw allow 3000
|
2022-10-21 02:59:13 -07:00
|
|
|
sudo systemctl daemon-reload
|
|
|
|
sudo systemctl enable gogs
|
|
|
|
sudo systemctl start gogs
|
2023-01-19 20:52:52 -08:00
|
|
|
sudo rm -rf gogs linux_amd64.tar.gz
|
2022-10-21 02:59:13 -07:00
|
|
|
|
|
|
|
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 "=================================================================="
|