For a Conceptual Introduction with no code see the blog IPFS - Introductory Concepts. For all my Tutorials that include code, I will attempt to package it into a one line script to make it simple to execute.
This tutorial is to explain how to setup an IPFS node on a Linux OS. It should work immediately with no modification needed with either Debian based distributions or CentOs. Please let me know if it doesn't work on your system.
For aesthetic value and readability, I will provide an explanation of what needs to be done, accompanied by a screenshot of code and a link to the whole script here. But please don't pipe to your root shell, that's silly.
1. Checking for your architecture to download the correct binary
3. Downloads the IPFS binary
4. Installing and initializing IPFS
5. Installing a SystemD Daemon Service
6. Starting and Enabling SystemD Daemon Service
The IPFS code offers versions for both 32bit and 64bit architecture. This first section of code is to check your architecture and store it in the variable architecture to be used later so that you can download the correct version automatically.
This section of the script checks to see which OS you are running, it only checks for CentOs and Debian at the moment, it could be improved. But this should work for all Debian based Operating Systems plus CentOs. This is only necessary to decide which update command to use.
This section might look a little complicated, but all it's doing is manipulating a string to construct the correct URI for downloading the IPFS binary based on your system architecture, and then using the curl command to download it.
First we unzip the file we just downloaded, then move into that directory and install it. Before you can use IPFS, it must be initiated first, this creates a directory in your home folder to store the files that you upload to it, and also a configuration file.
This section of code sets up an IPFS systemD daemon. A daemon is an application that runs in the background which you can set to always start up at boot time and to which you can add special firewall settings.
The final step is starting and enabling the daemon that you installed in the step above. Starting a daemon makes the program start now. Enabling a daemon sets the program to start automatically at boot time without you needing to prompt it to start.
After you have followed through this script, IPFS should start up automatically on reboot. You can then add files to be served on the IPFS network by typing the first line in the image below, but with the name of the file you want to add replacing test_directory/test_file1.
If you want to add an entire directory, include an -r flag to recursively add all files in a directory and sub-directories.
You can access files on the IPFS network either through an HTTP to IPFS gateway, or directly on the IPFS Network. The most well known HTTP gateway is https://ipfs.io.
To get a file from an HTTP gateway, you can visit the URI below in your browser:
For example, to get the header image of this blog you can visit the URI below.
To get a file directly from IPFS, type:
ipfs get <hash>.