From de86ac216b9d465385e765cd7ed10746e89694ff Mon Sep 17 00:00:00 2001 From: Youe Graillot Date: Fri, 25 Nov 2022 20:28:24 +0100 Subject: [PATCH] handle github rate limiting --- root/etc/services.d/setup/run | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/root/etc/services.d/setup/run b/root/etc/services.d/setup/run index f237f98..b683241 100644 --- a/root/etc/services.d/setup/run +++ b/root/etc/services.d/setup/run @@ -52,6 +52,11 @@ if [ "$AUTOCONFIG" = "true" ]; then if ! isPresent $urlPlugin "system/plugins"; then echo "[autoconfig] Installing 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'"}' fi if ! isPresent "path" "rootFolder"; then