Skip to content

Commit

Permalink
Update for age (#221)
Browse files Browse the repository at this point in the history
* update for age

* update
  • Loading branch information
shunk031 committed Mar 4, 2024
1 parent 3c9dd2c commit 3eae36f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 41 deletions.
42 changes: 2 additions & 40 deletions install/ubuntu/common/age.sh
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion install/ubuntu/server/sheldon.sh
Expand Up @@ -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

Expand Down

0 comments on commit 3eae36f

Please sign in to comment.