check for lazystream update on container start (#47)

This commit is contained in:
Cory Forsstrom
2021-04-19 11:30:58 -07:00
committed by GitHub
parent c3c7b7f249
commit 91eed809c4
3 changed files with 36 additions and 0 deletions

View File

@@ -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