You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
936 B
Bash
41 lines
936 B
Bash
#!/usr/bin/env bash
|
|
|
|
set -x
|
|
set -e
|
|
|
|
VERSION=${VERSION:-0.76.3}
|
|
PREFIX_DIR=/usr/local
|
|
BIN_DIR="${PREFIX_DIR}/bin"
|
|
|
|
OS=
|
|
if [[ $OSTYPE =~ linux ]]; then
|
|
OS=Linux
|
|
elif [[ $OSTYPE =~ darwin ]]; then
|
|
OS=macOS
|
|
else
|
|
echo unknown os: "$OSTYPE"
|
|
exit 1
|
|
fi
|
|
|
|
URL=https://github.com/gohugoio/hugo/releases/download/v${VERSION}/hugo_${VERSION}_${OS}-64bit.tar.gz
|
|
TMP_DIR=$(mktemp --directory)
|
|
|
|
cd "$TMP_DIR"
|
|
curl --location --silent --output release.tar.gz "${URL}"
|
|
tar xvzf release.tar.gz
|
|
sudo chown root:root hugo
|
|
|
|
sudo mkdir -p "${PREFIX_DIR}/apps/hugo/${VERSION}"
|
|
sudo mv ./hugo "${PREFIX_DIR}/apps/hugo/${VERSION}/hugo"
|
|
cd "${PREFIX_DIR}/apps/hugo/"
|
|
[[ -s current ]] && sudo unlink current
|
|
sudo ln -s "${VERSION}" current
|
|
|
|
cd ${BIN_DIR}
|
|
[[ -L ${BIN_DIR}/hugo ]] || sudo ln --symbolic "${PREFIX_DIR}/apps/hugo/current/hugo"
|
|
|
|
if [[ $TMP_DIR != "" ]]; then
|
|
rm -rf "${TMP_DIR}"
|
|
echo removed up temp directory "${TMP_DIR}"
|
|
fi
|