Skip to content

Commit

Permalink
Merge ElementsProject#865: Init: add elementsd.service file
Browse files Browse the repository at this point in the history
536939e init: update the elementsd.service file with some additions found in last Bitcoin Core version, ie PermissionsStartONly=true, ExecStartPre=/bin/chgrp elements /etc/elements, TimeoutStopSec=600 and ProtectHome=true (Sosthene00)
c884cad init: renamed bitcoind.service to elementsd.service (Sosthene00)

Pull request description:

  (This is a cleaned up version of ElementsProject#849 )
  I set up a Bitcoin Core and an Elements node on a Ubuntu machine for testing, and noticed that there was no elementsd.service file available in Elements repo as I expected, but a bitcoind.service file that seems to be an outdated version of the file in the Bitcoin Core repository.

  Since I needed to create a systemd service, I modified the most recent version of bitcoind.service file for elementsd as it seems fit to me.

  Besides replacing all occurrences of bitcoin and bitcoind, I also moved the debug.log file to another dir and the path to the bin is also different (/usr/local/bin/elementsd). This might be too specific to my project though.

  I suggest to add it to the Elements repository along the existing files, as maybe some people might find it useful.

  I'm pretty rookie with systemd too, I tried to stick to the example and recommandation in the Bitcoin Core repository, but I'd be glad if someone had suggestions to improve this.

Tree-SHA512: 8b07203b5e7c44d46fe5a9e6ba399ee44b89e037d000b51a0ecd473c4e924f5f8305369a8c7718d9d058a6d1a299d52fa1a397a264cd4c4e5733e286567caad2
  • Loading branch information
stevenroose committed Apr 16, 2020
2 parents af23572 + 536939e commit a19c972
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions contrib/init/bitcoind.service → contrib/init/elementsd.service
Original file line number Diff line number Diff line change
@@ -1,47 +1,53 @@
# It is not recommended to modify this file in-place, because it will
# be overwritten during package upgrades. If you want to add further
# options or overwrite existing ones then use
# $ systemctl edit bitcoind.service
# $ systemctl edit elementsd.service
# See "man systemd.service" for details.

# Note that almost all daemon options could be specified in
# /etc/bitcoin/bitcoin.conf, except for those explicitly specified as arguments
# in ExecStart=
# /etc/elements/elements.conf, but keep in mind those explicitly
# specified as arguments in ExecStart= will override those in the
# config file.

[Unit]
Description=Bitcoin daemon
Description=Elements daemon
After=network.target

[Service]
ExecStart=/usr/bin/bitcoind -daemon \
-pid=/run/bitcoind/bitcoind.pid \
-conf=/etc/bitcoin/bitcoin.conf \
-datadir=/var/lib/bitcoind
ExecStart=/usr/bin/elementsd -daemon \
-pid=/run/elementsd/elementsd.pid \
-conf=/etc/elements/elements.conf \
-datadir=/var/lib/elementsd

# Make sure the config directory is readable by the service user
PermissionsStartOnly=true
ExecStartPre=/bin/chgrp elements /etc/elements

# Process management
####################

Type=forking
PIDFile=/run/bitcoind/bitcoind.pid
PIDFile=/run/elementsd/elementsd.pid
Restart=on-failure
TimeoutStopSec=600

# Directory creation and permissions
####################################

# Run as bitcoin:bitcoin
User=bitcoin
Group=bitcoin
# Run as elements:elements
User=elements
Group=elements

# /run/bitcoind
RuntimeDirectory=bitcoind
# /run/elementsd
RuntimeDirectory=elementsd
RuntimeDirectoryMode=0710

# /etc/bitcoin
ConfigurationDirectory=bitcoin
# /etc/elements
ConfigurationDirectory=elements
ConfigurationDirectoryMode=0710

# /var/lib/bitcoind
StateDirectory=bitcoind
# /var/lib/elementsd
StateDirectory=elementsd
StateDirectoryMode=0710

# Hardening measures
Expand All @@ -53,6 +59,9 @@ PrivateTmp=true
# Mount /usr, /boot/ and /etc read-only for the process.
ProtectSystem=full

# Deny access to /home, /root and /run/user
ProtectHome=true

# Disallow the process and all of its children to gain
# new privileges through execve().
NoNewPrivileges=true
Expand Down

0 comments on commit a19c972

Please sign in to comment.