From 18bde96638dfb2abb8c10ba3e8ee247c3d2802d8 Mon Sep 17 00:00:00 2001 From: Youe Graillot Date: Sun, 27 Nov 2022 21:55:31 +0100 Subject: [PATCH] fix github rate limit wait --- root/etc/services.d/setup/run | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/root/etc/services.d/setup/run b/root/etc/services.d/setup/run index 3e5cab9..e999642 100644 --- a/root/etc/services.d/setup/run +++ b/root/etc/services.d/setup/run @@ -81,9 +81,10 @@ 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 )) + if [ "$(echo "$githubRate" | jq .remaining)" = "0" ]; then + deltaGithubResetTime=$(( $(echo "$githubRate" | jq .reset) - $(date +%s) + 5 )) + echo "[autoconfig] Waiting github rate limit reset : $deltaGithubResetTime seconds" + sleep $deltaGithubResetTime fi apiCall "POST" "command" '{"name":"InstallPlugin","githubUrl":"'$urlPlugin'"}'