Created
March 8, 2022 16:09
-
-
Save stackdump/297cba4aa30fc41ae0ffd67ce2cb4d44 to your computer and use it in GitHub Desktop.
snapshot Minetest world with IPFS
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
#!/usr/bin/env bash | |
# backup world in IPFS | |
cd "${BASH_SOURCE%/*}" || exit | |
ROOT='vevr.se' | |
WORLD="foo7" | |
TS=$(date +%s) | |
ARCHIVE="${WORLD}.${TS}.tgz" | |
NSKEY=k51qzi5uqu5dhe82f7mh0jc7exsq938ughiappzzdrlfh5y3mh28n593qwg71p | |
OLDPATH=$(ipfs resolve /ipns/${NSKEY}) | |
tar -czf ${ARCHIVE} ${WORLD} | |
CID=$(ipfs add ${ARCHIVE} -q) | |
# echo "${WORLD} snapshot: /ipfs/${CID}" | |
ipfs files write --create --truncate "/${ROOT}/worlds/foo7.tgz" ${ARCHIVE} | |
# Change entry in Mutable file system | |
MFSROOT=$(ipfs files stat "/${ROOT}" --hash) | |
# update our IPNS key to point to latest Filesytem | |
ipfs name publish ${MFSROOT} | |
# check resolution | |
NEWPTH=$(ipfs resolve /ipns/${NSKEY}) | |
echo "Updated ${OLDPATH} => ${NEWPTH}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This changes the published IPFS directory
DNS is set to point to the primay key (starts with k51qz...)
Part of the nginx config exposes the IPFS proxy using the subdomain to pass the IPNS name we want to use
When file is accessed via web - we get some goodies in the headers