Running ZeroNet as a SystemD service

in #systemd7 years ago (edited)

Introduction

I am personally using ZeroNet's snap package instead of the tarball.
First of all you should check if your system is compatible with snaps and if snapd is installed.
If you are using Ubuntu (or derivatives) 16.04 LTS or newer it should be installed and working.

Installing ZeroNet via snap

It is as simple as snap install zeronet.

Installing ZeroNet manually (not recommended)

Refer to the official website.

Creating service file

User Service

If you plan to use ZeroNet on a per user basis you should use a user service.

  • User services are located at multiple locations. The best place to put custom services is ~/.config/systemd/user. If the directories do not exist, you can create them first: $ mkdir -p ~/.config/systemd/user.
  • After that create a new file there with your favorite text editor (in my case nano) called zeronet.service (it may be called different as long as you keep the .service extension): $ nano ~/.config/systemd/user/zeronet.service
  • Fill your file with the following contents:
[Unit]
Description=ZeroNet Daemon Instance
After=network.target

[Service]
Type=simple
ExecStart=/snap/bin/zeronet --enable-tor

[Install]
WantedBy=default.target

NOTE: If you don't want to use TOR you may remove the --enable-tor flag.. Tor is bundled with the snap. No further configuration required.

  • Now you can start zeronet by running: $ systemctl --user start zeronet
  • Then check it's output: $ systemctl --user status zeronet
  • (Optional) You can allow systemd to start the service automatically on boot: $ systemctl --user enable zeronet

System Service

If you plan to use ZeroNet globally on a system you should use the system service. System services are located at multiple locations. The best place to put custom services is /etc/systemd/system.

  • You should create a new user explicitly for zeronet: # adduser --disabled-login zeronet
  • After that create a new file with your favorite text editor (in my case nano) called zeronet.service (it may be called different as long as you keep the .service extension): # nano /etc/systemd/system/zeronet.service
  • Fill your file with the following contents:
[Unit]
Description=ZeroNet Daemon Instance
After=network.target

[Service]
Type=simple
User=zeronet
Group=zeronet
ExecStart=/snap/bin/zeronet --enable-tor

[Install]
WantedBy=multi-user.target

NOTE: If you don't want to use TOR you may remove the --enable-tor flag.. Tor is bundled with the snap. No further configuration required.

  • Now you can start zeronet by running: # systemctl start zeronet
  • Then check it's output: # systemctl status zeronet
  • (Optional) You can allow systemd to start the service automatically on boot: # systemctl enable zeronet

See also

How to install snapd
ZeroNet
ZeroNet Docs

Sort:  

Congratulations @scrumplex! You received a personal award!

1 Year on Steemit

Click here to view your Board

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @scrumplex! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!