scripts/gethugo

31 lines
736 B
Plaintext
Raw Permalink Normal View History

2022-04-20 17:02:58 +02:00
#!/bin/bash
PATH=~/.local/bin:$PATH
if [ -z $1 ]; then
echo "[x] HUGO_VERSION is not set, pass it as \$1"
exit 9001
else
HUGO_VERSION=$1
fi
if [ $(hugo version | grep -q ${HUGO_VERSION}; echo $?) -eq 0 ]; then
echo "[*] which hugo: $(which hugo)"
echo "[*] already on $HUGO_VERSION, exiting..."
exit 0
fi
nutmp=$(mktemp -d);cd "$nutmp";unset nutmp
WORKDIR=$(pwd)
HOMEBIN="/home/$USER/.local/bin"
mkdir -pv $HOMEBIN
echo "[*] downloading hugo version \"$HUGO_VERSION\""
curl -sL https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz | bsdtar xfv -
mv -vf hugo ${HOMEBIN}
cd ..
rm -rfv $WORKDIR
echo "[*] hugo updated to version $HUGO_VERSION"