mirror of
https://github.com/rootzoll/raspiblitz.git
synced 2024-11-19 18:00:22 +01:00
* #4003 add bitcoin.check.sh to set debug file * add debug * change delimiter * set network on bitcoind service
This commit is contained in:
parent
f58a388cdb
commit
4e889be7d8
@ -11,6 +11,9 @@ txindex=0
|
||||
disablewallet=1
|
||||
peerbloomfilters=1
|
||||
datadir=/mnt/hdd/bitcoin
|
||||
main.debuglogfile=/mnt/hdd/bitcoin/debug.log
|
||||
test.debuglogfile=/mnt/hdd/bitcoin/testnet3/debug.log
|
||||
signet.debuglogfile=/mnt/hdd/bitcoin/signet/debug.log
|
||||
|
||||
# Connection settings
|
||||
rpcuser=raspibolt
|
||||
|
@ -1,58 +0,0 @@
|
||||
# RaspiBlitz: systemd unit for bitcoind
|
||||
# based on https://github.com/bitcoin/bitcoin/blob/master/contrib/init/bitcoind.service
|
||||
[Unit]
|
||||
Description=Bitcoin daemon
|
||||
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
# for use with sendmail alert
|
||||
#OnFailure=systemd-sendmail@%n
|
||||
|
||||
[Service]
|
||||
Environment='MALLOC_ARENA_MAX=1'
|
||||
ExecStartPre=-/home/admin/config.scripts/blitz.systemd.sh log blockchain STARTED
|
||||
ExecStart=/usr/local/bin/bitcoind -daemonwait \
|
||||
-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
|
||||
Restart=on-failure
|
||||
TimeoutStartSec=infinity
|
||||
TimeoutStopSec=600
|
||||
|
||||
# Directory creation and permissions
|
||||
####################################
|
||||
# Run as bitcoin:bitcoin
|
||||
User=bitcoin
|
||||
Group=bitcoin
|
||||
|
||||
StandardOutput=null
|
||||
StandardError=journal
|
||||
|
||||
# Hardening measures
|
||||
####################
|
||||
# Provide a private /tmp and /var/tmp.
|
||||
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
|
||||
# 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
|
82
home.admin/config.scripts/bitcoin.check.sh
Executable file
82
home.admin/config.scripts/bitcoin.check.sh
Executable file
@ -0,0 +1,82 @@
|
||||
#!/bin/bash
|
||||
|
||||
# command info
|
||||
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "-help" ]; then
|
||||
echo "# bitcoin.check.sh prestart [mainnet|testnet|signet]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
######################################################################
|
||||
# PRESTART
|
||||
# is executed by systemd bitcoind services everytime before bitcoin is started
|
||||
# so it tries to make sure the config is in valid shape
|
||||
######################################################################
|
||||
|
||||
# check/repair lnd config before starting
|
||||
if [ "$1" == "prestart" ]; then
|
||||
|
||||
echo "### RUNNING bitcoin.check.sh prestart"
|
||||
|
||||
# check correct user
|
||||
if [ "$USER" != "bitcoin" ]; then
|
||||
echo "# FAIL: run as user 'bitcoin'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check correct parameter
|
||||
if [ "$2" != "mainnet" ] && [ "$2" != "testnet" ] && [ "$2" != "signet" ]; then
|
||||
echo "# FAIL: missing/wrong parameter"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CHAIN="$2"
|
||||
|
||||
##### DIRECTORY PERMISSIONS #####
|
||||
|
||||
/bin/chgrp bitcoin /mnt/hdd/bitcoin
|
||||
|
||||
##### CLEAN UP #####
|
||||
|
||||
# all lines with just spaces to empty lines
|
||||
sed -i 's/^[[:space:]]*$//g' /mnt/hdd/bitcoin/bitcoin.conf
|
||||
# all double empty lines to single empty lines
|
||||
sed -i '/^$/N;/^\n$/D' /mnt/hdd/bitcoin/bitcoin.conf
|
||||
|
||||
##### CHECK/SET CONFIG VALUES #####
|
||||
|
||||
# correct debug log path
|
||||
if [ "${CHAIN}" == "mainnet" ]; then
|
||||
bitcoinlog_entry="main.debuglogfile"
|
||||
bitcoinlog_path="/mnt/hdd/bitcoin/debug.log"
|
||||
elif [ "${CHAIN}" == "testnet" ]; then
|
||||
bitcoinlog_entry="test.debuglogfile"
|
||||
bitcoinlog_path="/mnt/hdd/bitcoin/testnet3/debug.log"
|
||||
elif [ "${CHAIN}" == "signet" ]; then
|
||||
bitcoinlog_entry="signet.debuglogfile"
|
||||
bitcoinlog_path="/mnt/hdd/bitcoin/signet/debug.log"
|
||||
fi
|
||||
|
||||
# make sure entry exists
|
||||
echo "# make sure entry(${bitcoinlog_entry}) exists"
|
||||
extryExists=$(grep -c "^${bitcoinlog_entry}=" /mnt/hdd/bitcoin/bitcoin.conf)
|
||||
if [ "${extryExists}" == "0" ]; then
|
||||
echo "${bitcoinlog_entry}=${bitcoinlog_path}" >> /mnt/hdd/bitcoin/bitcoin.conf
|
||||
fi
|
||||
|
||||
# make sure entry has the correct value
|
||||
echo "# make sure entry(${bitcoinlog_entry}) has the correct value(${bitcoinlog_path})"
|
||||
sed -i "s|^${bitcoinlog_entry}=.*|${bitcoinlog_entry}=${bitcoinlog_path}|g" /mnt/hdd/bitcoin/bitcoin.conf
|
||||
|
||||
##### STATISTICS #####
|
||||
|
||||
# count startings
|
||||
if [ "${CHAIN}" == "mainnet" ]; then
|
||||
/home/admin/config.scripts/blitz.systemd.sh log blockchain STARTED
|
||||
fi
|
||||
|
||||
echo "# OK PRESTART DONE"
|
||||
|
||||
else
|
||||
echo "# FAIL: parameter not known - run with -h for help"
|
||||
exit 1
|
||||
fi
|
@ -241,12 +241,13 @@ signet.addnode=nsgyo7begau4yecc46ljfecaykyzszcseapxmtu6adrfagfrrzrlngyd.onion:38
|
||||
|
||||
removeParallelService
|
||||
|
||||
if [ ${CHAIN} = mainnet ];then
|
||||
sudo cp /home/admin/assets/bitcoind.service /etc/systemd/system/bitcoind.service
|
||||
else
|
||||
# /etc/systemd/system/${prefix}bitcoind.service
|
||||
# based on https://github.com/bitcoin/bitcoin/blob/master/contrib/init/bitcoind.service
|
||||
echo "
|
||||
# /etc/systemd/system/${prefix}bitcoind.service
|
||||
# based on https://github.com/bitcoin/bitcoin/blob/master/contrib/init/bitcoind.service
|
||||
chainparameter=""
|
||||
if [ "${CHAIN}" != "mainnet" ]; then
|
||||
chainparameter="-${CHAIN}"
|
||||
fi
|
||||
echo "
|
||||
[Unit]
|
||||
Description=Bitcoin daemon on ${CHAIN}
|
||||
|
||||
@ -255,15 +256,12 @@ Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Environment='MALLOC_ARENA_MAX=1'
|
||||
ExecStart=/usr/local/bin/bitcoind -${CHAIN} \\
|
||||
ExecStartPre=-/home/admin/config.scripts/bitcoin.check.sh prestart ${CHAIN}
|
||||
ExecStart=/usr/local/bin/bitcoind ${chainparameter} \\
|
||||
-daemonwait \\
|
||||
-conf=/mnt/hdd/bitcoin/bitcoin.conf \\
|
||||
-datadir=/mnt/hdd/bitcoin \\
|
||||
-debuglogfile=${bitcoinlogpath}
|
||||
|
||||
# Make sure the config directory is readable by the service user
|
||||
-datadir=/mnt/hdd/bitcoin
|
||||
PermissionsStartOnly=true
|
||||
ExecStartPre=/bin/chgrp bitcoin /mnt/hdd/bitcoin
|
||||
|
||||
# Process management
|
||||
####################
|
||||
@ -301,7 +299,6 @@ MemoryDenyWriteExecute=true
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
" | sudo tee /etc/systemd/system/${prefix}bitcoind.service
|
||||
fi
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable ${prefix}bitcoind
|
||||
echo "# OK - the bitcoin daemon on ${CHAIN} service is now enabled"
|
||||
|
Loading…
Reference in New Issue
Block a user