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

61 lines
2.0 KiB
Bash
Raw Normal View History

2023-04-08 14:21:14 -07:00
#!/usr/bin/env bash
2023-08-04 01:30:15 -07:00
trap 'exit 130' INT
2022-12-27 03:12:00 -08:00
while true
do
2023-04-18 18:50:09 -07:00
read -r -p "Would you like to update Gitea? [Y/n] " input
2022-12-27 03:12:00 -08:00
case $input in
[yY][eE][sS]|[yY])
break
;;
[nN][oO]|[nN])
break
;;
*)
echo "That wasn't an option..."
;;
esac
done
2023-04-18 18:50:09 -07:00
set -b
2023-01-20 16:01:40 -08:00
ping -c1 "github.com" &>"/dev/null"
2023-04-18 18:50:09 -07:00
ping -c1 "api.github.com" &>"/dev/null"
ping -c1 "dl.gitea.io" &>"/dev/null"
ping -c1 "raw.githubusercontent.com" &>"/dev/null"
2023-01-20 16:01:40 -08:00
if [[ "${?}" -ne 0 ]]; then
2023-04-18 18:50:09 -07:00
echo "I am unable to access one of the necessary domains that are needed to continue this Install."
2023-01-20 16:01:40 -08:00
elif [[ "${#args[@]}" -eq 0 ]]; then
2023-04-18 18:50:09 -07:00
# Check if curl is installed
if [ ! -x /usr/bin/curl ] ; then
CURL_NOT_EXIST=1
apt install -y curl
else
CURL_NOT_EXIST=0
fi
VER=$(curl --silent "https://api.github.com/repos/go-gitea/gitea/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | sed 's|[v,]||g' )
2022-12-27 03:12:00 -08:00
sudo systemctl stop gitea
2023-04-18 18:50:09 -07:00
if [ -n "$(uname -a | grep i386)" ]; then
curl -fsSL -o "/tmp/gitea" "https://dl.gitea.io/gitea/$VER/gitea-$VER-linux-386"
fi
if [ -n "$(uname -a | grep x86_64)" ]; then
curl -fsSL -o "/tmp/gitea" "https://dl.gitea.io/gitea/$VER/gitea-$VER-linux-amd64"
fi
if [ -n "$(uname -a | grep armv6l)" ]; then
curl -fsSL -o "/tmp/gitea" "https://dl.gitea.io/gitea/$VER/gitea-$VER-linux-arm-6"
2023-01-20 16:01:40 -08:00
fi
2022-12-27 03:12:00 -08:00
2023-04-18 18:50:09 -07:00
if [ -n "$(uname -a | grep armv7l)" ]; then
curl -fsSL -o "/tmp/gitea" "https://dl.gitea.io/gitea/$VER/gitea-$VER-linux-arm-7"
fi
sudo mv /tmp/gitea /usr/local/bin
sudo chmod +x /usr/local/bin/gitea
2023-04-30 10:39:29 -07:00
sudo chown -R git:git /var/lib/gitea
sudo chmod -R 750 /var/lib/gitea
2023-04-18 18:50:09 -07:00
sudo chown root:git /etc/gitea
sudo systemctl start gitea
sudo ufw allow 3000
echo -e "=================================================================="
2023-04-30 10:39:29 -07:00
echo "Gitea has been updated!!"
2023-04-18 18:50:09 -07:00
echo -e "=================================================================="
fi