How to launch Duniter, the Libre Money node daemon, at startup as a service using its own user.

If you don’t know about Duniter and Libre Money, you should absolutely have a look at it, as it is a revolutionary system to free ourselves from the current (corrupt) banking system. It is far more revolutionary and liberating than Bitcoin or any other alternative currency. This is not a currency you adopt because you want to make a fortune off other people’s back, but because you believe we all deserve equal opportunities, here and today, there and tomorrow.

So once duniter is installed (please ping me if you need some article on that) and set up and running using its own duniter account, now is the time to set it up as a “set-and-forget” service (otherwise it becomes “forget” without setting, as everything else).

Ubuntu 16+

If you are on a “modern” systemd OS (recent Debian, Ubuntu 15+), you use systemd.

Create a file /etc/systemd/system/duniter.service :

[Unit]
Description=Duniter node
After=network.target
ConditionPathExists=/home/duniter/.config/duniter/duniter_default/duniter.db

[Service]
Group=duniter
User=duniter
Type=forking
ExecStart=/usr/bin/duniter webstart
ExecReload=/usr/bin/duniter webrestart
ExecStop=/usr/bin/duniter stop
Restart=on-failure

[Install]
WantedBy=multi-user.target

Note that I’m using webstart rather than start so that it is accessible through the webui at localhost:9220

Check that it is running when using the command:

systemctl start duniter.service

Once this is done, activate it at startup:

systemctl enable duniter.service

Ubuntu 14-

On Ubuntu 14, however, you have to use the old init.d system.

Create the file: sudo vi /etc/init.d/duniter

Paste in the content:

#!/bin/bash
# duniter daemon
# chkconfig: 345 20 80
# description: duniter daemon
# processname: duniter

NAME=Duniter
DESC="Duniter Daemon"

case "$1" in
start)
su -c "/usr/bin/duniter webstart" duniter
;;

status)
su -c "/usr/bin/duniter status" duniter
;;

stop)
su -c "/usr/bin/duniter stop" duniter
;;

restart)
su -c "/usr/bin/duniter webrestart" duniter
;;

*)

echo "Usage: $0 {status|start|stop|restart}"
exit 1
esac

Make sure that the permissions are 755 for root on the file.

Start the service and check that it is running (top, webui, etc):

sudo service duniter start

Then you can make it start when the machine starts:

sudo update-rc.d duniter defaults

Leave a comment