From 936a4937ea3d361510b7eaf3e6ecf1aa0bca390a Mon Sep 17 00:00:00 2001 From: Simon C Date: Tue, 17 Mar 2020 13:55:49 +0100 Subject: [PATCH] feat: Add hugo install script --- scripts/hugo.sh | 84 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 scripts/hugo.sh diff --git a/scripts/hugo.sh b/scripts/hugo.sh new file mode 100755 index 0000000..6b4368c --- /dev/null +++ b/scripts/hugo.sh @@ -0,0 +1,84 @@ +#!/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 +} + +echo '🐹 Starting hugo install/update' + +if ! [ -x "$(command -v curl)" ]; +then + checkos "curl" +fi + +gitlatest="https://api.github.com/repositories/11180687/releases/latest" +url=$(curl -s $gitlatest | grep -o 'https://.*hugo_extended.*_Linux-64bit.tar.gz') + +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! πŸŽ‰'