Skip to content

Commit

Permalink
lint: consistent indentation, shellcheck friendly to that added script
Browse files Browse the repository at this point in the history
  • Loading branch information
yarikoptic committed May 7, 2024
1 parent ed08013 commit 41e8f28
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions scripts/replace_neurodesk_urls
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ function geturls() {
git -c annex.alwayscommit=false annex whereis --json "$1" | jq '.whereis[] | select(.description == "web") | .urls' | sed -e "s|[\"',]||g" | grep "$2" || :
}

for f in images/neurodesk/*.simg ; do
for f in images/neurodesk/*.simg ; do
echo "INFO: file $f"
# shellcheck disable=SC2207
oracleurls=( $(geturls "$f" oraclecloud) )
# shellcheck disable=SC2207
cloudfronturls=( $(geturls "$f" cloudfront) )
if [ -z "${oracleurls[*]}" ]; then
if [ -n "${cloudfronturls[*]}" ]; then
Expand All @@ -22,29 +24,30 @@ for f in images/neurodesk/*.simg ; do
exit 1
fi
fi
# shellcheck disable=SC2001
img=$(echo "${oracleurls[*]}" | sed -e 's,.*/,,g' )
if [ -z "$img" ]; then
echo "ERROR: Got empty image from ${oracleurls[*]}"
exit 1
fi
if [ -z "$img" ]; then
echo "ERROR: Got empty image from ${oracleurls[*]}"
exit 1
fi
newurl="https://d15yxasja65rk8.cloudfront.net/$img"
# let's verify that it is not 404
ret=$(curl -o /dev/null -s -I -w "%{http_code}" "$newurl")
if [ $ret != 200 ]; then
if [ "$ret" != 200 ]; then
echo "ERROR: $newurl - could not verify presence: $ret . Will not be added" >&2
#exit 1
else
echo "OK: $newurl" >&2
if [ -n "${cloudfronturls[*]}" ]; then
echo " INFO: cloudfront url seems to be already known -- $cloudfronturls . Not adding"
else
echo " INFO: adding $newurl to $f"
echo " INFO: adding $newurl to $f"
git -c annex.alwayscommit=false annex addurl "--file=$f" "$newurl"
fi
fi
echo " INFO: removing ${#oracleurls[@]} oracle urls"
for url in "${oracleurls[@]}"; do
git -c annex.alwayscommit=false annex rmurl "$f" "$url"
git -c annex.alwayscommit=false annex rmurl "$f" "$url"
done
done
# Trigger git-annex commit
Expand Down

0 comments on commit 41e8f28

Please sign in to comment.