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/giteainstall.sh

66 lines
2.1 KiB
Bash
Raw Normal View History

2022-10-18 21:38:54 -07:00
#!/bin/bash
2022-10-20 10:57:59 -07:00
while true
do
read -r -p "Would you like to install Gitea? [Y/n] " input
case $input in
[yY][eE][sS]|[yY])
break
;;
[nN][oO]|[nN])
break
;;
*)
2022-10-20 11:01:50 -07:00
echo "That wasn't an option..."
2022-10-20 10:57:59 -07:00
;;
esac
2022-10-19 01:40:21 -07:00
done
2023-01-20 16:01:40 -08:00
ping -c1 "github.com" &>"/dev/null"
if [[ "${?}" -ne 0 ]]; then
echo "I am unable to access Github.com, that is needed to continue this Install."
elif [[ "${#args[@]}" -eq 0 ]]; then
2023-02-22 18:14:05 -08:00
GITEA_VER="1.19"
2022-10-18 21:52:01 -07:00
sudo systemctl stop gitea
2022-10-21 02:33:25 -07:00
sudo apt-get install git -y
sudo wget -O /usr/local/bin/gitea https://github.com/go-gitea/gitea/releases/download/v"$GITEA_VER"/gitea-"$GITEA_VER"-linux-amd64
2022-10-18 21:38:54 -07:00
sudo chmod +x /usr/local/bin/gitea
sudo adduser --system --shell /bin/bash --gecos 'Git Version Control' --group --disabled-password --home /home/git git
sudo mkdir -p /var/lib/gitea/{custom,data,log}
sudo chown -R git:git /var/lib/gitea
sudo chmod -R 750 /var/lib/gitea
2022-10-18 21:38:54 -07:00
sudo mkdir -v /etc/gitea
sudo chown -R root:git /etc/gitea
sudo chmod -R 770 /etc/gitea
sudo echo "
[Unit]
Description=Gitea
After=syslog.target
After=network.target
[Service]
RestartSec=3s
Type=simple
User=git
Group=git
WorkingDirectory=/var/lib/gitea/
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
[Install]
WantedBy=multi-user.target
" >> /etc/systemd/system/gitea.service
2022-10-23 11:30:02 -07:00
sudo systemctl daemon-reload
2022-10-18 21:38:54 -07:00
sudo systemctl enable --now gitea
sudo systemctl start gitea
2023-01-16 20:41:13 -08:00
sudo ufw allow 3000
2022-10-19 01:40:21 -07:00
echo -e "=================================================================="
2022-10-19 02:01:13 -07:00
publicipaddress=$(curl -sS --connect-timeout 10 -m 60 https://ipv4.icanhazip.com/ || curl -sS --connect-timeout 10 -m 60 https://api.ipify.org )
2022-10-19 01:39:08 -07:00
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 "Gitea Should be available at http://${intenalip}:3000"
echo "Or If you are using a VPS at http://${publicipaddress}:3000"
2022-10-19 01:40:21 -07:00
echo -e "=================================================================="
2023-01-20 16:01:40 -08:00
fi