Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
55a97b9
Add init scripts and docs for Upstart and OpenRC
ajweiss Jul 31, 2014
005f913
Ubuntu/Upstart init scripts for Master Core
msgilligan Sep 15, 2014
3d73bb2
Add Install instructions to README.md
msgilligan Sep 15, 2014
36a5e66
Also install bitcoin-cli into /usr/bin
msgilligan Sep 15, 2014
cca0f95
Documentation improvements
msgilligan Sep 15, 2014
8d90ef9
Merge branch 'michael-0921' into msgilligan-msc-upstart
msgilligan Sep 15, 2014
789bf94
Merge remote-tracking branch 'msc/mscore-0.0.8' into msgilligan-msc-u…
msgilligan Sep 18, 2014
440f192
Comment out paytxfee setting
msgilligan Sep 18, 2014
122b950
Merge branch 'mscore-0.0.8' into msgilligan-msc-upstart
msgilligan Sep 25, 2014
7b5a4d5
Copied from ../init/bitcoind.conf
msgilligan Sep 25, 2014
717b633
Customize bitcoind.conf for Master Core
msgilligan Sep 25, 2014
6a61f97
Merge branch 'mscore-0.0.8' into msgilligan-msc-upstart
msgilligan Sep 29, 2014
83bec30
Rename bitcoind to mastercored
msgilligan Sep 30, 2014
d44d920
Rename the upstart service to ‘mastercored’
msgilligan Sep 30, 2014
20ba342
Remove extra -cli from generated file name
msgilligan Sep 30, 2014
85942a4
/etc/init file needs to be mastercored.conf
msgilligan Sep 30, 2014
0ef3cf2
Merge branch 'mscore-0.0.8' into msgilligan-msc-upstart
msgilligan Oct 3, 2014
234b73d
Update instructions
msgilligan Oct 4, 2014
60b709a
Merge branch 'mscore-0.0.8' into msgilligan-msc-upstart
msgilligan Oct 15, 2014
5aa48ee
rpcthreads=64 in default mastercore bitcoin.conf
msgilligan Oct 31, 2014
b491139
Merge branch 'mscore-0.0.8' into msgilligan-msc-upstart
msgilligan Oct 31, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions contrib/init/README.md
Original file line number Diff line number Diff line change
@@ -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.
65 changes: 65 additions & 0 deletions contrib/init/bitcoind.conf
Original file line number Diff line number Diff line change
@@ -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\"" \
"[email protected]"
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

86 changes: 86 additions & 0 deletions contrib/init/bitcoind.openrc
Original file line number Diff line number Diff line change
@@ -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\"" \
"[email protected]"
eerror ""
return 1
fi
}
27 changes: 27 additions & 0 deletions contrib/init/bitcoind.openrcconf
Original file line number Diff line number Diff line change
@@ -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"

22 changes: 22 additions & 0 deletions contrib/init/bitcoind.service
Original file line number Diff line number Diff line change
@@ -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
49 changes: 49 additions & 0 deletions contrib/msc-ubuntu/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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

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 <username>

1. Edit /etc/bitcoin/bitcoin.conf and uncomment and set `rpcuser` and `rpcpassword`.

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:

* [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)


89 changes: 89 additions & 0 deletions contrib/msc-ubuntu/bitcoin.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# 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

# Set the number of threads to service RPC calls (default: 4)
rpcthreads=64

# 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
35 changes: 35 additions & 0 deletions contrib/msc-ubuntu/install-mastercore-upstart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh

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
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
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/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)"


Loading