-
-
Save jeffrade/0b730d226ff6f6b985f802d3c9191023 to your computer and use it in GitHub Desktop.
#!/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 | |
# Let's wait for 30 seconds in case other processes need to come up first. | |
sleep 30 | |
echo "Starting bitcoind..." | |
bitcoind --daemon --server -pid=/path-to-dir/.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=/path-to-script/bitcoind-start.sh | |
# Process management | |
#################### | |
Type=forking | |
PIDFile=/path-to-dir/.bitcoin/bitcoind.pid | |
Restart=on-failure | |
# Directory creation and permissions | |
#################################### | |
# Run as bitcoin:bitcoin or <youruser> | |
User=youruser | |
Group=youruser | |
# 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 |
@bartenbach What in particular? This gist is mostly (if not all) a subset from files in the init directory: https://github.com/bitcoin/bitcoin/tree/master/contrib/init
Oh, weird. The tgz for Linux on bitcoin.org doesn't contain those files.
Oh, weird. The tgz for Linux on bitcoin.org doesn't contain those files.
@bartenbach As they shouldn't since the compiled binary doesn't know anything more than the OS architecture is is supposed to run on. See following link for more details https://github.com/bitcoin/bitcoin/blob/master/doc/init.md
I won't be much help, so join IRC or other forums if you have any more questions https://github.com/bitcoin/bitcoin/blob/216f4ca9e7ccb1f0fcb9bab0f9940992a87ae55f/doc/README.md#need-help
Yes, it could be any one of those three 2 kilobyte files. Might as well just not package any of them and let the user source them manually. Makes perfect sense 🙄
Thanks for sharing this.
To get it working on raspberry pi 4, with non root user
- I edited the start script so I can run it with my usual bitcoind user.
- I updated the path, and commented out user and group in the .service file or it would complain about user
- I commented out the PrivateDevices in .service or it would complain about capability
- updated WantedBy=default.target
- added required disk mounted in After and Requires section as explained here: https://unix.stackexchange.com/questions/246935/set-systemd-service-to-execute-after-fstab-mount but it only started to work after I added the blockchain disk partition in /etc/fstab (the automount was happening too late).
- install in ~/.config/systemd/user/bitcoind.service
then run
systemctl --user daemon-reload
systemctl --user enable bitcoind.service
systemctl --user start bitcoind.service
as explained in https://unix.stackexchange.com/questions/559753/how-to-make-systemd-services-run-automatically-after-reboot
for service to restart on reboot, user needs to be lingering on the machine: sudo loginctl enable-linger myusername
Good looking out. Is this really not provided by bitcoin core??