From 03e8fe0b280a1a3429e85de615910c4864bd335f Mon Sep 17 00:00:00 2001 From: Buddy Sandidge Date: Sun, 6 Dec 2020 12:34:56 -0800 Subject: [PATCH] Move hugo install script from system to home --- bin/install-hugo-home | 34 ++++++++++++++++++++++++++++++++++ bin/install-hugo-system | 40 ---------------------------------------- 2 files changed, 34 insertions(+), 40 deletions(-) create mode 100755 bin/install-hugo-home delete mode 100755 bin/install-hugo-system diff --git a/bin/install-hugo-home b/bin/install-hugo-home new file mode 100755 index 0000000..4fd6e32 --- /dev/null +++ b/bin/install-hugo-home @@ -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 diff --git a/bin/install-hugo-system b/bin/install-hugo-system deleted file mode 100755 index b6ffae8..0000000 --- a/bin/install-hugo-system +++ /dev/null @@ -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