From e1f49102761e340e3ae52d8bc3de5b6cfe771150 Mon Sep 17 00:00:00 2001 From: Youe Graillot Date: Sat, 26 Nov 2022 13:07:13 +0100 Subject: [PATCH] auto-update deemix plugin with AUTOCONFIG --- root/etc/services.d/setup/run | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/root/etc/services.d/setup/run b/root/etc/services.d/setup/run index 7781ba0..a316b59 100644 --- a/root/etc/services.d/setup/run +++ b/root/etc/services.d/setup/run @@ -76,14 +76,22 @@ apiKey="$(curl \ $url/initialize.js | sed -n "s/apiKey: '\(.*\)'.*/\1/p")" -if ! isPresent $urlPlugin "system/plugins"; then - echo "[autoconfig] Installing plugin" +plugin=$(apiCall "GET" "system/plugins" | jq '.[]|select(.name=="Deemix")') + +if [ -z "$plugin" ] || [ "$(echo "$plugin" | jq .updateAvailable)" = "true" ]; then + echo "[autoconfig] Installing / Updating Deemix plugin" githubRate=$(curl -s https://api.github.com/rate_limit | jq .rate) if [ "$(echo "$githubRate" | jq .remaining)" = "60" ]; then echo "[autoconfig] Waiting github rate limit reset" sleep $(( $(echo "$githubRate" | jq .reset) - $(date +%s) + 5 )) fi apiCall "POST" "command" '{"name":"InstallPlugin","githubUrl":"'$urlPlugin'"}' + + while "$(apiCall "GET" "system/plugins" | jq '.[]|select(.name=="Deemix").updateAvailable')" -eq "true"; do + sleep 0.1 + done + echo "[autoconfig] Stopping" + /run/s6/basedir/bin/halt fi if ! isPresent "path" "rootFolder"; then echo "[autoconfig] Setting /music rootFolder"