Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for age #221

Merged
merged 2 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 2 additions & 40 deletions install/ubuntu/common/age.sh
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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