From 74af7fa9a602bc3b49cfd92f59a174520cee6b9e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 10 Jan 2022 14:48:34 +0100 Subject: [PATCH] bin/update: Fix repository retrieval --- bin/update | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/update b/bin/update index 30dd4f52..a0422227 100755 --- a/bin/update +++ b/bin/update @@ -38,8 +38,15 @@ FETCHED_REPOS=(); for repo_name in "${SOURCE_REPOSITORIES[@]}"; do if [ ! -d "sources.d/$repo_name" ]; then FETCHED_REPOS+=( $repo_name ); - wget -q -O - https://github.com/Icinga/$repo_name/archive/main.tar.gz | tar xz - mv $repo_name-main/ sources.d/$repo_name + + DEFAULT_BRANCH="master" + HTTP_STATUS=$(curl -Is https://api.github.com/repos/Icinga/$repo_name/branches/master | head -n 1 | awk '{ print $2 }') + if [ "$HTTP_STATUS" == "301" ]; then + DEFAULT_BRANCH="main" + fi + + wget -q -O - https://github.com/Icinga/$repo_name/archive/$DEFAULT_BRANCH.tar.gz | tar xz + mv $repo_name-$DEFAULT_BRANCH/ sources.d/$repo_name fi done