thelinuxlist/scripts/gogsinstall.sh

41 lines
1.6 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 -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
tar xvf linux_amd64.tar.gz
sudo apt install git -y
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 wget -O /etc/systemd/system/gogs.service https://git.oldgate.org/Sophia/thelinuxlist/raw/branch/main/systemd/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
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 "=================================================================="