Skip to content

Instantly share code, notes, and snippets.

@arbal
Created January 2, 2021 19:26
Show Gist options
  • Save arbal/408cfa432082e16b9975dee0e0b3bda2 to your computer and use it in GitHub Desktop.
Save arbal/408cfa432082e16b9975dee0e0b3bda2 to your computer and use it in GitHub Desktop.
Download and install latest release of 'duf' from github for Debian / Ubuntu on amd64 / armhf (Raspberry Pi 4)
#!/usr/bin/env bash
set -euo pipefail
# install-duf-latest-deb.sh
# - Downloads and installs the latest duf (https://github.com/muesli/duf) release from github
# - Tested for Ubuntu & Debian running on amd64 & armhf
# Enable xtrace if the DEBUG environment variable is set
if [[ ${DEBUG-} =~ ^1|yes|true$ ]]; then
set -o xtrace # Trace the execution of the script (debug)
fi
# A better class of script...
set -o errexit # Exit on most errors (see the manual)
set -o errtrace # Make sure any error trap is inherited
set -o nounset # Disallow expansion of unset variables
set -o pipefail # Use last non-zero exit code in a pipeline
# Get arch
arch="$(dpkg --print-architecture)"
# Workaround for arch mismatch on rpi4
[[ "$arch" == "armhf" ]] && arch="armv7"
# Download to ./duf-latest.deb
curl --silent curl --silent "https://api.github.com/repos/muesli/duf/releases/latest" | jq -r ".assets[] | select(.name | test(\"linux_${arch}.deb\")) | .browser_download_url" | wget -O duf-latest.deb -i - && dpkg -i duf-latest.deb
# Optional: run 'duf' to show installed version (for logging, pssh, etc.)
echo
duf -version
@arbal
Copy link
Author

arbal commented Jan 2, 2021

Please read the script first, don't just trust it/me

Run using:
curl -sS https://gist.githubusercontent.com/arbal/408cfa432082e16b9975dee0e0b3bda2/raw/install-duf-latest-deb.sh | bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment