Move hugo install script from system to home

main
Buddy Sandidge 4 years ago
parent 488f4e16c2
commit 03e8fe0b28

@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -x
set -e
VERSION=${VERSION:-0.79.0}
LOCAL="${LOCAL:-${XDG_DATA_HOME:-${HOME}/.local}}"
SHARE_DIR="${LOCAL}/share/buddy-up"
DATA_DIR="${SHARE_DIR}/apps"
BIN_DIR="${BIN_DIR:-${XDG_BIN_HOME:-${LOCAL}/bin}}"
TMP_DIR=
if [[ ! -f "${DATA_DIR}/hugo/${VERSION}/hugo" ]] ; then
URL=https://github.com/gohugoio/hugo/releases/download/v${VERSION}/hugo_${VERSION}_$(uname -s)-64bit.tar.gz
TMP_DIR=$(mktemp --directory)
cd "${TMP_DIR}"
curl --location --silent --output release.tar.gz "${URL}"
tar xvzf release.tar.gz
mkdir -p "${DATA_DIR}/hugo/${VERSION}"
mv ./hugo "${DATA_DIR}/hugo/${VERSION}/hugo"
fi
cd "${DATA_DIR}/hugo/"
[[ -s current ]] && unlink current
ln -s "${VERSION}" current
cd "${BIN_DIR}"
[[ -L "hugo" ]] || ln --symbolic "${DATA_DIR}/hugo/current/hugo" hugo
if [[ "${TMP_DIR}" != "" ]]; then
rm -rf "${TMP_DIR}"
echo removed up temp directory "${TMP_DIR}"
fi

@ -1,40 +0,0 @@
#!/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
Loading…
Cancel
Save