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

81 lines
2.7 KiB
Bash
Raw Normal View History

2023-08-04 01:06:24 -07:00
#!/usr/bin/env bash
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
done
set -b
ping -c1 "github.com" &>"/dev/null"
ping -c1 "api.github.com" &>"/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
set -b
ping -c1 "go.dev" &>"/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
apt remove golang -y
rm -rf /tmp/go/
mkdir /tmp/go/
cd /tmp/go/
VER="1.20.7"
if [ -n "$(uname -a | grep x86_64)" ]; then
curl -fsSL -o "/tmp/go/go"$VER".linux-amd64.tar.gz" "https://go.dev/dl/go"$VER".linux-amd64.tar.gz"
fi
if [ -n "$(uname -a | grep armv6l)" ]; then
curl -fsSL -o "/tmp/go/go"$VER".linux-armv6l.tar.gz" "https://go.dev/dl/go"$VER".linux-armv6l.tar.gz"
fi
if [ -n "$(uname -a | grep i386)" ]; then
curl -fsSL -o "/tmp/go/go"$VER".linux-386.tar.gz" "https://go.dev/dl/go"$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
cd ~
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_"$VER"_linux-amd64.tar.gz" "https://github.com/gohugoio/hugo/releases/download/v$VER/hugo_"$VER"_linux-amd64.tar.gz"
fi
if [ -n "$(uname -a | grep armv6l)" ]; then
curl -fsSL -o "/tmp/hugo/hugo_"$VER"-arm64.tar.gz" "https://github.com/gohugoio/hugo/releases/download/v$VER/hugo_"$VER"-arm64.tar.gz"
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"
fi
cd /tmp/hugo/
tar -xzf /tmp/hugo/*.tar.gz
sudo mv /tmp/hugo/hugo /usr/local/bin
cd ~
fi