Skip to content

Instantly share code, notes, and snippets.

@m3dwards
Forked from jeffrade/bitcoind-start.sh
Last active September 6, 2023 13:02
Show Gist options
  • Save m3dwards/3517138bbb99e8d4c9bd42e607ca2169 to your computer and use it in GitHub Desktop.
Save m3dwards/3517138bbb99e8d4c9bd42e607ca2169 to your computer and use it in GitHub Desktop.
bitcoind systemd service and start script.
#!/bin/bash
# Just a simple wrapper to start bitcoind.
#
# If using systemd, simply create a file (e.g. /etc/systemd/system/bitcoind.service)
# from example file below and add this script in ExecStart.
# https://raw.521000.best-/bitcoin/bitcoin/76deb30550b2492f9c8d9f0302da32025166e0c5/contrib/init/bitcoind.service
#
# Then run following to always start:
# systemctl enable bitcoind
#
# and the following to start immediately:
# systemctl start bitcoind
# If you are mounting a secondary disk, find the UUID of your
# disk and a line entry in /etc/fstab e.g.
#
# UUID=foo-bar-1234 /path-to-dir/.bitcoin ext4 defaults 0 0
set -e
echo "Starting bitcoind..."
/opt/bitcoin/bitcoin-25.0/bin/bitcoind -pid=/home/bitcoin/.bitcoin/bitcoind.pid
echo "Done!"
# Install this in /etc/systemd/system/
# See below for more details and options
# https://raw.521000.best-/bitcoin/bitcoin/76deb30550b2492f9c8d9f0302da32025166e0c5/contrib/init/bitcoind.service
# Then run following to always start:
# systemctl enable bitcoind
#
# and the following to start immediately:
# systemctl start bitcoind
[Unit]
Description=Bitcoin daemon
After=network.target
[Service]
ExecStart=/opt/bitcoin/bitcoind-start.sh
# Process management
####################
Type=forking
PIDFile=/home/bitcoin/.bitcoin/bitcoind.pid
Restart=on-failure
RestartSec=20
# Directory creation and permissions
####################################
# Run as bitcoin:bitcoin or <youruser>
User=bitcoin
Group=bitcoin
# Hardening measures
####################
# Provide a private /tmp and /var/tmp.
PrivateTmp=true
# Use a new /dev namespace only populated with API pseudo devices
# such as /dev/null, /dev/zero and /dev/random.
PrivateDevices=true
# Deny the creation of writable and executable memory mappings.
MemoryDenyWriteExecute=true
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment