EOL this project :(
This commit is contained in:
parent
797b4d8de6
commit
0cc27e1896
|
@ -1,73 +1,124 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
trap 'exit 130' INT
|
trap 'exit 130' INT
|
||||||
while true
|
|
||||||
do
|
# Function to prompt user for installation
|
||||||
read -r -p "Would you like to install Gitea? [Y/n] " input
|
prompt_installation() {
|
||||||
|
while true; do
|
||||||
case $input in
|
read -r -p "Would you like to install Gitea? [Y/n] " input
|
||||||
|
|
||||||
|
case $input in
|
||||||
[yY][eE][sS]|[yY])
|
[yY][eE][sS]|[yY])
|
||||||
break
|
return 0
|
||||||
;;
|
;;
|
||||||
[nN][oO]|[nN])
|
[nN][oO]|[nN])
|
||||||
break
|
return 1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "That wasn't an option..."
|
echo "That wasn't an option..."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
set -b
|
}
|
||||||
ping -c1 "github.com" &>"/dev/null"
|
|
||||||
ping -c1 "api.github.com" &>"/dev/null"
|
# Function to check if required domains are accessible
|
||||||
ping -c1 "dl.gitea.io" &>"/dev/null"
|
check_domains() {
|
||||||
ping -c1 "raw.githubusercontent.com" &>"/dev/null"
|
echo "Checking necessary domains..."
|
||||||
if [[ "${?}" -ne 0 ]]; then
|
for domain in "github.com" "api.github.com" "dl.gitea.io" "raw.githubusercontent.com"; do
|
||||||
echo "I am unable to access one of the necessary domains that are needed to continue this Install."
|
if ! ping -c1 "$domain" &>"/dev/null"; then
|
||||||
elif [[ "${#args[@]}" -eq 0 ]]; then
|
echo "Unable to access $domain. Installation cannot proceed."
|
||||||
# Check if curl is installed
|
exit 1
|
||||||
if [ ! -x /usr/bin/curl ] ; then
|
fi
|
||||||
CURL_NOT_EXIST=1
|
done
|
||||||
apt install -y curl
|
}
|
||||||
|
|
||||||
|
# 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
|
else
|
||||||
CURL_NOT_EXIST=0
|
echo "Gitea installation aborted."
|
||||||
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"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$(uname -a | grep x86_64)" ]; then
|
exit 0
|
||||||
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
|
|
||||||
|
|
|
@ -1,32 +1,61 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
trap 'exit 130' INT
|
|
||||||
while true
|
# Function to prompt user for confirmation
|
||||||
do
|
prompt_confirmation() {
|
||||||
read -r -p "Would you like to uninstall Gitea? This is not reversible. [Y/n] " input
|
while true; do
|
||||||
|
read -r -p "Would you like to uninstall Gitea? This is not reversible. [Y/n] " input
|
||||||
case $input in
|
|
||||||
|
case $input in
|
||||||
[yY][eE][sS]|[yY])
|
[yY][eE][sS]|[yY])
|
||||||
break
|
return 0
|
||||||
;;
|
;;
|
||||||
[nN][oO]|[nN])
|
[nN][oO]|[nN])
|
||||||
break
|
return 1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "That wasn't an option..."
|
echo "That wasn't an option..."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
sudo systemctl stop gitea
|
}
|
||||||
sudo systemctl disable gitea
|
|
||||||
sudo rm -rf /etc/systemd/system/gitea.service
|
|
||||||
echo "Backing up Files"
|
|
||||||
tar -cvzf gitea.tar.gz /var/lib/gitea/ /etc/gitea
|
|
||||||
sudo rm -rf /home/git
|
|
||||||
sudo userdel git
|
|
||||||
sudo rm -rf /usr/local/bin/gitea
|
|
||||||
sudo rm -rf /var/lib/gitea/*
|
|
||||||
sudo rm -rf /etc/gitea
|
|
||||||
sudo ufw delete allow 3000
|
|
||||||
|
|
||||||
echo "Gitea has been uninstalled, and all files have are backed up in gitea.tar.gz, you can delete it at your discretion."
|
# Function to perform uninstallation
|
||||||
|
uninstall_gitea() {
|
||||||
|
echo "Stopping Gitea service..."
|
||||||
|
sudo systemctl stop gitea
|
||||||
|
|
||||||
|
echo "Disabling Gitea service..."
|
||||||
|
sudo systemctl disable gitea
|
||||||
|
|
||||||
|
echo "Removing Gitea service file..."
|
||||||
|
sudo rm -rf /etc/systemd/system/gitea.service
|
||||||
|
|
||||||
|
echo "Backing up files..."
|
||||||
|
timestamp=$(date +"%Y%m%d_%H%M%S")
|
||||||
|
tar -cvzf "gitea_backup_${timestamp}.tar.gz" /var/lib/gitea/ /etc/gitea || { echo "Failed to backup files. Exiting."; exit 1; }
|
||||||
|
|
||||||
|
echo "Removing Gitea user and home directory..."
|
||||||
|
sudo userdel -r git || { echo "Failed to delete Gitea user. Exiting."; exit 1; }
|
||||||
|
|
||||||
|
echo "Removing Gitea binary..."
|
||||||
|
sudo rm -rf /usr/local/bin/gitea
|
||||||
|
|
||||||
|
echo "Cleaning up Gitea data and configuration..."
|
||||||
|
sudo rm -rf /var/lib/gitea/* /etc/gitea
|
||||||
|
|
||||||
|
echo "Removing firewall rule for port 3000..."
|
||||||
|
sudo ufw delete allow 3000
|
||||||
|
|
||||||
|
echo "Gitea has been uninstalled, and all files have been backed up."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main script
|
||||||
|
trap 'exit 130' INT
|
||||||
|
|
||||||
|
if prompt_confirmation; then
|
||||||
|
uninstall_gitea
|
||||||
|
else
|
||||||
|
echo "Gitea uninstallation aborted."
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
|
@ -1,61 +1,95 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Trap Ctrl+C to exit gracefully
|
||||||
trap 'exit 130' INT
|
trap 'exit 130' INT
|
||||||
while true
|
|
||||||
do
|
# Function to prompt user for confirmation
|
||||||
read -r -p "Would you like to update Gitea? [Y/n] " input
|
prompt_confirmation() {
|
||||||
|
while true; do
|
||||||
case $input in
|
read -r -p "Would you like to update Gitea? [Y/n] " input
|
||||||
|
|
||||||
|
case $input in
|
||||||
[yY][eE][sS]|[yY])
|
[yY][eE][sS]|[yY])
|
||||||
break
|
return 0
|
||||||
;;
|
;;
|
||||||
[nN][oO]|[nN])
|
[nN][oO]|[nN])
|
||||||
break
|
return 1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "That wasn't an option..."
|
echo "That wasn't an option..."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
set -b
|
}
|
||||||
ping -c1 "github.com" &>"/dev/null"
|
|
||||||
ping -c1 "api.github.com" &>"/dev/null"
|
# Function to check network connectivity
|
||||||
ping -c1 "dl.gitea.io" &>"/dev/null"
|
check_connectivity() {
|
||||||
ping -c1 "raw.githubusercontent.com" &>"/dev/null"
|
echo "Checking necessary domains for connectivity..."
|
||||||
if [[ "${?}" -ne 0 ]]; then
|
for domain in "github.com" "api.github.com" "dl.gitea.io" "raw.githubusercontent.com"; do
|
||||||
echo "I am unable to access one of the necessary domains that are needed to continue this Install."
|
if ! ping -c1 "$domain" &>"/dev/null"; then
|
||||||
elif [[ "${#args[@]}" -eq 0 ]]; then
|
echo "Unable to access $domain. Update cannot proceed."
|
||||||
# Check if curl is installed
|
exit 1
|
||||||
if [ ! -x /usr/bin/curl ] ; then
|
fi
|
||||||
CURL_NOT_EXIST=1
|
done
|
||||||
apt install -y curl
|
}
|
||||||
|
|
||||||
|
# Function to perform the update
|
||||||
|
update_gitea() {
|
||||||
|
echo "Updating 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')
|
||||||
|
|
||||||
|
# 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
|
||||||
|
if prompt_confirmation; then
|
||||||
|
check_connectivity
|
||||||
|
update_gitea
|
||||||
else
|
else
|
||||||
CURL_NOT_EXIST=0
|
echo "Gitea update aborted."
|
||||||
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
|
fi
|
||||||
|
|
||||||
if [ -n "$(uname -a | grep x86_64)" ]; then
|
exit 0
|
||||||
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 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
|
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
while true
|
|
||||||
do
|
|
||||||
read -r -p "Would you like to uninstall Gitlab? This is not reversible. [Y/n] " input
|
|
||||||
|
|
||||||
case $input in
|
|
||||||
[yY][eE][sS]|[yY])
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
[nN][oO]|[nN])
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "That wasn't an option..."
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
sudo gitlab-ctl stop
|
|
||||||
sudo apt remove gitlab-ce -y
|
|
||||||
sudo apt update && apt upgrade -y
|
|
||||||
sudo ufw delete allow 443
|
|
||||||
sudo ufw delete allow 80
|
|
|
@ -1,44 +1,50 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
trap 'exit 130' INT
|
|
||||||
while true
|
# Confirmation prompt
|
||||||
do
|
while true; do
|
||||||
read -r -p "Would you like to install Go Language? [Y/n] " input
|
read -r -p "Would you like to install Go Language? [Y/n] " input
|
||||||
|
|
||||||
case $input in
|
case $input in
|
||||||
[yY][eE][sS]|[yY])
|
[yY][eE][sS]|[yY])
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
[nN][oO]|[nN])
|
[nN][oO]|[nN])
|
||||||
break
|
echo "Go installation aborted."
|
||||||
;;
|
exit 0
|
||||||
*)
|
;;
|
||||||
echo "That wasn't an option..."
|
*)
|
||||||
;;
|
echo "That wasn't an option..."
|
||||||
esac
|
;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check if curl is installed
|
# Check if curl is installed
|
||||||
if [ ! -x /usr/bin/curl ] ; then
|
if ! command -v curl &>/dev/null; then
|
||||||
CURL_NOT_EXIST=1
|
echo "curl is required but not installed. Installing curl..."
|
||||||
apt install -y curl
|
sudo apt update && sudo apt install -y curl
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get latest Go version
|
||||||
|
if [ "$(uname -m)" == "x86_64" ]; then
|
||||||
|
ARCH="amd64"
|
||||||
|
elif [ "$(uname -m)" == "armv6l" ]; then
|
||||||
|
ARCH="armv6l"
|
||||||
else
|
else
|
||||||
CURL_NOT_EXIST=0
|
ARCH="386"
|
||||||
fi
|
fi
|
||||||
apt remove golang -y
|
|
||||||
rm -rf /tmp/go/
|
GO_VERSION=$(curl -sSL https://golang.org/dl/?mode=json | grep -oP '"version":"\K[^"]+' | head -n1)
|
||||||
mkdir /tmp/go/
|
GO_URL="https://golang.org/dl/go$GO_VERSION.linux-$ARCH.tar.gz"
|
||||||
cd /tmp/go/
|
|
||||||
VER=$(curl --silent "https://go.dev/dl/?mode=json" | grep '"version":' | sed -E 's/.*"([^"]+)".*/\1/' | sed 's|[v,]||g' | head -1)
|
# Install Go
|
||||||
if [ -n "$(uname -a | grep x86_64)" ]; then
|
echo "Downloading and installing Go $GO_VERSION..."
|
||||||
curl -fsSL -o "/tmp/go/"$VER".linux-amd64.tar.gz" "https://go.dev/dl/"$VER".linux-amd64.tar.gz"
|
curl -fsSL -o "/tmp/go.tar.gz" "$GO_URL"
|
||||||
fi
|
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf /tmp/go.tar.gz
|
||||||
if [ -n "$(uname -a | grep armv6l)" ]; then
|
rm -f /tmp/go.tar.gz
|
||||||
curl -fsSL -o "/tmp/go/"$VER".linux-armv6l.tar.gz" "https://go.dev/dl/"$VER".linux-armv6l.tar.gz"
|
|
||||||
fi
|
# Update PATH
|
||||||
if [ -n "$(uname -a | grep i386)" ]; then
|
echo "Updating PATH..."
|
||||||
curl -fsSL -o "/tmp/go/"$VER".linux-386.tar.gz" "https://go.dev/dl/"$VER".linux-386.tar.gz"
|
|
||||||
fi
|
|
||||||
rm -rf /usr/local/go && tar -C /usr/local -xzf *.tar.gz
|
|
||||||
chmod +x /usr/local/go/bin/go
|
|
||||||
export PATH=$PATH:/usr/local/go/bin
|
export PATH=$PATH:/usr/local/go/bin
|
||||||
cd ~
|
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc # Add to .bashrc for persistent PATH
|
||||||
|
|
||||||
|
echo "Go $GO_VERSION has been successfully installed."
|
||||||
|
|
|
@ -1,49 +1,64 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Trap INT signal to ensure clean exits
|
||||||
trap 'exit 130' INT
|
trap 'exit 130' INT
|
||||||
while true
|
|
||||||
do
|
# Confirmation prompt
|
||||||
read -r -p "Would you like to install Hugo? [Y/n] " input
|
while true; do
|
||||||
|
read -r -p "Would you like to install Hugo? [Y/n] " input
|
||||||
case $input in
|
|
||||||
[yY][eE][sS]|[yY])
|
case $input in
|
||||||
break
|
[yY][eE][sS]|[yY])
|
||||||
;;
|
break
|
||||||
[nN][oO]|[nN])
|
;;
|
||||||
break
|
[nN][oO]|[nN])
|
||||||
;;
|
echo "Hugo installation aborted."
|
||||||
*)
|
exit 0
|
||||||
echo "That wasn't an option..."
|
;;
|
||||||
;;
|
*)
|
||||||
esac
|
echo "That wasn't an option..."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
if [ ! -x /usr/bin/curl ] ; then
|
|
||||||
CURL_NOT_EXIST=1
|
# Check for dependencies and install if needed
|
||||||
apt install -y curl
|
if ! command -v curl &>/dev/null; then
|
||||||
else
|
echo "Installing curl..."
|
||||||
CURL_NOT_EXIST=0
|
sudo apt update && sudo apt install -y curl || { echo "Failed to install curl. Exiting."; exit 1; }
|
||||||
fi
|
|
||||||
apt remove golang -y
|
|
||||||
apt autoremove -y
|
|
||||||
wget -O goinstall.sh https://sop.wtf/sh/u/goinstall && bash goinstall.sh
|
|
||||||
rm -rf /tmp/hugo/
|
|
||||||
mkdir /tmp/hugo/
|
|
||||||
VER=$(curl --silent "https://api.github.com/repos/gohugoio/hugo/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | sed 's|[v,]||g' )
|
|
||||||
if [ -n "$(uname -a | grep x86_64)" ]; then
|
|
||||||
curl -fsSL -o "/tmp/hugo/hugo_extended_"$VER"_linux-amd64.tar.gz" "https://github.com/gohugoio/hugo/releases/download/v$VER/hugo_extended_"$VER"_linux-amd64.tar.gz"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$(uname -a | grep armv6l)" ]; then
|
|
||||||
curl -fsSL -o "/tmp/hugo/hugo_extended_"$VER"-arm64.tar.gz" "https://github.com/gohugoio/hugo/releases/download/v$VER/hugo_extended_"$VER"-arm64.tar.gz"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$(uname -a | grep armv7l)" ]; then
|
# Remove unused dependencies (optional)
|
||||||
curl -fsSL -o "/tmp/hugo/hugo_"$VER"-arm.tar.gz" "https://github.com/gohugoio/hugo/releases/download/v$VER/hugo_"$VER"-arm.tar.gz"
|
echo "Removing unused dependencies..."
|
||||||
echo "Hugo Extended is not supported on armv7l, Installing Hugo standard"
|
sudo apt autoremove -y
|
||||||
sudo apt update
|
|
||||||
sudo apt install snapd
|
# Download Hugo
|
||||||
sudo snap install dart-sass
|
echo "Downloading Hugo..."
|
||||||
|
mkdir -p /tmp/hugo && cd /tmp/hugo || { echo "Failed to create directory. Exiting."; exit 1; }
|
||||||
|
VER=$(curl --silent "https://api.github.com/repos/gohugoio/hugo/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | sed 's|[v,]||g' ) || { echo "Failed to fetch Hugo version. Exiting."; exit 1; }
|
||||||
|
|
||||||
|
if [ -n "$(uname -a | grep x86_64)" ]; then
|
||||||
|
HUGO_URL="https://github.com/gohugoio/hugo/releases/download/v$VER/hugo_extended_${VER}_Linux-64bit.tar.gz"
|
||||||
|
elif [ -n "$(uname -a | grep armv6l)" ]; then
|
||||||
|
HUGO_URL="https://github.com/gohugoio/hugo/releases/download/v$VER/hugo_extended_${VER}_Linux-ARM64.tar.gz"
|
||||||
|
elif [ -n "$(uname -a | grep armv7l)" ]; then
|
||||||
|
HUGO_URL="https://github.com/gohugoio/hugo/releases/download/v$VER/hugo_${VER}_Linux-ARM.tar.gz"
|
||||||
|
echo "Hugo Extended is not supported on armv7l, installing standard Hugo..."
|
||||||
|
sudo apt update && sudo apt install -y snapd || { echo "Failed to install snapd. Exiting."; exit 1; }
|
||||||
|
sudo snap install dart-sass || { echo "Failed to install dart-sass via snap. Exiting."; exit 1; }
|
||||||
|
else
|
||||||
|
echo "Unsupported architecture. Exiting."
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
cd /tmp/hugo/
|
|
||||||
tar -xzf /tmp/hugo/*.tar.gz
|
# Download and install Hugo
|
||||||
sudo mv /tmp/hugo/hugo /usr/local/bin
|
echo "Downloading and installing Hugo..."
|
||||||
cd ~
|
wget -O hugo.tar.gz "$HUGO_URL" || { echo "Failed to download Hugo. Exiting."; exit 1; }
|
||||||
|
tar -xzf hugo.tar.gz || { echo "Failed to extract Hugo. Exiting."; exit 1; }
|
||||||
|
sudo mv hugo /usr/local/bin || { echo "Failed to move Hugo binary. Exiting."; exit 1; }
|
||||||
|
echo "Hugo successfully installed!"
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm -rf /tmp/hugo
|
||||||
|
cd ~
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
|
@ -1,80 +1,77 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
trap 'exit 130' INT
|
trap 'exit 130' INT
|
||||||
while true
|
|
||||||
do
|
# Confirmation prompt
|
||||||
read -r -p "Would you like to install phpMyAdmin? [Y/n] " input
|
while true; do
|
||||||
|
read -r -p "Would you like to install phpMyAdmin? [Y/n] " input
|
||||||
case $input in
|
|
||||||
[yY][eE][sS]|[yY])
|
case $input in
|
||||||
break
|
[yY][eE][sS]|[yY])
|
||||||
;;
|
break
|
||||||
[nN][oO]|[nN])
|
;;
|
||||||
break
|
[nN][oO]|[nN])
|
||||||
;;
|
echo "phpMyAdmin installation aborted."
|
||||||
*)
|
exit 0
|
||||||
echo "That wasn't an option..."
|
;;
|
||||||
;;
|
*)
|
||||||
esac
|
echo "That wasn't an option..."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Web server selection prompt
|
||||||
while [ "$go" != 'apache' ] && [ "$go" != 'nginx' ]; do
|
while [ "$go" != 'apache' ] && [ "$go" != 'nginx' ]; do
|
||||||
read -p "Would you like to install using Nginx or Apache? (nginx/apache) " go
|
read -p "Would you like to install using Nginx or Apache? (nginx/apache) " go
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Update and upgrade system packages
|
||||||
|
apt update && apt upgrade -y
|
||||||
|
|
||||||
|
# Install dependencies and add repositories
|
||||||
|
apt-get install build-essential lsb-release software-properties-common -y
|
||||||
if [ "$go" == 'nginx' ]; then
|
if [ "$go" == 'nginx' ]; then
|
||||||
sudo apt update && apt upgrade -y
|
add-apt-repository --yes ppa:ondrej/nginx
|
||||||
sudo apt-get install build-essential lsb-release software-properties-common -y
|
add-apt-repository --yes ppa:ondrej/php
|
||||||
sudo add-apt-repository --yes ppa:ondrej/nginx && sudo add-apt-repository --yes ppa:ondrej/php && sudo apt install php-fpm software-properties-common phpmyadmin php-mbstring php-zip php-gd php-json php-curl nginx-full php-mysql unzip -y
|
apt install nginx-full phpmyadmin php-{mbstring,zip,fpm,gd,json,curl,mysql} unzip -y
|
||||||
sudo systemctl stop nginx
|
systemctl stop nginx
|
||||||
sudo wget -O /etc/nginx/conf.d/phpmyadmin.conf https://git.oldgate.org/Sophia/thelinuxlist/raw/branch/main/conf/pmanginx.conf
|
wget -O /etc/nginx/conf.d/phpmyadmin.conf https://git.oldgate.org/Sophia/thelinuxlist/raw/branch/main/conf/pmanginx.conf
|
||||||
sudo systemctl enable nginx
|
systemctl enable nginx
|
||||||
sudo systemctl start nginx
|
systemctl start nginx
|
||||||
## Updating phpMyAdmin.
|
elif [ "$go" == 'apache' ]; then
|
||||||
sudo rm -rf /usr/share/phpmyadmin.bak
|
add-apt-repository --yes ppa:ondrej/apache2
|
||||||
sudo mv /usr/share/phpmyadmin/ /usr/share/phpmyadmin.bak
|
apt install apache2 libapache2-mod-php phpmyadmin php-{mbstring,zip,fpm,gd,json,curl,mysql} unzip -y
|
||||||
sudo mkdir /usr/share/phpmyadmin/
|
systemctl stop apache2
|
||||||
sudo wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.zip -P /usr/share/phpmyadmin/
|
wget -O /etc/apache2/sites-enabled/phpmyadmin.conf https://git.oldgate.org/Sophia/thelinuxlist/raw/branch/main/conf/pmaapache.conf
|
||||||
sudo unzip /usr/share/phpmyadmin/phpMyAdmin-latest-all-languages.zip -C /usr/share/phpmyadmin/
|
systemctl restart php-fpm
|
||||||
sudo mv /usr/share/phpmyadmin/phpMyAdmin-latest-all-languages/* /usr/share/phpmyadmin
|
systemctl reload apache2
|
||||||
sudo mkdir /usr/share/phpmyadmin/tmp/ && chmod -R 777 /usr/share/phpmyadmin/tmp/
|
systemctl enable apache2
|
||||||
sudo rm -rf /usr/share/phpmyadmin/phpMyAdmin-latest-all-languages /usr/share/phpmyadmin/phpMyAdmin-latest-all-languages.tar.gz
|
fi
|
||||||
## Thanks https://stackoverflow.com/users/3266847/benjamin-w
|
|
||||||
|
# Update phpMyAdmin
|
||||||
|
rm -rf /usr/share/phpmyadmin.bak
|
||||||
|
mv /usr/share/phpmyadmin/ /usr/share/phpmyadmin.bak
|
||||||
|
mkdir /usr/share/phpmyadmin/
|
||||||
|
wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz -P /usr/share/phpmyadmin/
|
||||||
|
tar -xzf /usr/share/phpmyadmin/*.tar.gz -C /usr/share/phpmyadmin/
|
||||||
|
mv /usr/share/phpmyadmin/phpMyAdmin-*-all-languages/* /usr/share/phpmyadmin
|
||||||
|
mkdir /usr/share/phpmyadmin/tmp/ && chmod -R 777 /usr/share/phpmyadmin/tmp/
|
||||||
|
|
||||||
|
# Set random Blowfish secret
|
||||||
randomBlowfishSecret=$(openssl rand -base64 22)
|
randomBlowfishSecret=$(openssl rand -base64 22)
|
||||||
sudo sed -e "s|cfg\['blowfish_secret'\] = ''|cfg['blowfish_secret'] = '$randomBlowfishSecret'|" /usr/share/phpmyadmin/config.sample.inc.php > /usr/share/phpmyadmin/config.inc.php
|
sed -e "s|cfg\['blowfish_secret'\] = ''|cfg['blowfish_secret'] = '$randomBlowfishSecret'|" /usr/share/phpmyadmin/config.sample.inc.php > /usr/share/phpmyadmin/config.inc.php
|
||||||
sudo systemctl restart nginx
|
|
||||||
sudo ufw allow 8080
|
# Restart web server and allow connections
|
||||||
|
if [ "$go" == 'nginx' ]; then
|
||||||
|
systemctl restart nginx
|
||||||
|
elif [ "$go" == 'apache' ]; then
|
||||||
|
systemctl restart apache2
|
||||||
|
fi
|
||||||
|
ufw allow 8080
|
||||||
|
|
||||||
|
# Display information
|
||||||
echo -e "=================================================================="
|
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 )
|
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)
|
internalip=$(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 "phpMyAdmin Should be available at http://${intenalip}:8080"
|
echo "phpMyAdmin should be available at http://${internalip}:8080"
|
||||||
echo "Or If you are using a VPS at http://${publicipaddress}:8080"
|
echo "Or if you are using a VPS, at http://${publicipaddress}:8080"
|
||||||
echo -e "=================================================================="
|
echo -e "=================================================================="
|
||||||
fi
|
|
||||||
if [ "$go" == 'apache' ]; then
|
|
||||||
sudo apt update && apt upgrade -y
|
|
||||||
sudo apt-get install build-essential lsb-release software-properties-common -y
|
|
||||||
sudo add-apt-repository --yes ppa:ondrej/apache2 && apt install apache2 libapache2-mod-php php-fpm software-properties-common phpmyadmin php-mbstring php-zip php-gd php-json php-curl php-mysql unzip -y
|
|
||||||
sudo systemctl stop apache2
|
|
||||||
sudo wget -O /etc/apache2/sites-enabled/phpmyadmin.conf https://git.oldgate.org/Sophia/thelinuxlist/raw/branch/main/conf/pmaapache.conf
|
|
||||||
sudo systemctl restart php-fpm
|
|
||||||
sudo systemctl reload apache2
|
|
||||||
sudo systemctl enable apache2
|
|
||||||
## Updating phpMyAdmin.
|
|
||||||
sudo rm -rf /usr/share/phpmyadmin.bak
|
|
||||||
sudo mv /usr/share/phpmyadmin/ /usr/share/phpmyadmin.bak
|
|
||||||
sudo mkdir /usr/share/phpmyadmin/
|
|
||||||
sudo wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.zip -P /usr/share/phpmyadmin/
|
|
||||||
sudo unzip /usr/share/phpmyadmin/phpMyAdmin-latest-all-languages.zip -C /usr/share/phpmyadmin/
|
|
||||||
sudo mv /usr/share/phpmyadmin/phpMyAdmin-latest-all-languages/* /usr/share/phpmyadmin
|
|
||||||
sudo mkdir /usr/share/phpmyadmin/tmp/ && chmod -R 777 /usr/share/phpmyadmin/tmp/
|
|
||||||
sudo rm -rf /usr/share/phpmyadmin/phpMyAdmin-latest-all-languages /usr/share/phpmyadmin/phpMyAdmin-latest-all-languages.tar.gz
|
|
||||||
## Thanks https://stackoverflow.com/users/3266847/benjamin-w
|
|
||||||
randomBlowfishSecret=$(openssl rand -base64 22)
|
|
||||||
sudo sed -e "s|cfg\['blowfish_secret'\] = ''|cfg['blowfish_secret'] = '$randomBlowfishSecret'|" /usr/share/phpmyadmin/config.sample.inc.php > /usr/share/phpmyadmin/config.inc.php
|
|
||||||
sudo systemctl restart apache2
|
|
||||||
sudo ufw allow 8080
|
|
||||||
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 "phpMyAdmin Should be available at http://${intenalip}:8080"
|
|
||||||
echo "Or If you are using a VPS at http://${publicipaddress}:8080"
|
|
||||||
echo -e "=================================================================="
|
|
||||||
fi
|
|
||||||
|
|
|
@ -1,34 +1,40 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
trap 'exit 130' INT
|
trap 'exit 130' INT
|
||||||
while true
|
|
||||||
do
|
|
||||||
read -r -p "Would you like to uninstall phpMyAdmin? [Y/n] " input
|
|
||||||
|
|
||||||
case $input in
|
|
||||||
[yY][eE][sS]|[yY])
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
[nN][oO]|[nN])
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "That wasn't an option..."
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
if [ -n "$(dpkg --get-selections | grep apache)" ]; then
|
|
||||||
sudo apt remove phpmyadmin -y
|
|
||||||
sudo apt-get autoremove -y
|
|
||||||
sudo rm -rf /usr/share/phpmyadmin/
|
|
||||||
sudo rm -rf /etc/apache2/sites-enabled/phpmyadmin.conf
|
|
||||||
sudo systemctl restart apache2
|
|
||||||
|
|
||||||
|
# Confirmation prompt
|
||||||
|
while true; do
|
||||||
|
read -r -p "Would you like to uninstall phpMyAdmin? [Y/n] " input
|
||||||
|
|
||||||
|
case $input in
|
||||||
|
[yY][eE][sS]|[yY])
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
[nN][oO]|[nN])
|
||||||
|
echo "phpMyAdmin uninstallation aborted."
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "That wasn't an option..."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Uninstallation
|
||||||
|
if [ -n "$(dpkg --get-selections | grep apache)" ]; then
|
||||||
|
sudo apt remove phpmyadmin -y
|
||||||
|
sudo apt-get autoremove -y
|
||||||
|
sudo rm -rf /usr/share/phpmyadmin/
|
||||||
|
sudo rm -rf /etc/apache2/sites-enabled/phpmyadmin.conf
|
||||||
|
sudo systemctl restart apache2
|
||||||
|
elif [ -n "$(dpkg --get-selections | grep nginx)" ]; then
|
||||||
|
sudo apt remove phpmyadmin -y
|
||||||
|
sudo apt-get autoremove -y
|
||||||
|
sudo rm -rf /usr/share/phpmyadmin/
|
||||||
|
sudo rm -rf /etc/nginx/conf.d/phpmyadmin.conf
|
||||||
|
sudo systemctl restart nginx
|
||||||
|
else
|
||||||
|
echo "Neither Apache nor Nginx is installed. Cannot uninstall phpMyAdmin."
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$(dpkg --get-selections | grep nginx)" ]; then
|
echo "phpMyAdmin has been successfully uninstalled."
|
||||||
sudo apt remove phpmyadmin -y
|
|
||||||
sudo apt-get autoremove -y
|
|
||||||
sudo rm -rf /usr/share/phpmyadmin/
|
|
||||||
sudo rm -rf /etc/nginx/conf.d/phpmyadmin.conf
|
|
||||||
sudo systemctl restart nginx
|
|
||||||
fi
|
|
||||||
|
|
|
@ -1,49 +1,46 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
trap 'exit 130' INT
|
trap 'exit 130' INT
|
||||||
while true
|
|
||||||
do
|
# Confirmation prompt
|
||||||
read -r -p "Would you like to Update phpMyAdmin? [Y/n] " input
|
while true; do
|
||||||
|
read -r -p "Would you like to Update phpMyAdmin? [Y/n] " input
|
||||||
case $input in
|
|
||||||
[yY][eE][sS]|[yY])
|
case $input in
|
||||||
break
|
[yY][eE][sS]|[yY])
|
||||||
;;
|
break
|
||||||
[nN][oO]|[nN])
|
;;
|
||||||
break
|
[nN][oO]|[nN])
|
||||||
;;
|
echo "phpMyAdmin update aborted."
|
||||||
*)
|
exit 0
|
||||||
echo "That wasn't an option..."
|
;;
|
||||||
;;
|
*)
|
||||||
esac
|
echo "That wasn't an option..."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
if [ ! -x /usr/bin/curl ] ; then
|
|
||||||
CURL_NOT_EXIST=1
|
# Dependency check
|
||||||
apt install -y curl
|
if ! command -v curl &>/dev/null; then
|
||||||
else
|
echo "Installing curl..."
|
||||||
CURL_NOT_EXIST=0
|
sudo apt install -y curl
|
||||||
fi
|
fi
|
||||||
sudo apt update && apt upgrade -y
|
|
||||||
|
# Update process
|
||||||
|
echo "Updating phpMyAdmin..."
|
||||||
|
sudo apt update && sudo apt upgrade -y
|
||||||
sudo rm -rf /usr/share/phpmyadmin.bak
|
sudo rm -rf /usr/share/phpmyadmin.bak
|
||||||
sudo mv /usr/share/phpmyadmin/ /usr/share/phpmyadmin.bak
|
sudo mv /usr/share/phpmyadmin/ /usr/share/phpmyadmin.bak
|
||||||
sudo mkdir /usr/share/phpmyadmin/
|
sudo mkdir /usr/share/phpmyadmin/
|
||||||
sudo wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.zip -P /usr/share/phpmyadmin/
|
sudo wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz -P /usr/share/phpmyadmin/
|
||||||
sudo unzip /usr/share/phpmyadmin/phpMyAdmin-latest-all-languages.zip -C /usr/share/phpmyadmin/
|
sudo tar -xzf /usr/share/phpmyadmin/*.tar.gz -C /usr/share/phpmyadmin/
|
||||||
sudo mv /usr/share/phpmyadmin/phpMyAdmin-latest-all-languages/* /usr/share/phpmyadmin
|
sudo mv /usr/share/phpmyadmin/phpMyAdmin-*-all-languages/* /usr/share/phpmyadmin
|
||||||
sudo mkdir /usr/share/phpmyadmin/tmp/ && chmod -R 777 /usr/share/phpmyadmin/tmp/
|
sudo mkdir /usr/share/phpmyadmin/tmp/ && sudo chmod -R 777 /usr/share/phpmyadmin/tmp/
|
||||||
sudo rm -rf /usr/share/phpmyadmin/phpMyAdmin-latest-all-languages /usr/share/phpmyadmin/phpMyAdmin-latest-all-languages.tar.gz
|
|
||||||
## Thanks https://stackoverflow.com/users/3266847/benjamin-w
|
|
||||||
randomBlowfishSecret=$(openssl rand -base64 22)
|
randomBlowfishSecret=$(openssl rand -base64 22)
|
||||||
sudo sed -e "s|cfg\['blowfish_secret'\] = ''|cfg['blowfish_secret'] = '$randomBlowfishSecret'|" /usr/share/phpmyadmin/config.sample.inc.php > /usr/share/phpmyadmin/config.inc.php
|
sudo sed -i "s|cfg\['blowfish_secret'\] = ''|cfg['blowfish_secret'] = '$randomBlowfishSecret'|" /usr/share/phpmyadmin/config.sample.inc.php
|
||||||
sudo systemctl restart apache2
|
sudo mv /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php
|
||||||
sudo systemctl restart nginx
|
sudo systemctl restart apache2 nginx
|
||||||
|
|
||||||
|
# Completion message
|
||||||
echo -e "=================================================================="
|
echo -e "=================================================================="
|
||||||
echo "phpMyAdmin has been updated!"
|
echo "phpMyAdmin has been updated!"
|
||||||
echo -e "=================================================================="
|
echo -e "=================================================================="
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,57 +1,102 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
trap 'exit 130' INT
|
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
|
|
||||||
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"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$(uname -a | grep x86_64)" ]; then
|
# Function to check if required domains are accessible
|
||||||
curl -fsSL -o "/tmp/gitea" "https://dl.gitea.io/gitea/$VER/gitea-$VER-linux-amd64"
|
check_domains() {
|
||||||
fi
|
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
|
||||||
|
}
|
||||||
|
|
||||||
if [ -n "$(uname -a | grep armv6l)" ]; then
|
# Function to install Gitea
|
||||||
curl -fsSL -o "/tmp/gitea" "https://dl.gitea.io/gitea/$VER/gitea-$VER-linux-arm-6"
|
install_gitea() {
|
||||||
fi
|
echo "Installing Gitea..."
|
||||||
|
|
||||||
if [ -n "$(uname -a | grep armv7l)" ]; then
|
# Check if curl is installed
|
||||||
curl -fsSL -o "/tmp/gitea" "https://dl.gitea.io/gitea/$VER/gitea-$VER-linux-arm-7"
|
if ! command -v curl &>/dev/null; then
|
||||||
fi
|
echo "Installing curl..."
|
||||||
|
sudo apt install -y curl || { echo "Failed to install curl. Exiting."; exit 1; }
|
||||||
|
fi
|
||||||
|
|
||||||
sudo mv /tmp/gitea /usr/local/bin
|
# Get latest Gitea version
|
||||||
sudo chmod +x /usr/local/bin/gitea
|
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 mkdir -p /var/lib/gitea/{custom,data,log}
|
|
||||||
sudo chown -R git:git /var/lib/gitea
|
# Install git
|
||||||
sudo chmod -R 750 /var/lib/gitea
|
echo "Installing git..."
|
||||||
sudo mkdir /etc/gitea
|
sudo apt-get install git -y || { echo "Failed to install git. Exiting."; exit 1; }
|
||||||
sudo chown root:git /etc/gitea
|
|
||||||
sudo chmod 770 /etc/gitea
|
# Create git user
|
||||||
curl -fsSL -o /etc/systemd/system/gitea.service https://raw.githubusercontent.com/go-gitea/gitea/master/contrib/systemd/gitea.service
|
echo "Creating git user..."
|
||||||
sudo systemctl daemon-reload
|
sudo adduser --system --shell /bin/bash --gecos 'Git Version Control' --group --disabled-password --home /home/git git
|
||||||
sudo systemctl enable --now gitea
|
|
||||||
sudo systemctl start gitea
|
# Download and install Gitea binary
|
||||||
sudo ufw allow 3000
|
echo "Downloading Gitea binary..."
|
||||||
echo -e "=================================================================="
|
case "$(uname -m)" in
|
||||||
publicipaddress=$(curl -sS --connect-timeout 10 -m 60 https://ipv4.icanhazip.com/ || curl -sS --connect-timeout 10 -m 60 https://api.ipify.org )
|
i386)
|
||||||
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)
|
arch="386"
|
||||||
echo "Gitea Should be available at http://${intenalip}:3000"
|
;;
|
||||||
echo "Or If you are using a VPS at http://${publicipaddress}:3000"
|
x86_64)
|
||||||
echo -e "=================================================================="
|
arch="amd64"
|
||||||
fi
|
;;
|
||||||
|
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
|
||||||
|
# Automate installation by assuming yes to the prompt
|
||||||
|
check_domains
|
||||||
|
install_gitea
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
|
@ -1,16 +1,39 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Function to perform uninstallation
|
||||||
|
uninstall_gitea() {
|
||||||
|
echo "Stopping Gitea service..."
|
||||||
|
sudo systemctl stop gitea
|
||||||
|
|
||||||
|
echo "Disabling Gitea service..."
|
||||||
|
sudo systemctl disable gitea
|
||||||
|
|
||||||
|
echo "Removing Gitea service file..."
|
||||||
|
sudo rm -rf /etc/systemd/system/gitea.service
|
||||||
|
|
||||||
|
echo "Backing up files..."
|
||||||
|
timestamp=$(date +"%Y%m%d_%H%M%S")
|
||||||
|
tar -cvzf "gitea_backup_${timestamp}.tar.gz" /var/lib/gitea/ /etc/gitea || { echo "Failed to backup files. Exiting."; exit 1; }
|
||||||
|
|
||||||
|
echo "Removing Gitea user and home directory..."
|
||||||
|
sudo userdel -r git || { echo "Failed to delete Gitea user. Exiting."; exit 1; }
|
||||||
|
|
||||||
|
echo "Removing Gitea binary..."
|
||||||
|
sudo rm -rf /usr/local/bin/gitea
|
||||||
|
|
||||||
|
echo "Cleaning up Gitea data and configuration..."
|
||||||
|
sudo rm -rf /var/lib/gitea/* /etc/gitea
|
||||||
|
|
||||||
|
echo "Removing firewall rule for port 3000..."
|
||||||
|
sudo ufw delete allow 3000
|
||||||
|
|
||||||
|
echo "Gitea has been uninstalled, and all files have been backed up."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main script
|
||||||
trap 'exit 130' INT
|
trap 'exit 130' INT
|
||||||
sudo systemctl stop gitea
|
|
||||||
sudo systemctl disable gitea
|
|
||||||
sudo rm -rf /etc/systemd/system/gitea.service
|
|
||||||
echo "Backing up Files"
|
|
||||||
tar -cvzf gitea.tar.gz /var/lib/gitea/ /etc/gitea
|
|
||||||
sudo rm -rf /home/git
|
|
||||||
sudo userdel git
|
|
||||||
sudo rm -rf /usr/local/bin/gitea
|
|
||||||
sudo rm -rf /var/lib/gitea/*
|
|
||||||
sudo rm -rf /etc/gitea
|
|
||||||
sudo ufw delete allow 3000
|
|
||||||
|
|
||||||
echo "Gitea has been uninstalled, and all files have are backed up in gitea.tar.gz, you can delete it at your discretion."
|
# Automate confirmation by assuming yes to the prompt
|
||||||
|
uninstall_gitea
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
|
@ -1,45 +1,70 @@
|
||||||
#!/usr/bin/env bash
|
#!/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
|
# Function to check network connectivity
|
||||||
curl -fsSL -o "/tmp/gitea" "https://dl.gitea.io/gitea/$VER/gitea-$VER-linux-amd64"
|
check_connectivity() {
|
||||||
fi
|
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
|
# Function to perform the update
|
||||||
curl -fsSL -o "/tmp/gitea" "https://dl.gitea.io/gitea/$VER/gitea-$VER-linux-arm-6"
|
update_gitea() {
|
||||||
fi
|
echo "Updating Gitea..."
|
||||||
|
|
||||||
if [ -n "$(uname -a | grep armv7l)" ]; then
|
# Check if curl is installed
|
||||||
curl -fsSL -o "/tmp/gitea" "https://dl.gitea.io/gitea/$VER/gitea-$VER-linux-arm-7"
|
if ! command -v curl &>/dev/null; then
|
||||||
fi
|
echo "Installing curl..."
|
||||||
sudo mv /tmp/gitea /usr/local/bin
|
sudo apt install -y curl || { echo "Failed to install curl. Exiting."; exit 1; }
|
||||||
sudo chmod +x /usr/local/bin/gitea
|
fi
|
||||||
sudo chown -R git:git /var/lib/gitea
|
|
||||||
sudo chmod -R 750 /var/lib/gitea
|
# Get latest Gitea version
|
||||||
sudo chown root:git /etc/gitea
|
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 start gitea
|
|
||||||
sudo ufw allow 3000
|
# Determine architecture
|
||||||
echo -e "=================================================================="
|
case "$(uname -m)" in
|
||||||
echo "Gitea has been updated!!"
|
i386)
|
||||||
echo -e "=================================================================="
|
arch="386"
|
||||||
fi
|
;;
|
||||||
|
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
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
sudo gitlab-ctl stop
|
|
||||||
sudo apt remove gitlab-ce -y
|
|
||||||
sudo apt update && apt upgrade -y
|
|
||||||
sudo ufw delete allow 443
|
|
||||||
sudo ufw delete allow 80
|
|
|
@ -1,27 +1,36 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
trap 'exit 130' INT
|
|
||||||
# Check if curl is installed
|
# Check if curl is installed
|
||||||
if [ ! -x /usr/bin/curl ] ; then
|
if ! command -v curl &>/dev/null; then
|
||||||
CURL_NOT_EXIST=1
|
echo "curl is required but not installed. Installing curl..."
|
||||||
apt install -y curl
|
sudo apt update && sudo apt install -y curl || {
|
||||||
else
|
echo "Failed to install curl. Exiting."
|
||||||
CURL_NOT_EXIST=0
|
exit 1
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
apt remove golang -y
|
|
||||||
rm -rf /tmp/go/
|
# Get latest Go version
|
||||||
mkdir /tmp/go/
|
ARCH=$(uname -m)
|
||||||
cd /tmp/go/
|
case $ARCH in
|
||||||
VER=$(curl --silent "https://go.dev/dl/?mode=json" | grep '"version":' | sed -E 's/.*"([^"]+)".*/\1/' | sed 's|[v,]||g' | head -1)
|
"x86_64") ARCH="amd64" ;;
|
||||||
if [ -n "$(uname -a | grep x86_64)" ]; then
|
"armv6l") ARCH="armv6l" ;;
|
||||||
curl -fsSL -o "/tmp/go/"$VER".linux-amd64.tar.gz" "https://go.dev/dl/"$VER".linux-amd64.tar.gz"
|
*) ARCH="386" ;;
|
||||||
fi
|
esac
|
||||||
if [ -n "$(uname -a | grep armv6l)" ]; then
|
|
||||||
curl -fsSL -o "/tmp/go/"$VER".linux-armv6l.tar.gz" "https://go.dev/dl/"$VER".linux-armv6l.tar.gz"
|
GO_VERSION=$(curl -sSL https://golang.org/dl/?mode=json | grep -oP '"version":"\K[^"]+' | head -n1)
|
||||||
fi
|
GO_URL="https://golang.org/dl/go$GO_VERSION.linux-$ARCH.tar.gz"
|
||||||
if [ -n "$(uname -a | grep i386)" ]; then
|
|
||||||
curl -fsSL -o "/tmp/go/"$VER".linux-386.tar.gz" "https://go.dev/dl/"$VER".linux-386.tar.gz"
|
# Install Go
|
||||||
fi
|
echo "Downloading and installing Go $GO_VERSION..."
|
||||||
rm -rf /usr/local/go && tar -C /usr/local -xzf *.tar.gz
|
sudo rm -rf /usr/local/go
|
||||||
chmod +x /usr/local/go/bin/go
|
sudo curl -fsSL "$GO_URL" | sudo tar -C /usr/local -xz || {
|
||||||
export PATH=$PATH:/usr/local/go/bin
|
echo "Failed to download and install Go. Exiting."
|
||||||
cd ~
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Update PATH
|
||||||
|
echo "Updating PATH..."
|
||||||
|
echo 'export PATH=$PATH:/usr/local/go/bin' | sudo tee -a /etc/profile.d/go.sh >/dev/null
|
||||||
|
source /etc/profile.d/go.sh
|
||||||
|
|
||||||
|
echo "Go $GO_VERSION has been successfully installed."
|
||||||
|
|
|
@ -1,33 +1,46 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Trap INT signal to ensure clean exits
|
||||||
trap 'exit 130' INT
|
trap 'exit 130' INT
|
||||||
if [ ! -x /usr/bin/curl ] ; then
|
|
||||||
CURL_NOT_EXIST=1
|
# Check for dependencies and install if needed
|
||||||
apt install -y curl
|
if ! command -v curl &>/dev/null; then
|
||||||
else
|
echo "Installing curl..."
|
||||||
CURL_NOT_EXIST=0
|
sudo apt update && sudo apt install -y curl || { echo "Failed to install curl. Exiting."; exit 1; }
|
||||||
fi
|
|
||||||
apt remove golang -y
|
|
||||||
apt autoremove -y
|
|
||||||
wget -O goinstall.sh https://sop.wtf/sh/u/goinstall && bash goinstall.sh
|
|
||||||
rm -rf /tmp/hugo/
|
|
||||||
mkdir /tmp/hugo/
|
|
||||||
VER=$(curl --silent "https://api.github.com/repos/gohugoio/hugo/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | sed 's|[v,]||g' )
|
|
||||||
if [ -n "$(uname -a | grep x86_64)" ]; then
|
|
||||||
curl -fsSL -o "/tmp/hugo/hugo_extended_"$VER"_linux-amd64.tar.gz" "https://github.com/gohugoio/hugo/releases/download/v$VER/hugo_extended_"$VER"_linux-amd64.tar.gz"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$(uname -a | grep armv6l)" ]; then
|
|
||||||
curl -fsSL -o "/tmp/hugo/hugo_extended_"$VER"-arm64.tar.gz" "https://github.com/gohugoio/hugo/releases/download/v$VER/hugo_extended_"$VER"-arm64.tar.gz"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$(uname -a | grep armv7l)" ]; then
|
# Remove unused dependencies (optional)
|
||||||
curl -fsSL -o "/tmp/hugo/hugo_"$VER"-arm.tar.gz" "https://github.com/gohugoio/hugo/releases/download/v$VER/hugo_"$VER"-arm.tar.gz"
|
echo "Removing unused dependencies..."
|
||||||
echo "Hugo Extended is not supported on armv7l, Installing Hugo standard"
|
sudo apt autoremove -y
|
||||||
sudo apt update
|
|
||||||
sudo apt install snapd
|
# Download Hugo
|
||||||
sudo snap install dart-sass
|
echo "Downloading Hugo..."
|
||||||
|
mkdir -p /tmp/hugo && cd /tmp/hugo || { echo "Failed to create directory. Exiting."; exit 1; }
|
||||||
|
VER=$(curl --silent "https://api.github.com/repos/gohugoio/hugo/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | sed 's|[v,]||g' ) || { echo "Failed to fetch Hugo version. Exiting."; exit 1; }
|
||||||
|
|
||||||
|
if [ -n "$(uname -a | grep x86_64)" ]; then
|
||||||
|
HUGO_URL="https://github.com/gohugoio/hugo/releases/download/v$VER/hugo_extended_${VER}_Linux-64bit.tar.gz"
|
||||||
|
elif [ -n "$(uname -a | grep armv6l)" ]; then
|
||||||
|
HUGO_URL="https://github.com/gohugoio/hugo/releases/download/v$VER/hugo_extended_${VER}_Linux-ARM64.tar.gz"
|
||||||
|
elif [ -n "$(uname -a | grep armv7l)" ]; then
|
||||||
|
HUGO_URL="https://github.com/gohugoio/hugo/releases/download/v$VER/hugo_${VER}_Linux-ARM.tar.gz"
|
||||||
|
echo "Hugo Extended is not supported on armv7l, installing standard Hugo..."
|
||||||
|
sudo apt update && sudo apt install -y snapd || { echo "Failed to install snapd. Exiting."; exit 1; }
|
||||||
|
sudo snap install dart-sass || { echo "Failed to install dart-sass via snap. Exiting."; exit 1; }
|
||||||
|
else
|
||||||
|
echo "Unsupported architecture. Exiting."
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
cd /tmp/hugo/
|
|
||||||
tar -xzf /tmp/hugo/*.tar.gz
|
# Download and install Hugo
|
||||||
sudo mv /tmp/hugo/hugo /usr/local/bin
|
echo "Downloading and installing Hugo..."
|
||||||
cd ~
|
wget -O hugo.tar.gz "$HUGO_URL" || { echo "Failed to download Hugo. Exiting."; exit 1; }
|
||||||
|
tar -xzf hugo.tar.gz || { echo "Failed to extract Hugo. Exiting."; exit 1; }
|
||||||
|
sudo mv hugo /usr/local/bin || { echo "Failed to move Hugo binary. Exiting."; exit 1; }
|
||||||
|
echo "Hugo successfully installed!"
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm -rf /tmp/hugo
|
||||||
|
cd ~
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
Reference in New Issue