From 3eae36f2937602c1a12c86ea500c0d296faf6371 Mon Sep 17 00:00:00 2001 From: Shunsuke KITADA Date: Mon, 4 Mar 2024 11:20:58 +0900 Subject: [PATCH] Update for age (#221) * update for age * update --- install/ubuntu/common/age.sh | 42 ++------------------------------ install/ubuntu/server/sheldon.sh | 2 +- 2 files changed, 3 insertions(+), 41 deletions(-) diff --git a/install/ubuntu/common/age.sh b/install/ubuntu/common/age.sh index b4e81b3a..bf2e77bb 100644 --- a/install/ubuntu/common/age.sh +++ b/install/ubuntu/common/age.sh @@ -10,46 +10,8 @@ function is_jq_installed() { command -v jq &>/dev/null } -function get_latest_version() { - local url="https://api.github.com/repos/FiloSottile/age/releases/latest" - - local user_opt - if [[ -n "${DOTFILES_GITHUB_PAT:-}" ]]; then - user_opt="-u Saki-htr:${DOTFILES_GITHUB_PAT}" - else - user_opt="" - fi - - curl "${user_opt}" -s "${url}" | jq -r '.tag_name' -} - function install_age() { - local version - version=$(get_latest_version) - - local dir_name="age" - local tar_name="${dir_name}-${version}-linux-amd64.tar.gz" - - local url="https://github.com/FiloSottile/age/releases/download/${version}/age-${version}-linux-amd64.tar.gz" - - # create tmp directory - local tmp_dir - tmp_dir="$(mktemp -d)" - - # download tar.gz file - local tar_path="${tmp_dir%/}/${tar_name}" - wget -qO "${tar_path}" "${url}" - - # decompress the tar.gz file - tar -xzf "${tar_path}" -C "${tmp_dir}" - - # move the binary to the directory - local local_bin_dir="${HOME%/}/.local/bin" - mkdir -p "${local_bin_dir}" - mv -v "${tmp_dir%/}/${dir_name}/age" "${local_bin_dir}" - - # clean up the tmp directory - rm -rf "${tmp_dir}" + sudo apt-get install -y age } function install_jq() { @@ -59,7 +21,7 @@ function install_jq() { } function uninstall_age() { - rm -v "${HOME%/}/.local/bin/age" + sudo apt-get remove -y age } function uninstall_jq() { diff --git a/install/ubuntu/server/sheldon.sh b/install/ubuntu/server/sheldon.sh index 7df5d12c..3b8340de 100644 --- a/install/ubuntu/server/sheldon.sh +++ b/install/ubuntu/server/sheldon.sh @@ -11,7 +11,7 @@ readonly BIN_DIR="${HOME}/.local/bin/server" function install_sheldon() { mkdir -p "${BIN_DIR}" - if [[ -n "${DOTFILES_GITHUB_PAT}" ]]; then + if [[ -n "${DOTFILES_GITHUB_PAT:-}" ]]; then export GITHUB_TOKEN=${DOTFILES_GITHUB_PAT} fi