This is a set of new and improved rc.d scripts for Bitcoin, Litecoin, and it's derivatives. These new scripts include better process management, automatic data directory creation, and the ability to run as a non-root user.
The originals can be found at http://www.unibia.com/unibianet/freebsd/freebsd-rcd-scripts-bitcoin-and-....
How to Use
Usage is the same but much of the prerequisites (such as the database directory) are automatically created. You'll still need a configuration file with an "rpcpassword" set:
edit /usr/local/etc/bitcoin.conf
edit /usr/local/etc/litecoin.conf
You can get a sample configuration file from
- https://en.bitcoin.it/wiki/Running_Bitcoin#Bitcoin.conf_Configuration_File for Bitcoin
- https://litecoin.info/Litecoin.conf#litecoin.conf_Configuration_File. for Litecoin
Download the updated rc.d scripts, place them in "/usr/local/etc/rc.d" and set the correct permissions:
cd /usr/local/etc/rc.d
fetch -o /usr/local/etc/rc.d/bitcoin http://www.unibia.com/unibianet/sites/default/files/bitcoin.rc_.d
fetch -o /usr/local/etc/rc.d/litecoin http://www.unibia.com/unibianet/sites/default/files/litecoin.rc_.d
chmod 555 /usr/local/etc/rc.d/bitcoin
chmod 555 /usr/local/etc/rc.d/litecoin
Enable the service in /etc/rc.conf:
echo "bitcoin_enable="YES"" >> /etc/rc.conf
echo "litecoin_enable="YES"" >> /etc/rc.conf
Start the service:
service bitcoin start
service litecoin start
Stop them with:
service bitcoin stop
service litecoin stop
Restart them with:
service bitcoin restart
service litecoin restart
Show status:
service bitcoin status
service litecoin status
Changing the Database Directory
By default the rc.d scripts will store the block chain and database files in /var/db/COINNAME. The Bitcoin block chain is currently over 16 GB as April 2014 and it's possible your /var may not have enough free space. You can specify an alternate data directory by adjusting the corresponding rc variable, simply add the following to your /etc/rc.conf file:
echo "bitcoin_datadir="/usr/local/bitcoin"" >> /etc/rc.conf
echo "litecoin_datadir="/usr/local/litecoin"" >> /etc/rc.conf
The data directory will be automatically created with the user and group "bitcoind" is setup to run as.
Securing Your Bitcoin and Litecoin Service
If you need to run Bitcoin or Litecoin as an alternate user adjust the following rc variables by adding them to your /etc/rc.conf file. Specify the user and group you want to run bitcoind as:
echo "bitcoin_user="bitcoin"" >> /etc/rc.conf
echo "bitcoin_group="bitcoin"" >> /etc/rc.conf
echo "litecoin_user="litecoin"" >> /etc/rc.conf
echo "litecoin_group="litecoin"" >> /etc/rc.conf
You'll need to create whatever user and group you specify. This implementation does not require that they have shell access. For example:
bitcoin:*:701:701:BitCoin Daemon:/nonexistent:/usr/sbin/nologin
litecoin:*:702:702:LiteCoin Daemon:/nonexistent:/usr/sbin/nologin
One thing to note, if you already have an existing data directory you will need to change it's user and group permissions:
chown -R bitcoin:bitcoin /var/db/bitcoin
Using for other Crypto Currencies
The scripts can be easily adjusted for use with any other crypto currency. Download the script and do a simple search and replace:
fetch -o /usr/local/etc/rc.d/foocoin http://www.unibia.com/unibianet/sites/default/files/bitcoin.rc_.d
sed -i "" 's/bitcoin/foocoin/g' /usr/local/etc/rc.d/foocoin
chmod 555 /usr/local/etc/rc.d/foocoin
The script can then be used in exactly the same way.
NOTE: Some coins based on the Bitcoin 0.8.99.0 source have a bug where the debug log gets written to the root partition. To work around this, issue the following command (adjusting the coin's name and database directory accordingly):
ln -s /var/db/COINNAME /.COINNAME
If you found this useful and would like to show thanks send me some Bitcoins: 1B6eyXVRPxdEitW5vWrUnzzXUy6o38P9wN
Attachment | Size |
---|---|
Bitcoin FreeBSD rc.d Script | 1.78 KB |
Litecoin FreeBSD rc.d Script | 1.82 KB |