forked from Sophia/thelinuxlist
EOL this project :(
This commit is contained in:
@ -1,73 +1,124 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
trap 'exit 130' INT
|
||||
while true
|
||||
do
|
||||
read -r -p "Would you like to install Gitea? [Y/n] " input
|
||||
|
||||
case $input in
|
||||
|
||||
# Function to prompt user for installation
|
||||
prompt_installation() {
|
||||
while true; do
|
||||
read -r -p "Would you like to install Gitea? [Y/n] " input
|
||||
|
||||
case $input in
|
||||
[yY][eE][sS]|[yY])
|
||||
break
|
||||
;;
|
||||
return 0
|
||||
;;
|
||||
[nN][oO]|[nN])
|
||||
break
|
||||
;;
|
||||
return 1
|
||||
;;
|
||||
*)
|
||||
echo "That wasn't an option..."
|
||||
;;
|
||||
esac
|
||||
done
|
||||
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
|
||||
echo "That wasn't an option..."
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# Function to check if required domains are accessible
|
||||
check_domains() {
|
||||
echo "Checking necessary domains..."
|
||||
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. Installation cannot proceed."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Function to install Gitea
|
||||
install_gitea() {
|
||||
echo "Installing Gitea..."
|
||||
|
||||
# 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')
|
||||
|
||||
# Install git
|
||||
echo "Installing git..."
|
||||
sudo apt-get install git -y || { echo "Failed to install git. Exiting."; exit 1; }
|
||||
|
||||
# Create git user
|
||||
echo "Creating git user..."
|
||||
sudo adduser --system --shell /bin/bash --gecos 'Git Version Control' --group --disabled-password --home /home/git git
|
||||
|
||||
# Download and install Gitea binary
|
||||
echo "Downloading Gitea binary..."
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
# Create necessary directories and files
|
||||
echo "Setting up directories and files..."
|
||||
sudo mkdir -p /var/lib/gitea/{custom,data,log}
|
||||
sudo chown -R git:git /var/lib/gitea
|
||||
sudo chmod -R 750 /var/lib/gitea
|
||||
sudo mkdir -p /etc/gitea
|
||||
sudo chown root:git /etc/gitea
|
||||
sudo chmod 770 /etc/gitea
|
||||
|
||||
# Configure systemd service
|
||||
echo "Configuring systemd service..."
|
||||
sudo curl -fsSL -o /etc/systemd/system/gitea.service https://raw.githubusercontent.com/go-gitea/gitea/master/contrib/systemd/gitea.service
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now gitea
|
||||
|
||||
# Allow port through firewall
|
||||
echo "Allowing port 3000 through firewall..."
|
||||
sudo ufw allow 3000
|
||||
|
||||
# Get public and internal IP addresses
|
||||
public_ip=$(curl -sS --connect-timeout 10 -m 60 https://ipv4.icanhazip.com/ || curl -sS --connect-timeout 10 -m 60 https://api.ipify.org )
|
||||
internal_ip=$(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)
|
||||
|
||||
# Output installation information
|
||||
echo -e "=================================================================="
|
||||
echo "Gitea has been installed successfully!"
|
||||
echo "The Gitea web interface should be available at:"
|
||||
echo "http://$internal_ip:3000"
|
||||
echo "Or, if you are using a VPS, at:"
|
||||
echo "http://$public_ip:3000"
|
||||
echo "=================================================================="
|
||||
}
|
||||
|
||||
# Main script
|
||||
if prompt_installation; then
|
||||
check_domains
|
||||
install_gitea
|
||||
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
|
||||
sudo apt-get install git -y
|
||||
sudo adduser --system --shell /bin/bash --gecos 'Git Version Control' --group --disabled-password --home /home/git git
|
||||
if [ -n "$(uname -a | grep i386)" ]; then
|
||||
curl -fsSL -o "/tmp/gitea" "https://dl.gitea.io/gitea/$VER/gitea-$VER-linux-386"
|
||||
echo "Gitea installation aborted."
|
||||
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"
|
||||
fi
|
||||
|
||||
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 mkdir -p /var/lib/gitea/{custom,data,log}
|
||||
sudo chown -R git:git /var/lib/gitea
|
||||
sudo chmod -R 750 /var/lib/gitea
|
||||
sudo mkdir /etc/gitea
|
||||
sudo chown root:git /etc/gitea
|
||||
sudo chmod 770 /etc/gitea
|
||||
curl -fsSL -o /etc/systemd/system/gitea.service https://raw.githubusercontent.com/go-gitea/gitea/master/contrib/systemd/gitea.service
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now gitea
|
||||
sudo systemctl start gitea
|
||||
sudo ufw allow 3000
|
||||
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 "Gitea Should be available at http://${intenalip}:3000"
|
||||
echo "Or If you are using a VPS at http://${publicipaddress}:3000"
|
||||
echo -e "=================================================================="
|
||||
fi
|
||||
exit 0
|
||||
|
Reference in New Issue
Block a user