forked from Sophia/thelinuxlist
EOL this project :(
This commit is contained in:
@ -1,45 +1,70 @@
|
||||
#!/usr/bin/env bash
|
||||
trap 'exit 130' INT
|
||||
set -b
|
||||
ping -c1 "github.com" &>"/dev/null"
|
||||
ping -c1 "api.github.com" &>"/dev/null"
|
||||
ping -c1 "dl.gitea.io" &>"/dev/null"
|
||||
ping -c1 "raw.githubusercontent.com" &>"/dev/null"
|
||||
if [[ "${?}" -ne 0 ]]; then
|
||||
echo "I am unable to access one of the necessary domains that are needed to continue this Install."
|
||||
elif [[ "${#args[@]}" -eq 0 ]]; then
|
||||
# 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' )
|
||||
sudo systemctl stop gitea
|
||||
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
|
||||
# Function to check network connectivity
|
||||
check_connectivity() {
|
||||
echo "Checking necessary domains for connectivity..."
|
||||
for domain in "github.com" "api.github.com" "dl.gitea.io" "raw.githubusercontent.com"; do
|
||||
if ! ping -c1 "$domain" &>"/dev/null"; then
|
||||
echo "Unable to access $domain. Update cannot proceed."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if [ -n "$(uname -a | grep armv6l)" ]; then
|
||||
curl -fsSL -o "/tmp/gitea" "https://dl.gitea.io/gitea/$VER/gitea-$VER-linux-arm-6"
|
||||
fi
|
||||
# Function to perform the update
|
||||
update_gitea() {
|
||||
echo "Updating Gitea..."
|
||||
|
||||
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
|
||||
sudo chown -R git:git /var/lib/gitea
|
||||
sudo chmod -R 750 /var/lib/gitea
|
||||
sudo chown root:git /etc/gitea
|
||||
sudo systemctl start gitea
|
||||
sudo ufw allow 3000
|
||||
echo -e "=================================================================="
|
||||
echo "Gitea has been updated!!"
|
||||
echo -e "=================================================================="
|
||||
fi
|
||||
# Check if curl is installed
|
||||
if ! command -v curl &>/dev/null; then
|
||||
echo "Installing curl..."
|
||||
sudo apt install -y curl || { echo "Failed to install curl. Exiting."; exit 1; }
|
||||
fi
|
||||
|
||||
# Get latest Gitea version
|
||||
VER=$(curl --silent "https://api.github.com/repos/go-gitea/gitea/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | sed 's|[v,]||g')
|
||||
|
||||
# Determine architecture
|
||||
case "$(uname -m)" in
|
||||
i386)
|
||||
arch="386"
|
||||
;;
|
||||
x86_64)
|
||||
arch="amd64"
|
||||
;;
|
||||
armv6l)
|
||||
arch="arm-6"
|
||||
;;
|
||||
armv7l)
|
||||
arch="arm-7"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported architecture"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Download and install Gitea binary
|
||||
gitea_url="https://dl.gitea.io/gitea/$VER/gitea-$VER-linux-$arch"
|
||||
echo "Downloading Gitea from: $gitea_url"
|
||||
sudo curl -fsSL -o "/tmp/gitea" "$gitea_url"
|
||||
sudo mv /tmp/gitea /usr/local/bin
|
||||
sudo chmod +x /usr/local/bin/gitea
|
||||
|
||||
# Restart Gitea service
|
||||
echo "Restarting Gitea service..."
|
||||
sudo systemctl restart gitea
|
||||
|
||||
# Allow port through firewall
|
||||
echo "Allowing port 3000 through firewall..."
|
||||
sudo ufw allow 3000
|
||||
|
||||
echo "Gitea has been updated successfully!"
|
||||
}
|
||||
|
||||
# Main script
|
||||
# Automate confirmation by assuming yes to the prompt
|
||||
check_connectivity
|
||||
update_gitea
|
||||
|
||||
exit 0
|
||||
|
Reference in New Issue
Block a user