hugo-theme-lowtech/scripts/hugo.sh

100 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
installgit() {
if ! [ -x "$(command -v git)" ];
then
echo "Git is not installed\n\nStarting git installation...!"
eval $1
echo "Done installing git!\n"
fi
}
systemtypeinstall() {
if [ $1 = "ID=arch" ]; # installing in Arch Linux
then
echo "Installing $2 🐹🐹🐹🐹\n"
cmd=`sudo pacman -S git`
installgit $cmd
git clone https://aur.archlinux.org/snapd.git &&
cd snapd &&
makepkg -si &&
cd ../ &&
rm -rf snapd
sudo systemctl enable --now snapd.socket
echo "Done🎉🎉🎉🎉🎉🎉!"
elif [ $1 = "ID=ubuntu" ] || [ $1 = "ID=Debian" ]; # installing in Ubuntu or Debian
then
cmd=`sudo apt install git`
installgit $cmd
$(sudo apt install $2)
elif [ $1 = "ID=Fedora" ]; # installing in Fedora
then
cmd=`sudo apt install git`
installgit $cmd
$(sudo dnf install $2)
else
echo "Please find $2 installation for $1 online!"
fi
}
checkos() {
platform="$(uname | tr '[:upper:]' '[:lower:]')" # get which OS you are running
if [[ $platform = "linux" ]];
then
if ! [ -x "$(command -v snap)" ];
then
systemtype=$(grep -w "ID=.*" /etc/os-release)
systemtypeinstall $systemtype 'snapd'
else
$(snap install $1)
fi
else
echo "Please find instructions on how to install"
fi
}
getArchitecture() {
architecture="$(arch)"
if [[ $architecture = "armv7l" ]];
then
echo "ARM"
else
echo "64bit"
fi
}
echo '🐹 Starting hugo install/update'
if ! [ -x "$(command -v curl)" ];
then
checkos "curl"
fi
architecture=$(getArchitecture)
gitlatest="https://api.github.com/repositories/11180687/releases/latest"
echo $architecture
echo $gitlatest
url=$(curl -s $gitlatest | grep -o "https://.*hugo_extended.*_Linux-$architecture.tar.gz")
echo $url
echo '✅ Found the latest version!'
echo ''
echo '🐹 Downloading the hugo extended latest...!'
curl -s $url -L -o hugo_extended_latest.tar.gz
echo '✅ Download complete: ' $url
echo "🐹 Extracting archive!"
tar -zxf hugo_extended_latest.tar.gz hugo
echo '✅ Extracted to /usr/local/bin'
rm hugo_extended_latest.tar.gz
echo ''
echo '👉 Current Version' $(./hugo version)
echo ''
echo '🎉 DONE! 🎉'