IPFS and Fuse

the worlds data in your filesystem

Published June 5, 2020 #ipfs #fuse #howto

IPFS is cool. It’s a peer to peer distributed file system, or graph database, where you reference the data by its hash. This has the great property that the data is no longer tied to a particular computer or server. It can be spread around and you can get it from anybody without worrying if they’ve changed or alterted it in any way. If you know what you are looking for, you don’t need to worry about who you get it from.

Lets see how we can use the Fuse interface, so that we can use our regular shell scripting toolbox to access and process data on the network.

Installing fuse on Linux

sudo apt-get install fuse

Make sure you are in the fuse group:

sudo groupadd fuse
sudo usermod -a -G fuse $USER

Edit /etc/fuse.conf and enable user_allow_other.

Installing Fuse on OSX

I’ve not tried it, but here’s a link to the OSXFuse project.

Setting up the mount points

# make the directories
sudo mkdir /ipfs
sudo mkdir /ipns

# chown them so ipfs can use them without root permissions
sudo chown $USER /ipfs
sudo chown $USER /ipns

Install IPFS

Download ipfs for your platform and install. e.g.:

cd $(mktemp -d)
wget https://dist.ipfs.io/go-ipfs/v0.5.1/go-ipfs_v0.5.1_linux-amd64.tar.gz
tar xzvf go-ipfs_v0.5.1_linux-amd64.tar.gz
cd go-ipfs
sudo sh install.sh

The initialise ipfs and start ipfs

ipfs init
ipfs config --json Mounts.FuseAllowOther true
ipfs daemon --mount

Find some content

We can look up the CID of some files

dig +noall +answer TXT _dnslink.docs.ipfs.io| sed 's/.*\/ipfs/\/ipfs/;s/"//'

Which at the time of this writing outputs /ipfs/bafybeicksctt6uom4iltnel6hqmgwaphlazrpzq5wv37bpjnmzintdq7su.

And then we can go into that directory and start up a webserver.

cd /ipfs/bafybeicksctt6uom4iltnel6hqmgwaphlazrpzq5wv37bpjnmzintdq7su

Lets start up a webserver and check it out:

python -m SimpleHTTPServer

And when you visit localhost:8000 you have a copy of that specific version of their documentation site served from your local filesystem.


The FUSE gateway isn’t super stable, so there are some potential issues with this. But its an interesting distrubtion mechanism where you could have ngnix serving files right from /ipfs or /ipns, and be able to push changed locally on your computer and then have the webservers automatically pick them up.

This is also an easy way to interact with large files using a basic script that doesn’t need to interact with the ipfs api’s directly.

Read next

Next Post: Beginning Emacs
Previous Post: Playing with deno

See also

Setting up IPFS on a chromebook

Connecting to the world

Lets look at how to run an ipfs node on a chromebook. We are using the linux container for this, and in order to get the experience right we’ll need to install some chrome extensions to make it work seamlessly.

Read more

Book Image Shortcode for Hugo

Lets link to bookshop

HappyFunCorp helped build Bookshop.org which is an online bookstore that distributes 30% of the book profits to independent bookstores in your area. Basically it’s a place that people can link to that isn’t Amazon, and that will kick some money to your local community. I wanted to find a way to easily create links to these product pages, and show images if needed. There’s no API to access bookshop (I asked on our internal dev channel) but I know how to write a script so I cobbled something together and made a hugo shortcode to render stuff on my blog.

Read more

Styling tables with Hugo

Markdown sometimes isn’t enough

Markdown is a nice format to write it, but sometimes you need to add HTML classes directly to the output to make it look how you want. Here’s a way to do that using hugo shortcodes. Create a table shortcode Put this in /layouts/shortcodes/table.html: {{ $htmlTable := .Inner | markdownify }} {{ $class := .Get 0 }} {{ $old := "<table>" }} {{ $new := printf "<table class=\"%s\">" $class }} {{ $htmlTable := replace $htmlTable $old $new }} {{ $htmlTable | safeHTML }} Create a table Like this:

Read more