Sep 042014
 

Many thanks to GNUtransfer for lending us a VPS and other resources to write this article.

In this article we will show how to use the package bitcoind-init for debian wheezy amd64 available in our repository.

NOTE: We have called this package «bitcoind-init» to avoid conflicts with «bitcoind» package available in Debian repositories.

This is the bitcoind package for debian wheezy amd64 compiled with downloaded sources from git repository https://github.com/bitcoin/bitcoin.git and a script in init.d to start and stop it.

The package has a start and stop script in /etc/init.d

First let’s proceed to install the package with apt-get, dependencies are also installed.

root@vps590197:/# apt-get install bitcoind-init
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libboost-chrono1.49.0 libboost-filesystem1.49.0 libboost-program-options1.49.0 libboost-system1.49.0 libboost-thread1.49.0 libdb5.1++ libminiupnpc5 minissdpd openssl pwgen rpl
Suggested packages:
  db-util db4.8-util ca-certificates
The following NEW packages will be installed:
  bitcoind-init libboost-chrono1.49.0 libboost-filesystem1.49.0 libboost-program-options1.49.0 libboost-system1.49.0 libboost-thread1.49.0 libdb5.1++ libminiupnpc5 minissdpd openssl pwgen
  rpl
0 upgraded, 12 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,742 kB of archives.
After this operation, 10.4 MB of additional disk space will be used.
Do you want to continue [Y/n]? 
Get:1 http://repository.geeklab.com.ar/geeklab-repository/ wheezy/contrib bitcoind-init amd64 0.9.3-0 [1,822 kB]
Get:2 http://security.debian.org/ wheezy/updates/main openssl amd64 1.0.1e-2+deb7u12 [701 kB]                                                  
Get:3 http://ftp.us.debian.org/debian/ wheezy/main rpl all 1.5.5-1 [8,314 B]                                                                   
Get:4 http://ftp.us.debian.org/debian/ wheezy/main pwgen amd64 2.06-1+b2 [21.0 kB]               
Get:5 http://ftp.us.debian.org/debian/ wheezy/main libboost-system1.49.0 amd64 1.49.0-3.2 [33.4 kB] 
Get:6 http://ftp.us.debian.org/debian/ wheezy/main libboost-filesystem1.49.0 amd64 1.49.0-3.2 [78.3 kB]              
Get:7 http://ftp.us.debian.org/debian/ wheezy/main libboost-program-options1.49.0 amd64 1.49.0-3.2 [162 kB]                
Get:8 http://ftp.us.debian.org/debian/ wheezy/main libboost-thread1.49.0 amd64 1.49.0-3.2 [64.0 kB]                            
Get:9 http://ftp.us.debian.org/debian/ wheezy/main libboost-chrono1.49.0 amd64 1.49.0-3.2 [39.8 kB]                   
Get:10 http://ftp.us.debian.org/debian/ wheezy/main libdb5.1++ amd64 5.1.29-5 [757 kB]
Get:11 http://ftp.us.debian.org/debian/ wheezy/main libminiupnpc5 amd64 1.5-2 [37.9 kB]                                                                                                      
Get:12 http://ftp.us.debian.org/debian/ wheezy/main minissdpd amd64 1.1.20120121-1 [17.5 kB]                                                                                                 
Fetched 3,742 kB in 8s (462 kB/s)                                                                                                                                                            
Selecting previously unselected package openssl.
(Reading database ... 27776 files and directories currently installed.)
Unpacking openssl (from .../openssl_1.0.1e-2+deb7u12_amd64.deb) ...
Selecting previously unselected package rpl.
Unpacking rpl (from .../archives/rpl_1.5.5-1_all.deb) ...
Selecting previously unselected package pwgen.
Unpacking pwgen (from .../pwgen_2.06-1+b2_amd64.deb) ...
Selecting previously unselected package libboost-system1.49.0.
Unpacking libboost-system1.49.0 (from .../libboost-system1.49.0_1.49.0-3.2_amd64.deb) ...
Selecting previously unselected package libboost-filesystem1.49.0.
Unpacking libboost-filesystem1.49.0 (from .../libboost-filesystem1.49.0_1.49.0-3.2_amd64.deb) ...
Selecting previously unselected package libboost-program-options1.49.0.
Unpacking libboost-program-options1.49.0 (from .../libboost-program-options1.49.0_1.49.0-3.2_amd64.deb) ...
Selecting previously unselected package libboost-thread1.49.0.
Unpacking libboost-thread1.49.0 (from .../libboost-thread1.49.0_1.49.0-3.2_amd64.deb) ...
Selecting previously unselected package libboost-chrono1.49.0.
Unpacking libboost-chrono1.49.0 (from .../libboost-chrono1.49.0_1.49.0-3.2_amd64.deb) ...
Selecting previously unselected package libdb5.1++:amd64.
Unpacking libdb5.1++:amd64 (from .../libdb5.1++_5.1.29-5_amd64.deb) ...
Selecting previously unselected package libminiupnpc5.
Unpacking libminiupnpc5 (from .../libminiupnpc5_1.5-2_amd64.deb) ...
Processing triggers for man-db ...
Setting up openssl (1.0.1e-2+deb7u12) ...
Setting up rpl (1.5.5-1) ...
Setting up pwgen (2.06-1+b2) ...
Setting up libboost-system1.49.0 (1.49.0-3.2) ...
Setting up libboost-filesystem1.49.0 (1.49.0-3.2) ...
Setting up libboost-program-options1.49.0 (1.49.0-3.2) ...
Setting up libboost-thread1.49.0 (1.49.0-3.2) ...
Setting up libboost-chrono1.49.0 (1.49.0-3.2) ...
Setting up libdb5.1++:amd64 (5.1.29-5) ...
Setting up libminiupnpc5 (1.5-2) ...
Processing triggers for python-support ...
Selecting previously unselected package bitcoind-init.
(Reading database ... 27926 files and directories currently installed.)
Unpacking bitcoind-init (from .../bitcoind-init_0.9.3-0_amd64.deb) ...
Selecting previously unselected package minissdpd.
Unpacking minissdpd (from .../minissdpd_1.1.20120121-1_amd64.deb) ...
Processing triggers for man-db ...
Setting up bitcoind-init (0.9.3-0) ...
update-rc.d: using dependency based boot sequencing
[ ok ] bitcoin-init.sh: Start bitcoind Daemon is disabled check /etc/default/bitcoin-init.
Setting up minissdpd (1.1.20120121-1) ...
root@vps590197:/# 

Installing this package will create the user «bitcoin» whose working directory is:

/var/lib/bitcoin

Installation script leaves a working configuration ready. You just need to edit /etc/default/bitcoin-init (The syntax is bash)

root@vps590197:/# cat /etc/default/bitcoin-init 
ENABLE=no

SERVER_CONF=/var/lib/bitcoin/.bitcoin/bitcoin-server.conf
CLIENT_CONF=/var/lib/bitcoin/.bitcoin/bitcoin.conf
DATADIR=/var/lib/bitcoin/.bitcoin
RUNUSER=bitcoin
RUNGROUP=bitcoin

NICE_VAL=18

and set the value of the ENABLE variable to «yes»

root@vps590197:/# cat /etc/default/bitcoin-init 
ENABLE=yes

SERVER_CONF=/var/lib/bitcoin/.bitcoin/bitcoin-server.conf
CLIENT_CONF=/var/lib/bitcoin/.bitcoin/bitcoin.conf
DATADIR=/var/lib/bitcoin/.bitcoin
RUNUSER=bitcoin
RUNGROUP=bitcoin

NICE_VAL=18

In case we need to modify the bitcoind daemon configuration you must edit the file /var/lib/bitcoin/.bitcoin/bitcoin-server.conf

If we modify the rpcuser and/or rpcpassword variables in file /var/lib/bitcoin/.bitcoin/bitcoin-server.conf we must do the same in /var/lib/bitcoin/.bitcoin/bitcoin.conf.

If there is a file called wallet.dat you should copy it to the directory /var/lib/bitcoin/.bitcoin and change owner and permissions

root@vps590197:/# chown bitcoin:bitcoin /var/lib/bitcoin/.bitcoin/wallet.dat
root@vps590197:/# chmod 0600 /var/lib/bitcoin/.bitcoin/wallet.dat
root@vps590197:/# 

If we do not have wallet.dat file, one will be created the first time you run the daemon.

We now proceed to start the daemon. The startup script is /etc/init.d/bitcoin-init.sh

root@vps590197:/# /etc/init.d/bitcoin-init.sh start
[ ok ] bitcoin-init.sh: Start bitcoind.
root@vps590197:/# 

Just wait a few minutes and then try to execute a query as user «bitcoin»:

root@vps590197:/# su bitcoin 
bitcoin@vps590197:/$ bitcoin-cli getinfo
{
    "version" : 90300,
    "protocolversion" : 70002,
    "walletversion" : 60000,
    "balance" : 0.00000000,
    "blocks" : 95537,
    "timeoffset" : 0,
    "connections" : 4,
    "proxy" : "",
    "difficulty" : 8078.19525793,
    "testnet" : false,
    "keypoololdest" : 1409790646,
    "keypoolsize" : 1025,
    "paytxfee" : 0.00000000,
    "relayfee" : 0.00001000,
    "errors" : ""
}
bitcoin@vps590197:/$ 

If you want to connect as another user (such as root) you can do the following:

root@vps590197:/# mkdir -p /root/.bitcoin
root@vps590197:/# cp /var/lib/bitcoin/.bitcoin/bitcoin.conf /root/.bitcoin/
root@vps590197:/# chown root:root /root/.bitcoin/bitcoin.conf 
root@vps590197:/# chmod 0600 /root/.bitcoin/bitcoin.conf
root@vps590197:/# 

and then …

root@vps590197:/# bitcoin-cli getinfo
{
    "version" : 90300,
    "protocolversion" : 70002,
    "walletversion" : 60000,
    "balance" : 0.00000000,
    "blocks" : 114072,
    "timeoffset" : 0,
    "connections" : 4,
    "proxy" : "",
    "difficulty" : 76192.61934751,
    "testnet" : false,
    "keypoololdest" : 1409790646,
    "keypoolsize" : 1025,
    "paytxfee" : 0.00000000,
    "relayfee" : 0.00001000,
    "errors" : ""
}
root@vps590197:/#                    

NOTE 1: You must wait for the entire chain of blocks to synchronize, it could take more than one day.

NOTE 2: Make sure you have enough disk space. For this article the entire block chain occupies about 27GB.

Any bug or misconception feel free to leave a comment.

This concludes this article.

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.