forked from Sophia/thelinuxlist
EOL this project :(
This commit is contained in:
@ -1,49 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Trap INT signal to ensure clean exits
|
||||
trap 'exit 130' INT
|
||||
while true
|
||||
do
|
||||
read -r -p "Would you like to install Hugo? [Y/n] " input
|
||||
|
||||
case $input in
|
||||
[yY][eE][sS]|[yY])
|
||||
break
|
||||
;;
|
||||
[nN][oO]|[nN])
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "That wasn't an option..."
|
||||
;;
|
||||
esac
|
||||
|
||||
# Confirmation prompt
|
||||
while true; do
|
||||
read -r -p "Would you like to install Hugo? [Y/n] " input
|
||||
|
||||
case $input in
|
||||
[yY][eE][sS]|[yY])
|
||||
break
|
||||
;;
|
||||
[nN][oO]|[nN])
|
||||
echo "Hugo installation aborted."
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "That wasn't an option..."
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [ ! -x /usr/bin/curl ] ; then
|
||||
CURL_NOT_EXIST=1
|
||||
apt install -y curl
|
||||
else
|
||||
CURL_NOT_EXIST=0
|
||||
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"
|
||||
|
||||
# Check for dependencies and install if needed
|
||||
if ! command -v curl &>/dev/null; then
|
||||
echo "Installing curl..."
|
||||
sudo apt update && sudo apt install -y curl || { echo "Failed to install curl. Exiting."; exit 1; }
|
||||
fi
|
||||
|
||||
if [ -n "$(uname -a | grep armv7l)" ]; then
|
||||
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 "Hugo Extended is not supported on armv7l, Installing Hugo standard"
|
||||
sudo apt update
|
||||
sudo apt install snapd
|
||||
sudo snap install dart-sass
|
||||
# Remove unused dependencies (optional)
|
||||
echo "Removing unused dependencies..."
|
||||
sudo apt autoremove -y
|
||||
|
||||
# Download Hugo
|
||||
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
|
||||
cd /tmp/hugo/
|
||||
tar -xzf /tmp/hugo/*.tar.gz
|
||||
sudo mv /tmp/hugo/hugo /usr/local/bin
|
||||
cd ~
|
||||
|
||||
# Download and install Hugo
|
||||
echo "Downloading and installing Hugo..."
|
||||
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
Block a user