Last active
April 18, 2020 14:59
-
-
Save craigmayhew/4af9e8ecc035fc0693472e56ca478e04 to your computer and use it in GitHub Desktop.
Pin domains locally from the address stored in each domains _dnslink DNS record
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################### | |
#### Run this as a regular cron, and #### | |
#### you will always have the latest #### | |
#### copy of websites stored locally! #### | |
############################################### | |
# add domains you care about pinning | |
DOMAINS[0]=craig.mayhew.io | |
DOMAINS[1]=bigprimes.net | |
for domain in "${DOMAINS[@]}" | |
do | |
# lookup dnslink record to fetch ipfs content address | |
DNSLINK=$(dig -t txt +short _dnslink.$domain) | |
# get just the IPFS hash which starts with Q | |
HASH=$(echo $DNSLINK | grep -o -e "Q\([a-zA-z0-9]*\)") | |
# pin it | |
ipfs pin add $HASH | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment