All Post's

A SystemD Unit for IPFS

IPFS or Interplanetary File System allows you to distribute Files and thus Websites and Videos over a distributed Net much like the Torrent Network. In order to use it on your machine you have to compile it manually or use a precompiled Version from the website. However the Binarys and the github Repo are lacking a SystemD unit file.

Writing the Files

A socket activated unit needs two files: a Socket file and a Unit file. But first of all: Where should a user generated systemd file live? For user created unit files there are two places to choose from: /etc/systemd/user/ or ~/.config/systemd/user/ however one can always choose /etc/systemd/system/.

So wherever you want to save your file here is what they should look like:

Initiate the Repo

If you are using ipfs for the first time you need to Initiate the Repo via ipfs init - you could also decide to use a service user for ipfs

Writing the service file

/etc/systemd/system/ipfs-daemon.service

[Unit]
Description=IPTS Daemon Service

[Service]
Type=simple
ExecStart=/usr/local/bin/ipfs daemon
User=**The User you initialized the service with**

[Install]
WantedBy=multi-user.target

Testing

As privileged user reload the systemctl daemon via systemctl daemon-reload to load the new service files. Next activate the socket file via systemctl enable ipfs-daemon.service --now and verify that the service is running systemctl status ipfs-dameon.service

Conclusion

Writing a systemD Unit is quite simple. An advanced topic would be socket activation. Thus only starting the service when the specified socket is called.