mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-09-27 20:16:22 +02:00
#2826 improve bitcoind service files
This commit is contained in:
@@ -1,30 +1,79 @@
|
|||||||
# RaspiBlitz: systemd unit for bitcoind
|
# RaspiBlitz: systemd unit for bitcoind
|
||||||
|
# based on https://github.com/bitcoin/bitcoin/blob/master/contrib/init/bitcoind.service
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Bitcoin-Daemon
|
Description=Bitcoin daemon
|
||||||
Wants=network.target
|
|
||||||
After=network.target
|
After=network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
# for use with sendmail alert
|
# for use with sendmail alert
|
||||||
#OnFailure=systemd-sendmail@%n
|
#OnFailure=systemd-sendmail@%n
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=bitcoin
|
ExecStartPre=-/home/admin/config.scripts/blitz.systemd.sh log blockchain STARTED
|
||||||
Group=bitcoin
|
ExecStart=/usr/local/bin/bitcoind -daemonwait \
|
||||||
|
-pid=/mnt/hdd/bitcoin/bitcoind.pid \
|
||||||
|
-conf=/mnt/hdd/bitcoin/bitcoin.conf \
|
||||||
|
-datadir=/mnt/hdd/bitcoin \
|
||||||
|
-debuglogfile=/mnt/hdd/bitcoin/debug.log
|
||||||
|
|
||||||
|
# Make sure the config directory is readable by the service user
|
||||||
|
PermissionsStartOnly=true
|
||||||
|
ExecStartPre=/bin/chgrp bitcoin /mnt/hdd/bitcoin
|
||||||
|
|
||||||
|
# Process management
|
||||||
|
####################
|
||||||
|
|
||||||
Type=forking
|
Type=forking
|
||||||
PIDFile=/mnt/hdd/bitcoin/bitcoind.pid
|
PIDFile=/mnt/hdd/bitcoin/bitcoind.pid
|
||||||
ExecStartPre=-/home/admin/config.scripts/blitz.systemd.sh log blockchain STARTED
|
Restart=on-failure
|
||||||
ExecStart=/usr/local/bin/bitcoind -daemon -conf=/mnt/hdd/bitcoin/bitcoin.conf -pid=/mnt/hdd/bitcoin/bitcoind.pid -debuglogfile=/mnt/hdd/bitcoin/debug.log
|
TimeoutStartSec=infinity
|
||||||
Restart=always
|
TimeoutStopSec=600
|
||||||
TimeoutSec=120
|
|
||||||
RestartSec=30
|
# Directory creation and permissions
|
||||||
|
####################################
|
||||||
|
|
||||||
|
# Run as bitcoin:bitcoin
|
||||||
|
User=bitcoin
|
||||||
|
Group=bitcoin
|
||||||
|
|
||||||
|
# /mnt/hdd/bitcoin
|
||||||
|
RuntimeDirectory=bitcoin
|
||||||
|
RuntimeDirectoryMode=0710
|
||||||
|
|
||||||
|
# /mnt/hdd/bitcoin
|
||||||
|
ConfigurationDirectory=bitcoin
|
||||||
|
ConfigurationDirectoryMode=0710
|
||||||
|
|
||||||
|
# /mnt/hdd/bitcoin
|
||||||
|
StateDirectory=bitcoin
|
||||||
|
StateDirectoryMode=0710
|
||||||
|
|
||||||
StandardOutput=null
|
StandardOutput=null
|
||||||
StandardError=journal
|
StandardError=journal
|
||||||
|
|
||||||
# Hardening measures
|
# Hardening measures
|
||||||
|
####################
|
||||||
|
|
||||||
|
# Provide a private /tmp and /var/tmp.
|
||||||
PrivateTmp=true
|
PrivateTmp=true
|
||||||
|
|
||||||
|
# Mount /usr, /boot/ and /etc read-only for the process.
|
||||||
ProtectSystem=full
|
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
|
NoNewPrivileges=true
|
||||||
|
|
||||||
|
# Use a new /dev namespace only populated with API pseudo devices
|
||||||
|
# such as /dev/null, /dev/zero and /dev/random.
|
||||||
PrivateDevices=true
|
PrivateDevices=true
|
||||||
|
|
||||||
|
# Deny the creation of writable and executable memory mappings.
|
||||||
|
MemoryDenyWriteExecute=true
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
@@ -229,28 +229,80 @@ signet.addnode=nsgyo7begau4yecc46ljfecaykyzszcseapxmtu6adrfagfrrzrlngyd.onion:38
|
|||||||
sudo cp /home/admin/assets/bitcoind.service /etc/systemd/system/bitcoind.service
|
sudo cp /home/admin/assets/bitcoind.service /etc/systemd/system/bitcoind.service
|
||||||
else
|
else
|
||||||
# /etc/systemd/system/${prefix}bitcoind.service
|
# /etc/systemd/system/${prefix}bitcoind.service
|
||||||
|
# based on https://github.com/bitcoin/bitcoin/blob/master/contrib/init/bitcoind.service
|
||||||
echo "
|
echo "
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Bitcoin daemon on ${CHAIN}
|
Description=Bitcoin daemon on ${CHAIN}
|
||||||
|
|
||||||
|
After=network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=bitcoin
|
PIDFile=/mnt/hdd/bitcoin/${prefix}bitcoind.pid
|
||||||
Group=bitcoin
|
ExecStart=/usr/local/bin/bitcoind -${CHAIN} -daemonwait \
|
||||||
|
-pid=/mnt/hdd/bitcoin/${prefix}bitcoind.pid \
|
||||||
|
-conf=/mnt/hdd/bitcoin/bitcoin.conf \
|
||||||
|
-datadir=/mnt/hdd/bitcoin \
|
||||||
|
-debuglogfile=/mnt/hdd/bitcoin/${prefix}debug.log
|
||||||
|
|
||||||
|
# Make sure the config directory is readable by the service user
|
||||||
|
PermissionsStartOnly=true
|
||||||
|
ExecStartPre=/bin/chgrp bitcoin /mnt/hdd/bitcoin
|
||||||
|
|
||||||
|
# Process management
|
||||||
|
####################
|
||||||
|
|
||||||
Type=forking
|
Type=forking
|
||||||
PIDFile=/mnt/hdd/bitcoin/${prefix}bitcoind.pid
|
PIDFile=/mnt/hdd/bitcoin/${prefix}bitcoind.pid
|
||||||
ExecStart=/usr/local/bin/bitcoind -${CHAIN} -daemon -pid=/mnt/hdd/bitcoin/${prefix}bitcoind.pid -debuglogfile=/mnt/hdd/bitcoin/${prefix}debug.log
|
Restart=on-failure
|
||||||
Restart=always
|
TimeoutStartSec=infinity
|
||||||
TimeoutSec=120
|
TimeoutStopSec=600
|
||||||
RestartSec=30
|
|
||||||
|
# Directory creation and permissions
|
||||||
|
####################################
|
||||||
|
|
||||||
|
# Run as bitcoin:bitcoin
|
||||||
|
User=bitcoin
|
||||||
|
Group=bitcoin
|
||||||
|
|
||||||
|
# /mnt/hdd/bitcoin
|
||||||
|
RuntimeDirectory=bitcoin
|
||||||
|
RuntimeDirectoryMode=0710
|
||||||
|
|
||||||
|
# /mnt/hdd/bitcoin
|
||||||
|
ConfigurationDirectory=bitcoin
|
||||||
|
ConfigurationDirectoryMode=0710
|
||||||
|
|
||||||
|
# /mnt/hdd/bitcoin
|
||||||
|
StateDirectory=bitcoin
|
||||||
|
StateDirectoryMode=0710
|
||||||
|
|
||||||
StandardOutput=null
|
StandardOutput=null
|
||||||
StandardError=journal
|
StandardError=journal
|
||||||
|
|
||||||
# Hardening measures
|
# Hardening measures
|
||||||
|
####################
|
||||||
|
|
||||||
|
# Provide a private /tmp and /var/tmp.
|
||||||
PrivateTmp=true
|
PrivateTmp=true
|
||||||
|
|
||||||
|
# Mount /usr, /boot/ and /etc read-only for the process.
|
||||||
ProtectSystem=full
|
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
|
NoNewPrivileges=true
|
||||||
|
|
||||||
|
# Use a new /dev namespace only populated with API pseudo devices
|
||||||
|
# such as /dev/null, /dev/zero and /dev/random.
|
||||||
PrivateDevices=true
|
PrivateDevices=true
|
||||||
|
|
||||||
|
# Deny the creation of writable and executable memory mappings.
|
||||||
|
MemoryDenyWriteExecute=true
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
" | sudo tee /etc/systemd/system/${prefix}bitcoind.service
|
" | sudo tee /etc/systemd/system/${prefix}bitcoind.service
|
||||||
|
Reference in New Issue
Block a user