Update update.sh

This commit is contained in:
ADS-B related code 2023-03-16 07:57:34 -07:00 • committed by GitHub
commit d2ccf23320
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -84,15 +84,21 @@ function revision() {
}
function getGIT() {
# getGIT $REPO $BRANCH $TARGET (directory)
echo "--- start getGIT() ---"
if [[ -z "$1" ]] || [[ -z "$2" ]] || [[ -z "$3" ]]; then echo "getGIT wrong usage, check your script or tell the author!" 1>&2; return 1; fi
REPO="$1"; BRANCH="$2"; TARGET="$3"; pushd .; tmp=/tmp/getGIT-tmp.$RANDOM.$RANDOM
echo "--- 2nd getGIT() ---"
if cd "$TARGET" &>/dev/null && [[ $(git remote get-url origin) == "$REPO" ]] && git fetch --depth 1 origin "$BRANCH" && git reset --hard FETCH_HEAD; then popd && return 0; fi
popd; if ! cd /tmp || ! rm -rf "$TARGET"; then return 1; fi
echo "--- 3rd getGIT() ---"
if git clone --depth 1 --single-branch --branch "$2" "$1" "$3"; then return 0; fi
echo "--- 4th getGIT() ---"
if wget -O "$tmp" "${REPO%".git"}/archive/$BRANCH.zip" && unzip "$tmp" -d "$tmp.folder"; then
if mv -fT "$tmp.folder/$(ls $tmp.folder)" "$TARGET"; then rm -rf "$tmp" "$tmp.folder"; return 0; fi
fi
echo "--- 5th getGIT() ---"
rm -rf "$tmp" "$tmp.folder"; return 1
echo "--- end getGIT() ---"
}
REPO="https://github.com/adsbfi/adsb-fi-scripts.git"