Skip to content

Instantly share code, notes, and snippets.

@koichirok
Created September 10, 2024 21:48
Show Gist options
  • Save koichirok/aca23bd7b301aa55e56ce0bcbac981ff to your computer and use it in GitHub Desktop.
Save koichirok/aca23bd7b301aa55e56ce0bcbac981ff to your computer and use it in GitHub Desktop.
Script to install latest rbw deb package from the rbw releases page
#!/bin/sh
#
# Install the latest rbw deb package from the rbw releases page.
#
# See https://github.com/doy/rbw for more information.
#
CURL=curl
PACKAGE_URL_BASE="https://git.tozt.net/rbw/releases/deb/"
$CURL -sL $PACKAGE_URL_BASE | sed -n -e 's/ \{2,\}/;/g' -e 's|<a href="\([^"]*.deb\)">\1</a>|\1|p' | (
latest_package=""
latest_time=0
while IFS=";" read -r filename timestamp size; do
time=$(date -d "$timestamp" +%s)
if [ "$time" -gt "$latest_time" ]; then
latest_time=$time
latest_package=$filename
fi
done
if [ -z "$latest_package" ]; then
echo "No packages found"
exit 1
fi
echo "===> Downloading $latest_package"
$CURL -L "$PACKAGE_URL_BASE$latest_package" -o "/tmp/$latest_package"
echo "===> Installing package"
if [ "$(whoami)" != "root" ]; then
sudo=sudo
fi
$sudo apt-get install -y "/tmp/$latest_package"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment