New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add shell script version #9
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
IPFS public gateway checker: shell script version
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| #!/bin/bash | ||
|
|
||
| # IPFS public gateway checker v1.0 (shell script version) | ||
| # original repository: https://github.com/ipfs/public-gateway-checker | ||
| # this script added by Joss Brown: https://github.com/JayBrown | ||
|
|
||
| JSON_URL="https://raw.githubusercontent.com/ipfs/public-gateway-checker/master/gateways.json" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't it better to hardcode the list? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better to have the list in one place instead of multiple ones though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could (in a later version!) add some extra functionality. The script would then create an invisible file in |
||
| TESTHASH="Qmaisz6NMhDB51cCvNWa1GMS7LU1pAxdF4Ld6Ft9kZEP2a" | ||
|
|
||
| echo "Public IPFS Gateways" | ||
|
|
||
| GATEWAYS=$(curl --silent "$JSON_URL" | sed -e '$ d' -e '1,1d' -e 's/\"//g') | ||
| if [[ $GATEWAYS == "" ]] ; then | ||
| echo "Error: no gateways found." | ||
| exit | ||
| fi | ||
|
|
||
| GWNUM=$(echo "$GATEWAYS" | wc -l | xargs) | ||
|
|
||
| while read -r GATEWAY | ||
| do | ||
|
|
||
| GATEWAY=$(echo "$GATEWAY" | xargs) | ||
| TESTURL=$(echo "$GATEWAY" | sed -e "s-:hash,-$TESTHASH-" -e "s-:hash-$TESTHASH-") | ||
| DOMAIN=$(echo "$GATEWAY" | awk -F/ '{print $1"//"$3}') | ||
|
|
||
| if [[ $(curl --silent "$TESTURL") == "Hello from IPFS Gateway Checker" ]] ; then | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about using the option There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, would better to fix the URLs to be correct from the beginning instead, but be more future-proof to follow redirect so I agree. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use case: you run the script and But in this case, too, we could add a redirect option There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @victorbjelkholm @koalalorenzo You can ignore the original pull request. I have a new cli here. EDIT: seems to have been auto-added to the pull request. Neat. :) I haven't yet had the time to test it thoroughly, but preliminary runs seem to go well. Changes: |
||
| echo -e "✅ Online:\t$DOMAIN" | ||
| else | ||
| echo -e "❌ Offline:\t$DOMAIN" | ||
| fi | ||
|
|
||
| done < <(echo "$GATEWAYS") | ||
|
|
||
| echo "Done: $GWNUM gateways checked." | ||
| exit | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be
/usr/bin/env bashhere instead to ensure portability.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK