From 91eed809c4326865ae443b793adedc5f85878e34 Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Mon, 19 Apr 2021 11:30:58 -0700 Subject: [PATCH] check for lazystream update on container start (#47) --- root/etc/cont-init.d/60-update-lazystream | 36 +++++++++++++++++++ .../{60-chown-files => 70-chown-files} | 0 .../cont-init.d/{70-firstrun => 99-firstrun} | 0 3 files changed, 36 insertions(+) create mode 100644 root/etc/cont-init.d/60-update-lazystream rename root/etc/cont-init.d/{60-chown-files => 70-chown-files} (100%) rename root/etc/cont-init.d/{70-firstrun => 99-firstrun} (100%) diff --git a/root/etc/cont-init.d/60-update-lazystream b/root/etc/cont-init.d/60-update-lazystream new file mode 100644 index 0000000..3e0d9c2 --- /dev/null +++ b/root/etc/cont-init.d/60-update-lazystream @@ -0,0 +1,36 @@ +#!/usr/bin/with-contenv bash + +function prepend() { + while read line; + do echo "${1}${line}"; + done; +} + +exec 1> >(prepend "[update-lazystream] ") + +echo "checking for update" + +current_version=$(lazystream --version) +current_version=v${current_version:11} + +echo "installed version: ${current_version}" + +latest_release=$(curl -s https://api.github.com/repos/tarkah/lazystream/releases/latest | grep 'musl.tar.gz' | grep browser_download_url | cut -d '"' -f 4) +latest_version=$(echo $latest_release | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | head -n 1) + +echo "remote version: ${latest_version}" + +if [ $current_version != $latest_version ]; then + echo "newer version available, downloading..." + + wget https://github.com/tarkah/lazystream/releases/download/$latest_version/lazystream-$latest_version-x86_64-unknown-linux-musl.tar.gz -O lazystream.tar.gz; \ + tar xzf lazystream.tar.gz; \ + mv ././lazystream /usr/bin/lazystream; \ + rm lazystream.tar.gz; \ + rm -rf lazystream/; \ + chmod +x /usr/bin/lazystream + + echo "lazystream successfully updated to ${latest_version}" +else + echo "latest version already installed" +fi \ No newline at end of file diff --git a/root/etc/cont-init.d/60-chown-files b/root/etc/cont-init.d/70-chown-files similarity index 100% rename from root/etc/cont-init.d/60-chown-files rename to root/etc/cont-init.d/70-chown-files diff --git a/root/etc/cont-init.d/70-firstrun b/root/etc/cont-init.d/99-firstrun similarity index 100% rename from root/etc/cont-init.d/70-firstrun rename to root/etc/cont-init.d/99-firstrun