From 55a97b93223919171195fb11c11281c9cdb0be3e Mon Sep 17 00:00:00 2001 From: Adam Weiss Date: Thu, 31 Jul 2014 11:56:17 -0400 Subject: [PATCH 01/14] Add init scripts and docs for Upstart and OpenRC (cherry picked from commit 234bfbf6a5fcba37e510e9cb6c1f2a629cd0290e) Conflicts: contrib/init/bitcoind.service doc/README.md --- contrib/init/README.md | 10 ++++ contrib/init/bitcoind.conf | 65 ++++++++++++++++++++++ contrib/init/bitcoind.openrc | 86 +++++++++++++++++++++++++++++ contrib/init/bitcoind.openrcconf | 27 ++++++++++ contrib/init/bitcoind.service | 22 ++++++++ doc/README.md | 1 + doc/init.md | 92 ++++++++++++++++++++++++++++++++ 7 files changed, 303 insertions(+) create mode 100644 contrib/init/README.md create mode 100644 contrib/init/bitcoind.conf create mode 100644 contrib/init/bitcoind.openrc create mode 100644 contrib/init/bitcoind.openrcconf create mode 100644 contrib/init/bitcoind.service create mode 100644 doc/init.md diff --git a/contrib/init/README.md b/contrib/init/README.md new file mode 100644 index 000000000000..d3fa9665839a --- /dev/null +++ b/contrib/init/README.md @@ -0,0 +1,10 @@ +Sample configuration files for: + +SystemD: bitcoind.service +Upstart: bitcoind.conf +OpenRC: bitcoind.openrc + bitcoind.openrcconf + +have been made available to assist packagers in creating node packages here. + +See doc/init.md for more information. diff --git a/contrib/init/bitcoind.conf b/contrib/init/bitcoind.conf new file mode 100644 index 000000000000..f9554eecde7f --- /dev/null +++ b/contrib/init/bitcoind.conf @@ -0,0 +1,65 @@ +description "Bitcoin Core Daemon" + +start on runlevel [2345] +stop on starting rc RUNLEVEL=[016] + +env BITCOIND_BIN="/usr/bin/bitcoind" +env BITCOIND_USER="bitcoin" +env BITCOIND_GROUP="bitcoin" +env BITCOIND_PIDDIR="/var/run/bitcoind" +# upstart can't handle variables constructed with other variables +env BITCOIND_PIDFILE="/var/run/bitcoind/bitcoind.pid" +env BITCOIND_CONFIGFILE="/etc/bitcoin/bitcoin.conf" +env BITCOIND_DATADIR="/var/lib/bitcoind" + +expect fork + +respawn +respawn limit 5 120 +kill timeout 60 + +pre-start script + # this will catch non-existent config files + # bitcoind will check and exit with this very warning, but it can do so + # long after forking, leaving upstart to think everything started fine. + # since this is a commonly encountered case on install, just check and + # warn here. + if ! grep -qs '^rpcpassword=' "$BITCOIND_CONFIGFILE" ; then + echo "ERROR: You must set a secure rpcpassword to run bitcoind." + echo "The setting must appear in $BITCOIND_CONFIGFILE" + echo + echo "This password is security critical to securing wallets " + echo "and must not be the same as the rpcuser setting." + echo "You can generate a suitable random password using the following" + echo "command from the shell:" + echo + echo "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'" + echo + echo "It is also recommended that you also set alertnotify so you are " + echo "notified of problems:" + echo + echo "ie: alertnotify=echo %%s | mail -s \"Bitcoin Alert\"" \ + "admin@foo.com" + echo + exit 1 + fi + + mkdir -p "$BITCOIND_PIDDIR" + chmod 0755 "$BITCOIND_PIDDIR" + chown $BITCOIND_USER:$BITCOIND_GROUP "$BITCOIND_PIDDIR" + chown $BITCOIND_USER:$BITCOIND_GROUP "$BITCOIND_CONFIGFILE" + chmod 0660 "$BITCOIND_CONFIGFILE" +end script + +exec start-stop-daemon \ + --start \ + --pidfile "$BITCOIND_PIDFILE" \ + --chuid $BITCOIND_USER:$BITCOIND_GROUP \ + --exec "$BITCOIND_BIN" \ + -- \ + -pid="$BITCOIND_PIDFILE" \ + -conf="$BITCOIND_CONFIGFILE" \ + -datadir="$BITCOIND_DATADIR" \ + -disablewallet \ + -daemon + diff --git a/contrib/init/bitcoind.openrc b/contrib/init/bitcoind.openrc new file mode 100644 index 000000000000..1f7758c9202a --- /dev/null +++ b/contrib/init/bitcoind.openrc @@ -0,0 +1,86 @@ +#!/sbin/runscript + +# backward compatibility for existing gentoo layout +# +if [ -d "/var/lib/bitcoin/.bitcoin" ]; then + BITCOIND_DEFAULT_DATADIR="/var/lib/bitcoin/.bitcoin" +else + BITCOIND_DEFAULT_DATADIR="/var/lib/bitcoind" +fi + +BITCOIND_CONFIGFILE=${BITCOIND_CONFIGFILE:-/etc/bitcoin/bitcoin.conf} +BITCOIND_PIDDIR=${BITCOIND_PIDDIR:-/var/run/bitcoind} +BITCOIND_PIDFILE=${BITCOIND_PIDFILE:-${BITCOIND_PIDDIR}/bitcoind.pid} +BITCOIND_DATADIR=${BITCOIND_DATADIR:-${BITCOIND_DEFAULT_DATADIR}} +BITCOIND_USER=${BITCOIND_USER:-bitcoin} +BITCOIND_GROUP=${BITCOIND_GROUP:-bitcoin} +BITCOIND_BIN=${BITCOIND_BIN:-/usr/bin/bitcoind} + +name="Bitcoin Core Daemon" +description="Bitcoin crypto-currency p2p network daemon" + +command="/usr/bin/bitcoind" +command_args="-pid=\"${BITCOIND_PIDFILE}\" \ + -conf=\"${BITCOIND_CONFIGFILE}\" \ + -datadir=\"${BITCOIND_DATADIR}\" \ + -daemon \ + ${BITCOIND_OPTS}" + +required_files="${BITCOIND_CONFIGFILE}" +start_stop_daemon_args="-u ${BITCOIND_USER} \ + -N ${BITCOIND_NICE:-0} -w 2000" +pidfile="${BITCOIND_PIDFILE}" +retry=60 + +depend() { + need localmount net +} + +# verify +# 1) that the datadir exists and is writable (or create it) +# 2) that a directory for the pid exists and is writable +# 3) ownership and permissions on the config file +start_pre() { + checkpath \ + -d \ + --mode 0750 \ + --owner "${BITCOIND_USER}:${BITCOIND_GROUP}" \ + "${BITCOIND_DATADIR}" + + checkpath \ + -d \ + --mode 0755 \ + --owner "${BITCOIND_USER}:${BITCOIND_GROUP}" \ + "${BITCOIND_PIDDIR}" + + checkpath -f \ + -o ${BITCOIND_USER}:${BITCOIND_GROUP} \ + -m 0660 \ + ${BITCOIND_CONFIGFILE} + + checkconfig || return 1 +} + +checkconfig() +{ + if ! grep -qs '^rpcpassword=' "${BITCOIND_CONFIGFILE}" ; then + eerror "" + eerror "ERROR: You must set a secure rpcpassword to run bitcoind." + eerror "The setting must appear in ${BITCOIND_CONFIGFILE}" + eerror "" + eerror "This password is security critical to securing wallets " + eerror "and must not be the same as the rpcuser setting." + eerror "You can generate a suitable random password using the following" + eerror "command from the shell:" + eerror "" + eerror "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'" + eerror "" + eerror "It is also recommended that you also set alertnotify so you are " + eerror "notified of problems:" + eerror "" + eerror "ie: alertnotify=echo %%s | mail -s \"Bitcoin Alert\"" \ + "admin@foo.com" + eerror "" + return 1 + fi +} diff --git a/contrib/init/bitcoind.openrcconf b/contrib/init/bitcoind.openrcconf new file mode 100644 index 000000000000..d8d7f5833746 --- /dev/null +++ b/contrib/init/bitcoind.openrcconf @@ -0,0 +1,27 @@ +# /etc/conf.d/bitcoind: config file for /etc/init.d/bitcoind + +# Config file location +#BITCOIND_CONFIGFILE="/etc/bitcoin/bitcoin.conf" + +# What directory to write pidfile to? (created and owned by $BITCOIND_USER) +#BITCOIND_PIDDIR="/var/run/bitcoind" + +# What filename to give the pidfile +#BITCOIND_PIDFILE="${BITCOIND_PIDDIR}/bitcoind.pid" + +# Where to write bitcoind data (be mindful that the blockchain is large) +#BITCOIND_DATADIR="/var/lib/bitcoind" + +# User and group to own bitcoind process +#BITCOIND_USER="bitcoin" +#BITCOIND_GROUP="bitcoin" + +# Path to bitcoind executable +#BITCOIND_BIN="/usr/bin/bitcoind" + +# Nice value to run bitcoind under +#BITCOIND_NICE=0 + +# Additional options (avoid -conf and -datadir, use flags above) +BITCOIND_OPTS="-disablewallet" + diff --git a/contrib/init/bitcoind.service b/contrib/init/bitcoind.service new file mode 100644 index 000000000000..9132957c38b8 --- /dev/null +++ b/contrib/init/bitcoind.service @@ -0,0 +1,22 @@ +[Unit] +Description=Bitcoin's distributed currency daemon +After=network.target + +[Service] +User=bitcoin +Group=bitcoin + +Type=forking +PIDFile=/var/lib/bitcoind/bitcoind.pid +ExecStart=/usr/bin/bitcoind -daemon -pid=/var/lib/bitcoind/bitcoind.pid \ +-conf=/etc/bitcoin/bitcoin.conf -datadir=/var/lib/bitcoind -disablewallet + +Restart=always +PrivateTmp=true +TimeoutStopSec=60s +TimeoutStartSec=2s +StartLimitInterval=120s +StartLimitBurst=5 + +[Install] +WantedBy=multi-user.target diff --git a/doc/README.md b/doc/README.md index b4e37e22aac8..8982498960aa 100644 --- a/doc/README.md +++ b/doc/README.md @@ -68,6 +68,7 @@ The Bitcoin repo's [root README](https://github.com/bitcoin/bitcoin/blob/master/ - [Assets Attribution](assets-attribution.md) - [Files](files.md) - [Tor Support](tor.md) +- [Init Scripts (systemd/upstart/openrc)](init.md) License --------------------- diff --git a/doc/init.md b/doc/init.md new file mode 100644 index 000000000000..3d14025ab497 --- /dev/null +++ b/doc/init.md @@ -0,0 +1,92 @@ +Sample init scripts and service configuration for bitcoind +========================================================== + +Sample scripts and configuration files for systemd, Upstart and OpenRC +can be found in the contrib/init folder. + +contrib/init/bitcoind.service: systemd service unit configuration +contrib/init/bitcoind.openrc: OpenRC compatible SysV style init script +contrib/init/bitcoind.openrcconf: OpenRC conf.d file +contrib/init/bitcoind.conf: Upstart service configuration file + +1. Service User +--------------------------------- + +All three startup configurations assume the existence of a "bitcoin" user +and group. They must be created before attempting to use these scripts. + +2. Configuration +--------------------------------- + +At a bare minimum, bitcoind requires that the rpcpassword setting be set +when running as a daemon. If the configuration file does not exist or this +setting is not set, bitcoind will shutdown promptly after startup. + +This password does not have to be remembered or typed as it is mostly used +as a fixed token that bitcoind and client programs read from the configuration +file, however it is recommended that a strong and secure password be used +as this password is security critical to securing the wallet should the +wallet be enabled. + +If bitcoind is run with "-daemon" flag, and no rpcpassword is set, it will +print a randomly generated suitable password to stderr. You can also +generate one from the shell yourself like this: + +bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo' + +Once you have a password in hand, set rpcpassword= in /etc/bitcoin/bitcoin.conf + +For an example configuration file that describes the configuration settings, +see contrib/debian/examples/bitcoin.conf. + +3. Paths +--------------------------------- + +All three configurations assume several paths that might need to be adjusted. + +Binary: /usr/bin/bitcoind +Configuration file: /etc/bitcoin/bitcoin.conf +Data directory: /var/lib/bitcoind +PID file: /var/run/bitcoind/bitcoind.pid (OpenRC and Upstart) + /var/lib/bitcoind/bitcoind.pid (systemd) + +The configuration file, PID directory (if applicable) and data directory +should all be owned by the bitcoin user and group. It is advised for security +reasons to make the configuration file and data directory only readable by the +bitcoin user and group. Access to bitcoin-cli and other bitcoind rpc clients +can then be controlled by group membership. + +4. Installing Service Configuration +----------------------------------- + +4a) systemd + +Installing this .service file consists on just copying it to +/usr/lib/systemd/system directory, followed by the command +"systemctl daemon-reload" in order to update running systemd configuration. + +To test, run "systemctl start bitcoind" and to enable for system startup run +"systemctl enable bitcoind" + +4b) OpenRC + +Rename bitcoind.openrc to bitcoind and drop it in /etc/init.d. Double +check ownership and permissions and make it executable. Test it with +"/etc/init.d/bitcoind start" and configure it to run on startup with +"rc-update add bitcoind" + +4c) Upstart (for Debian/Ubuntu based distributions) + +Drop bitcoind.conf in /etc/init. Test by running "service bitcoind start" +it will automatically start on reboot. + +NOTE: This script is incompatible with CentOS 5 and Amazon Linux 2014 as they +use old versions of Upstart and do not supply the start-stop-daemon uitility. + +5. Auto-respawn +----------------------------------- + +Auto respawning is currently only configured for Upstart and systemd. +Reasonable defaults have been chosen but YMMV. + + From 005f91398291b50ccfbbed83147f04b3635ba3cb Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Mon, 15 Sep 2014 10:34:23 -0700 Subject: [PATCH 02/14] Ubuntu/Upstart init scripts for Master Core MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Back-ported some files from BitCoin core (approved) PR’s with some additions for Master Core. See: https://github.com/bitcoin/bitcoin/issues/4124 https://github.com/bitcoin/bitcoin/pull/4611 --- contrib/msc-ubuntu/README.md | 20 +++++ contrib/msc-ubuntu/bitcoin.conf | 87 +++++++++++++++++++ .../msc-ubuntu/install-mastercore-upstart.sh | 29 +++++++ 3 files changed, 136 insertions(+) create mode 100644 contrib/msc-ubuntu/README.md create mode 100644 contrib/msc-ubuntu/bitcoin.conf create mode 100755 contrib/msc-ubuntu/install-mastercore-upstart.sh diff --git a/contrib/msc-ubuntu/README.md b/contrib/msc-ubuntu/README.md new file mode 100644 index 000000000000..d848a0a969bf --- /dev/null +++ b/contrib/msc-ubuntu/README.md @@ -0,0 +1,20 @@ +Master Core Upstart support for Ubuntu (tested on 14.04 LTS) + +This is based upon upstream work that is documented in these links: + +* [Issue #4124](https://github.com/bitcoin/bitcoin/issues/4124) +* [Issue #4611](https://github.com/bitcoin/bitcoin/pull/4611) + +This branch/PR used "git cherry-pick" to pull some of that code so it can be added to the michael-0921 branch of Master Core. + +Doc on the files from the "Cherry Pick" can be found: + +* [init/README.md](../init/README.md) +* [doc/init.md](../../doc/init.md) + +It has been tested on Ubuntu 14.04 LTS. + +There is a Vagrant script to install it here: +[https://github.com/msgilligan/install-msc/tree/vagrant](https://github.com/msgilligan/install-msc/tree/vagrant) + + diff --git a/contrib/msc-ubuntu/bitcoin.conf b/contrib/msc-ubuntu/bitcoin.conf new file mode 100644 index 000000000000..b60688d79631 --- /dev/null +++ b/contrib/msc-ubuntu/bitcoin.conf @@ -0,0 +1,87 @@ +# bitcoin.conf configuration file. Lines beginning with # are comments. + + +# Network-related settings: + +# Run on the test network instead of the real bitcoin network. +#testnet=1 + +# Connect via a socks4 proxy +#proxy=127.0.0.1:9050 + +# Use as many addnode= settings as you like to connect to specific peers +#addnode=69.164.218.197 +#addnode=10.0.0.2:8333 + +# ... or use as many connect= settings as you like to connect ONLY +# to specific peers: +#connect=69.164.218.197 +#connect=10.0.0.1:8333 + +# Maximum number of inbound+outbound connections. +#maxconnections= + + +# JSON-RPC options (for controlling a running Bitcoin/bitcoind process) + +# server=1 tells Bitcoin to accept JSON-RPC commands. +#server=1 + +# You must set rpcuser and rpcpassword to secure the JSON-RPC api +#rpcuser=Ulysseys +#rpcpassword=YourSuperGreatPasswordNumber_385593 + +# By default, only RPC connections from localhost are allowed. Specify +# as many rpcallowip= settings as you like to allow connections from +# other hosts (and you may use * as a wildcard character): +#rpcallowip=10.1.1.34 +#rpcallowip=192.168.1.* + +# Listen for RPC connections on this TCP port: +rpcport=8332 + +# You can use Bitcoin or bitcoind to send commands to Bitcoin/bitcoind +# running on another host using this option: +rpcconnect=127.0.0.1 + +# Use Secure Sockets Layer (also known as TLS or HTTPS) to communicate +# with Bitcoin -server or bitcoind +#rpcssl=1 + +# OpenSSL settings used when rpcssl=1 +rpcsslciphers=TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH +rpcsslcertificatechainfile=server.cert +rpcsslprivatekeyfile=server.pem + + +# Miscellaneous options + +# Set gen=1 to attempt to generate bitcoins +gen=0 + +# Use SSE instructions to try to generate bitcoins faster. +#4way=1 + +# Pre-generate this many public/private key pairs, so wallet backups will be valid for +# both prior transactions and several dozen future transactions. +keypool=100 + +# Pay an optional transaction fee every time you send bitcoins. Transactions with fees +# are more likely than free transactions to be included in generated blocks, so may +# be validated sooner. +paytxfee=0.00 + +# Allow direct connections for the 'pay via IP address' feature. +#allowreceivebyip=1 + + +# User interface options + +# Start Bitcoin minimized +#min=1 + +# Minimize to the system tray +#minimizetotray=1 + +# txindex is required for Master Core +txindex=1 diff --git a/contrib/msc-ubuntu/install-mastercore-upstart.sh b/contrib/msc-ubuntu/install-mastercore-upstart.sh new file mode 100755 index 000000000000..df78c642b4dc --- /dev/null +++ b/contrib/msc-ubuntu/install-mastercore-upstart.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# Copy the executable +cp src/bitcoind /usr/bin/bitcoind + +# Set up directories, users, and permissions as standardized by Bitcoin Core +mkdir -p /etc/bitcoin +mkdir -p /var/lib/bitcoind +mkdir -p /var/run/bitcoind + +groupadd --force --system bitcoin +useradd -M --system --shell /usr/sbin/nologin --home /var/lib/bitcoind --gid bitcoin bitcoin + +chown bitcoin:bitcoin /var/lib/bitcoind +chmod 750 /var/lib/bitcoind + +chown bitcoin:bitcoin /var/run/bitcoind +chmod 755 /var/run/bitcoind + +# Copy Bitcoin configuration file +cp contrib/msc-ubuntu/bitcoin.conf /etc/bitcoin +chown bitcoin:bitcoin /etc/bitcoin/bitcoin.conf +chmod 660 /etc/bitcoin/bitcoin.conf + +# Copy Upstart configuration file/script +cp contrib/init/bitcoind.conf /etc/init + +echo "Set rpcuser and rpcpassword in /etc/bitcoin/bitcoin.conf, then type: service bitcoind start" + From 3d73bb2bfd465c35826d533e1d681b12da4cf257 Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Mon, 15 Sep 2014 10:53:10 -0700 Subject: [PATCH 03/14] Add Install instructions to README.md --- contrib/msc-ubuntu/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/contrib/msc-ubuntu/README.md b/contrib/msc-ubuntu/README.md index d848a0a969bf..d20bab3f851a 100644 --- a/contrib/msc-ubuntu/README.md +++ b/contrib/msc-ubuntu/README.md @@ -1,5 +1,18 @@ Master Core Upstart support for Ubuntu (tested on 14.04 LTS) +To install: + +1. Build Master Core + + ./autogen.sh + ./configure + make + +1. Run the install script + + sudo ./contrib/msc-ubuntu/install-mastercore-upstart.sh + + This is based upon upstream work that is documented in these links: * [Issue #4124](https://github.com/bitcoin/bitcoin/issues/4124) From 36a5e66e8d499ba584b923395721044848783124 Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Mon, 15 Sep 2014 14:52:58 -0700 Subject: [PATCH 04/14] Also install bitcoin-cli into /usr/bin --- contrib/msc-ubuntu/install-mastercore-upstart.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/msc-ubuntu/install-mastercore-upstart.sh b/contrib/msc-ubuntu/install-mastercore-upstart.sh index df78c642b4dc..3b36d46b4427 100755 --- a/contrib/msc-ubuntu/install-mastercore-upstart.sh +++ b/contrib/msc-ubuntu/install-mastercore-upstart.sh @@ -2,6 +2,7 @@ # Copy the executable cp src/bitcoind /usr/bin/bitcoind +cp src/bitcoin-cli /usr/bin/bitcoin-cli # Set up directories, users, and permissions as standardized by Bitcoin Core mkdir -p /etc/bitcoin From cca0f958bd6fc2c52213e78fea02216469b2fe0f Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Mon, 15 Sep 2014 14:53:23 -0700 Subject: [PATCH 05/14] Documentation improvements --- contrib/msc-ubuntu/README.md | 12 +++++++++++- contrib/msc-ubuntu/install-mastercore-upstart.sh | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/contrib/msc-ubuntu/README.md b/contrib/msc-ubuntu/README.md index d20bab3f851a..7e1a7e7183df 100644 --- a/contrib/msc-ubuntu/README.md +++ b/contrib/msc-ubuntu/README.md @@ -12,13 +12,23 @@ To install: sudo ./contrib/msc-ubuntu/install-mastercore-upstart.sh +Running `bitcoin-cli` for a quick test: + +1. Add your user to the `bitcoin` group so you can read `/etc/bitcoin/bitcoin.conf` + + sudo usermod -a -G bitcoin + +1. Use `getinfo` to make sure RPC is working + + /usr/sbin/bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf getinfo + This is based upon upstream work that is documented in these links: * [Issue #4124](https://github.com/bitcoin/bitcoin/issues/4124) * [Issue #4611](https://github.com/bitcoin/bitcoin/pull/4611) -This branch/PR used "git cherry-pick" to pull some of that code so it can be added to the michael-0921 branch of Master Core. +This branch/PR used `git cherry-pick` to pull some of that code so it can be added to the `michael-0921` branch of Master Core. Doc on the files from the "Cherry Pick" can be found: diff --git a/contrib/msc-ubuntu/install-mastercore-upstart.sh b/contrib/msc-ubuntu/install-mastercore-upstart.sh index 3b36d46b4427..02a0f2fd21a6 100755 --- a/contrib/msc-ubuntu/install-mastercore-upstart.sh +++ b/contrib/msc-ubuntu/install-mastercore-upstart.sh @@ -26,5 +26,5 @@ chmod 660 /etc/bitcoin/bitcoin.conf # Copy Upstart configuration file/script cp contrib/init/bitcoind.conf /etc/init -echo "Set rpcuser and rpcpassword in /etc/bitcoin/bitcoin.conf, then type: service bitcoind start" +echo "Set rpcuser and rpcpassword in /etc/bitcoin/bitcoin.conf, then type: 'service bitcoind start' (as root/sudo)" From 440f19274d63b5dfe2599ac5f88b40bc42209aa7 Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Thu, 18 Sep 2014 10:14:37 -0700 Subject: [PATCH 06/14] Comment out paytxfee setting Use the default hardcoded in the source. --- contrib/msc-ubuntu/bitcoin.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/msc-ubuntu/bitcoin.conf b/contrib/msc-ubuntu/bitcoin.conf index b60688d79631..35feaf17fb77 100644 --- a/contrib/msc-ubuntu/bitcoin.conf +++ b/contrib/msc-ubuntu/bitcoin.conf @@ -69,7 +69,7 @@ keypool=100 # Pay an optional transaction fee every time you send bitcoins. Transactions with fees # are more likely than free transactions to be included in generated blocks, so may # be validated sooner. -paytxfee=0.00 +#paytxfee=0.00 # Allow direct connections for the 'pay via IP address' feature. #allowreceivebyip=1 From 7b5a4d58781cf58e40a7816e7c7f85483c9b8ffa Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Thu, 25 Sep 2014 12:16:03 -0700 Subject: [PATCH 07/14] Copied from ../init/bitcoind.conf --- contrib/msc-ubuntu/bitcoind.conf | 65 ++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 contrib/msc-ubuntu/bitcoind.conf diff --git a/contrib/msc-ubuntu/bitcoind.conf b/contrib/msc-ubuntu/bitcoind.conf new file mode 100644 index 000000000000..f9554eecde7f --- /dev/null +++ b/contrib/msc-ubuntu/bitcoind.conf @@ -0,0 +1,65 @@ +description "Bitcoin Core Daemon" + +start on runlevel [2345] +stop on starting rc RUNLEVEL=[016] + +env BITCOIND_BIN="/usr/bin/bitcoind" +env BITCOIND_USER="bitcoin" +env BITCOIND_GROUP="bitcoin" +env BITCOIND_PIDDIR="/var/run/bitcoind" +# upstart can't handle variables constructed with other variables +env BITCOIND_PIDFILE="/var/run/bitcoind/bitcoind.pid" +env BITCOIND_CONFIGFILE="/etc/bitcoin/bitcoin.conf" +env BITCOIND_DATADIR="/var/lib/bitcoind" + +expect fork + +respawn +respawn limit 5 120 +kill timeout 60 + +pre-start script + # this will catch non-existent config files + # bitcoind will check and exit with this very warning, but it can do so + # long after forking, leaving upstart to think everything started fine. + # since this is a commonly encountered case on install, just check and + # warn here. + if ! grep -qs '^rpcpassword=' "$BITCOIND_CONFIGFILE" ; then + echo "ERROR: You must set a secure rpcpassword to run bitcoind." + echo "The setting must appear in $BITCOIND_CONFIGFILE" + echo + echo "This password is security critical to securing wallets " + echo "and must not be the same as the rpcuser setting." + echo "You can generate a suitable random password using the following" + echo "command from the shell:" + echo + echo "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'" + echo + echo "It is also recommended that you also set alertnotify so you are " + echo "notified of problems:" + echo + echo "ie: alertnotify=echo %%s | mail -s \"Bitcoin Alert\"" \ + "admin@foo.com" + echo + exit 1 + fi + + mkdir -p "$BITCOIND_PIDDIR" + chmod 0755 "$BITCOIND_PIDDIR" + chown $BITCOIND_USER:$BITCOIND_GROUP "$BITCOIND_PIDDIR" + chown $BITCOIND_USER:$BITCOIND_GROUP "$BITCOIND_CONFIGFILE" + chmod 0660 "$BITCOIND_CONFIGFILE" +end script + +exec start-stop-daemon \ + --start \ + --pidfile "$BITCOIND_PIDFILE" \ + --chuid $BITCOIND_USER:$BITCOIND_GROUP \ + --exec "$BITCOIND_BIN" \ + -- \ + -pid="$BITCOIND_PIDFILE" \ + -conf="$BITCOIND_CONFIGFILE" \ + -datadir="$BITCOIND_DATADIR" \ + -disablewallet \ + -daemon + From 717b633fcb6ae105ad52f91cd0bdb3ecfd2befd3 Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Thu, 25 Sep 2014 12:24:40 -0700 Subject: [PATCH 08/14] Customize bitcoind.conf for Master Core MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * remove the ‘-disablewallet’ flag * Add parenthetic “(Master Core)” to description * change install script to copy from ‘msc-ubuntu’ directory. --- contrib/msc-ubuntu/bitcoind.conf | 3 +-- contrib/msc-ubuntu/install-mastercore-upstart.sh | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/contrib/msc-ubuntu/bitcoind.conf b/contrib/msc-ubuntu/bitcoind.conf index f9554eecde7f..6ff3fdb6cbdb 100644 --- a/contrib/msc-ubuntu/bitcoind.conf +++ b/contrib/msc-ubuntu/bitcoind.conf @@ -1,4 +1,4 @@ -description "Bitcoin Core Daemon" +description "Bitcoin Core Daemon (Master Core)" start on runlevel [2345] stop on starting rc RUNLEVEL=[016] @@ -60,6 +60,5 @@ exec start-stop-daemon \ -pid="$BITCOIND_PIDFILE" \ -conf="$BITCOIND_CONFIGFILE" \ -datadir="$BITCOIND_DATADIR" \ - -disablewallet \ -daemon diff --git a/contrib/msc-ubuntu/install-mastercore-upstart.sh b/contrib/msc-ubuntu/install-mastercore-upstart.sh index 02a0f2fd21a6..7298c4059993 100755 --- a/contrib/msc-ubuntu/install-mastercore-upstart.sh +++ b/contrib/msc-ubuntu/install-mastercore-upstart.sh @@ -24,7 +24,7 @@ chown bitcoin:bitcoin /etc/bitcoin/bitcoin.conf chmod 660 /etc/bitcoin/bitcoin.conf # Copy Upstart configuration file/script -cp contrib/init/bitcoind.conf /etc/init +cp contrib/msc-ubuntu/bitcoind.conf /etc/init echo "Set rpcuser and rpcpassword in /etc/bitcoin/bitcoin.conf, then type: 'service bitcoind start' (as root/sudo)" From 83bec305845bd111f9a95dc3f49810415649d245 Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Mon, 29 Sep 2014 17:03:38 -0700 Subject: [PATCH 09/14] Rename bitcoind to mastercored MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … and bitcoin-cli to mastercore-cli --- contrib/msc-ubuntu/bitcoind.conf | 5 +++-- contrib/msc-ubuntu/install-mastercore-upstart.sh | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/contrib/msc-ubuntu/bitcoind.conf b/contrib/msc-ubuntu/bitcoind.conf index 6ff3fdb6cbdb..2b68c784e0aa 100644 --- a/contrib/msc-ubuntu/bitcoind.conf +++ b/contrib/msc-ubuntu/bitcoind.conf @@ -3,7 +3,8 @@ description "Bitcoin Core Daemon (Master Core)" start on runlevel [2345] stop on starting rc RUNLEVEL=[016] -env BITCOIND_BIN="/usr/bin/bitcoind" +env BITCOIND_BIN="/usr/bin/mastercored" +env BITCOIND_BIN_NAME="mastercored" env BITCOIND_USER="bitcoin" env BITCOIND_GROUP="bitcoin" env BITCOIND_PIDDIR="/var/run/bitcoind" @@ -25,7 +26,7 @@ pre-start script # since this is a commonly encountered case on install, just check and # warn here. if ! grep -qs '^rpcpassword=' "$BITCOIND_CONFIGFILE" ; then - echo "ERROR: You must set a secure rpcpassword to run bitcoind." + echo "ERROR: You must set a secure rpcpassword to run $BITCOIND_BIN_NAME." echo "The setting must appear in $BITCOIND_CONFIGFILE" echo echo "This password is security critical to securing wallets " diff --git a/contrib/msc-ubuntu/install-mastercore-upstart.sh b/contrib/msc-ubuntu/install-mastercore-upstart.sh index 7298c4059993..ef952d3632c2 100755 --- a/contrib/msc-ubuntu/install-mastercore-upstart.sh +++ b/contrib/msc-ubuntu/install-mastercore-upstart.sh @@ -1,8 +1,11 @@ #!/bin/sh +BITCOIND_BIN_NAME="mastercored" +BITCOINCLI_BIN_NAME="mastercore-cli" + # Copy the executable -cp src/bitcoind /usr/bin/bitcoind -cp src/bitcoin-cli /usr/bin/bitcoin-cli +cp src/$BITCOIND_BIN_NAME /usr/bin/$BITCOIND_BIN_NAME +cp src/$BITCOINCLI_BIN_NAME-cli /usr/bin/$BITCOINCLI_BIN_NAME # Set up directories, users, and permissions as standardized by Bitcoin Core mkdir -p /etc/bitcoin From d44d920838049b93552e35ba0866ac1af99b1a46 Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Mon, 29 Sep 2014 17:16:33 -0700 Subject: [PATCH 10/14] =?UTF-8?q?Rename=20the=20upstart=20service=20to=20?= =?UTF-8?q?=E2=80=98mastercored=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit But continue to user the bitcoin/bitcoind names for files, directories, users & groups. --- contrib/msc-ubuntu/install-mastercore-upstart.sh | 6 ++++-- contrib/msc-ubuntu/{bitcoind.conf => mastercored.conf} | 0 2 files changed, 4 insertions(+), 2 deletions(-) rename contrib/msc-ubuntu/{bitcoind.conf => mastercored.conf} (100%) diff --git a/contrib/msc-ubuntu/install-mastercore-upstart.sh b/contrib/msc-ubuntu/install-mastercore-upstart.sh index ef952d3632c2..ecea66763193 100755 --- a/contrib/msc-ubuntu/install-mastercore-upstart.sh +++ b/contrib/msc-ubuntu/install-mastercore-upstart.sh @@ -2,6 +2,7 @@ BITCOIND_BIN_NAME="mastercored" BITCOINCLI_BIN_NAME="mastercore-cli" +SERVICE_NAME="mastercored" # Copy the executable cp src/$BITCOIND_BIN_NAME /usr/bin/$BITCOIND_BIN_NAME @@ -27,7 +28,8 @@ chown bitcoin:bitcoin /etc/bitcoin/bitcoin.conf chmod 660 /etc/bitcoin/bitcoin.conf # Copy Upstart configuration file/script -cp contrib/msc-ubuntu/bitcoind.conf /etc/init +cp contrib/msc-ubuntu/mastercored.conf /etc/init/$SERVICE_NAME + +echo "Set rpcuser and rpcpassword in /etc/bitcoin/bitcoin.conf, then type: 'service $SERVICE_NAME start' (as root/sudo)" -echo "Set rpcuser and rpcpassword in /etc/bitcoin/bitcoin.conf, then type: 'service bitcoind start' (as root/sudo)" diff --git a/contrib/msc-ubuntu/bitcoind.conf b/contrib/msc-ubuntu/mastercored.conf similarity index 100% rename from contrib/msc-ubuntu/bitcoind.conf rename to contrib/msc-ubuntu/mastercored.conf From 20ba342d13b596521c786adf72201bfacfbd3246 Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Tue, 30 Sep 2014 01:21:58 -0700 Subject: [PATCH 11/14] Remove extra -cli from generated file name --- contrib/msc-ubuntu/install-mastercore-upstart.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/msc-ubuntu/install-mastercore-upstart.sh b/contrib/msc-ubuntu/install-mastercore-upstart.sh index ecea66763193..10eeb23dde13 100755 --- a/contrib/msc-ubuntu/install-mastercore-upstart.sh +++ b/contrib/msc-ubuntu/install-mastercore-upstart.sh @@ -6,7 +6,7 @@ SERVICE_NAME="mastercored" # Copy the executable cp src/$BITCOIND_BIN_NAME /usr/bin/$BITCOIND_BIN_NAME -cp src/$BITCOINCLI_BIN_NAME-cli /usr/bin/$BITCOINCLI_BIN_NAME +cp src/$BITCOINCLI_BIN_NAME /usr/bin/$BITCOINCLI_BIN_NAME # Set up directories, users, and permissions as standardized by Bitcoin Core mkdir -p /etc/bitcoin From 85942a44dc79e6bba9b3cec7f557406bf723aeac Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Tue, 30 Sep 2014 01:43:56 -0700 Subject: [PATCH 12/14] /etc/init file needs to be mastercored.conf --- contrib/msc-ubuntu/install-mastercore-upstart.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/msc-ubuntu/install-mastercore-upstart.sh b/contrib/msc-ubuntu/install-mastercore-upstart.sh index 10eeb23dde13..f6e7005119d5 100755 --- a/contrib/msc-ubuntu/install-mastercore-upstart.sh +++ b/contrib/msc-ubuntu/install-mastercore-upstart.sh @@ -28,7 +28,7 @@ chown bitcoin:bitcoin /etc/bitcoin/bitcoin.conf chmod 660 /etc/bitcoin/bitcoin.conf # Copy Upstart configuration file/script -cp contrib/msc-ubuntu/mastercored.conf /etc/init/$SERVICE_NAME +cp contrib/msc-ubuntu/mastercored.conf /etc/init/$SERVICE_NAME.conf echo "Set rpcuser and rpcpassword in /etc/bitcoin/bitcoin.conf, then type: 'service $SERVICE_NAME start' (as root/sudo)" From 234b73ddacf3a0d4026d87cffd3b83e12ae44a7f Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Sat, 4 Oct 2014 14:16:25 -0700 Subject: [PATCH 13/14] Update instructions * Reflect bitcoin -> mastercore name change * Add instructions for starting the mastercored service --- contrib/msc-ubuntu/README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/contrib/msc-ubuntu/README.md b/contrib/msc-ubuntu/README.md index 7e1a7e7183df..d3bce32b22db 100644 --- a/contrib/msc-ubuntu/README.md +++ b/contrib/msc-ubuntu/README.md @@ -12,15 +12,21 @@ To install: sudo ./contrib/msc-ubuntu/install-mastercore-upstart.sh -Running `bitcoin-cli` for a quick test: +Running `mastercore-cli` for a quick test: 1. Add your user to the `bitcoin` group so you can read `/etc/bitcoin/bitcoin.conf` sudo usermod -a -G bitcoin -1. Use `getinfo` to make sure RPC is working +1. Edit /etc/bitcoin/bitcoin.conf and uncomment and set `rpcuser` and `rpcpassword`. - /usr/sbin/bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf getinfo +1. Start the `mastercored` service. + + sudo service mastercored start + +1. Use the `getinfo` RPC to make sure the daemon and RPC is working + + /usr/sbin/mastercore-cli -conf=/etc/bitcoin/bitcoin.conf getinfo This is based upon upstream work that is documented in these links: From 5aa48eebb9d09f214c9991fcedb13a584dc57666 Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Fri, 31 Oct 2014 08:53:11 -0700 Subject: [PATCH 14/14] rpcthreads=64 in default mastercore bitcoin.conf Workaround for omniwallet issue #1075 https://github.com/mastercoin-MSC/omniwallet/issues/1075 --- contrib/msc-ubuntu/bitcoin.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/msc-ubuntu/bitcoin.conf b/contrib/msc-ubuntu/bitcoin.conf index 35feaf17fb77..a89025fde1b4 100644 --- a/contrib/msc-ubuntu/bitcoin.conf +++ b/contrib/msc-ubuntu/bitcoin.conf @@ -53,6 +53,8 @@ rpcsslciphers=TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH rpcsslcertificatechainfile=server.cert rpcsslprivatekeyfile=server.pem +# Set the number of threads to service RPC calls (default: 4) +rpcthreads=64 # Miscellaneous options