Advertisement
jcomeau_ictx

build_coins.sh

Nov 24th, 2014
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.64 KB | None | 0 0
  1. #!/bin/bash
  2. # automate build of needed dependencies from source
  3. # for crippled CentOS installations with fracked-up libs and binaries
  4. #
  5. if [ "$(which yum)" ]; then
  6.  # install EPEL for packages outside normal CentOS distribution
  7.  CENTOS6_EPEL=http://mirror-fpt-telecom.fpt.net/fedora/epel/6/i386
  8.  wget $CENTOS6_EPEL/epel-release-6-8.noarch.rpm
  9.  sudo rpm -ivh epel-release-6-8.noarch.rpm
  10.  # get rid of services we don't need
  11.  sudo yum erase httpd sendmail
  12.  sudo yum erase sendmail
  13.  # install development stuff we need
  14.  sudo yum install gcc-c++ bzip2-devel python-devel python-pip git
  15. else # assume Debian
  16.  sudo apt-get install g++ libbz2-dev python-dev python-pip git libtool
  17. fi
  18. sudo pip install scrypt
  19. cd
  20. mkdir -p src
  21. cd src
  22. # build openssl from source
  23. OPENSSL_DIR=openssl-1.0.1e
  24. if [ \! -f $OPENSSL_DIR.tar.gz ]; then
  25.  wget http://www.openssl.org/source/$OPENSSL_DIR.tar.gz
  26. fi
  27. if [ \! -d $OPENSSL_DIR ]; then
  28.  tar xfz $OPENSSL_DIR.tar.gz
  29.  rm -f $OPENSSL_DIR/Makefile  # remove default Makefile to force ./config
  30. fi
  31. if [ $HOME/bin/c_rehash -ot $OPENSSL_DIR ]; then
  32.  if [ \! -f $OPENSSL_DIR/Makefile ]; then
  33.   (cd $OPENSSL_DIR && \
  34.    ./config --prefix=$HOME enable-ec enable-ecdh enable-ecdsa zlib -fPIC shared)
  35.  fi
  36.  (cd $OPENSSL_DIR && make install)
  37. fi
  38. # boost needs about 1G to compile
  39. if [ "$(free -m | sed -n 's/^Mem:\s\+\([0-9]\+\).*$/\1/p')" -lt 800 ]; then
  40.  if [ \! -e /tmp/boostswap ]; then
  41.   dd if=/dev/zero of=/tmp/boostswap bs=64M count=16
  42.   sudo mkswap /tmp/boostswap
  43.   sudo swapon /tmp/boostswap
  44.  fi
  45. fi
  46. # build boost from source
  47. SOURCEFORGE=http://sourceforge.net/projects
  48. BOOST_DIR=boost_1_54_0
  49. if [ \! -f $BOOST_DIR.tar.gz ]; then
  50.  wget $SOURCEFORGE/boost/files/boost/1.54.0/$BOOST_DIR.tar.gz
  51. fi
  52. if [ \! -d $BOOST_DIR ]; then
  53.  tar xfz $BOOST_DIR.tar.gz
  54. fi
  55. if [ $HOME/include/boost -ot $BOOST_DIR ]; then
  56.  if [ \! -e $HOME/lib/libboost_python.a ]; then
  57.   (cd $BOOST_DIR && \
  58.    ./bootstrap.sh --prefix=$HOME && \
  59.    ./b2 install --with=all)
  60.  fi
  61. fi
  62. # build Berkeley DB4.8 from source
  63. DB_DIR=db-4.8.30.NC
  64. if [ \! -f $DB_DIR.tar.gz ]; then
  65.  wget http://download.oracle.com/berkeley-db/$DB_DIR.tar.gz
  66. fi
  67. if [ \! -d $DB_DIR ]; then
  68.  tar xfz $DB_DIR.tar.gz
  69.  touch $DB_DIR
  70. fi
  71. if [ $HOME/include/db_cxx.h -ot $DB_DIR ]; then
  72.  if [ \! -e $DB_DIR/build_unix/Makefile ]; then
  73.   (cd $DB_DIR/build_unix/ && \
  74.    ../dist/configure --prefix=$HOME --enable-cxx)
  75.  fi
  76.  (cd $DB_DIR/build_unix/ && make install)
  77. fi
  78. # build libminiupnpc from source
  79. # most cryptocoin Makefiles hardcode USE_PNP:=0, so setting USE_PNP=- won't work
  80. MINIUPNP=http://miniupnp.free.fr
  81. MINIUPNP_DIR=miniupnpc-1.8.20131209
  82. if [ \! -f $MINIUPNP_DIR.tar.gz ]; then
  83.  wget -O $MINIUPNP_DIR.tar.gz \
  84.   "$MINIUPNP/files/download.php?file=$MINIUPNP_DIR.tar.gz"
  85. fi
  86. if [ \! -d $MINIUPNP_DIR ]; then
  87.  tar xfz $MINIUPNP_DIR.tar.gz
  88. fi
  89. if [ $HOME/include/miniupnpc -ot $MINIUPNP_DIR ]; then
  90.  (cd $MINIUPNP_DIR && make INSTALLPREFIX=$HOME install)
  91. fi
  92. # build bitcoin
  93. # as of version 9.something, bitcoin changes too much to use with simpleminer
  94. # switching back to version 8 for as long as the blockchain supports it
  95. if [ "$YES_I_WANT_LATEST_BITCOIN" ]; then
  96.  if [ \! -d bitcoin ]; then
  97.   git clone https://github.com/bitcoin/bitcoin.git
  98.  fi
  99.  if [ $HOME/bin/bitcoind.real -ot bitcoin ]; then
  100.   (cd bitcoin/ && \
  101.    CPPFLAGS="-I$HOME/include" LDFLAGS="-L/$HOME/lib -Wl,-rpath-link,$HOME/lib" \
  102.    ./configure --prefix=$HOME --with-boost=$HOME)
  103.   (cd bitcoin/ && make && mv -f src/bitcoind $HOME/bin/bitcoind.real)
  104.   # you will also have to fiddle with bitcoin-cli and maybe other stuff
  105.  fi
  106. else
  107.  BITCOIN_VERSION=bitcoin-0.8.6
  108.  BITCOIN_ARCHIVE=$BITCOIN_VERSION-linux
  109.  BITCOIN_SOURCE=http://downloads.sourceforge.net/project/bitcoin/Bitcoin
  110.  if [ \! -d $BITCOIN_ARCHIVE ]; then
  111.   wget $BITCOIN_SOURCE/$BITCOIN_VERSION/$BITCOIN_ARCHIVE.tar.gz
  112.   tar xzf $BITCOIN_ARCHIVE.tar.gz
  113.  fi
  114.  if [ $HOME/bin/bitcoind.real -ot $BITCOIN_ARCHIVE ]; then
  115.   (cd $BITCOIN_ARCHIVE/src/src && \
  116.    CXXFLAGS="-I$HOME/include" LDFLAGS="-L/$HOME/lib -Wl,-rpath-link,$HOME/lib" \
  117.     make && mv -f src/src/bitcoind $HOME/bin/bitcoind.real)
  118.  fi
  119. fi
  120. if [ \! -d AmericanCoin ]; then
  121.  git clone https://github.com/AMCcoin/AmericanCoin.git
  122. fi
  123. if [ $HOME/bin/americancoind.real -ot AmericanCoin ]; then
  124.  (cd AmericanCoin/src &&
  125.   make CXXFLAGS="-I$HOME/include" LDFLAGS="-L$HOME/lib" -f makefile.unix &&
  126.   cp americancoind $HOME/bin/americancoind.real)
  127. fi
  128. # build Berkeley DB5.1 from source, for dogecoin
  129. # http://download.oracle.com/berkeley-db/db-5.1.29.NC.tar.gz
  130. DB_DIR=db-5.1.29.NC
  131. DB_PREFIX=bdb5.1
  132. if [ \! -f $DB_DIR.tar.gz ]; then
  133.  wget http://download.oracle.com/berkeley-db/$DB_DIR.tar.gz
  134. fi
  135. if [ \! -d $DB_DIR ]; then
  136.  tar xfz $DB_DIR.tar.gz
  137.  touch $DB_DIR
  138. fi
  139. if [ $HOME/$DB_PREFIX -ot $DB_DIR ]; then
  140.  if [ \! -e $DB_DIR/build_unix/Makefile ]; then
  141.   (cd $DB_DIR/build_unix/ && \
  142.    ../dist/configure --prefix=$HOME/$DB_PREFIX --enable-cxx)
  143.  fi
  144.  (cd $DB_DIR/build_unix/ && make install)
  145. fi
  146. # dogecoin build puts BOOST_CPPFLAGS before CPPFLAGS, which causes the
  147. # compiler to find the bdb4.8 headers first. fix this with a symlink
  148. (cd $HOME/include && ln -sf $HOME/$DB_PREFIX/include $DB_PREFIX)
  149. DOGECOIN_VERSION=1.8.1-beta-1
  150. DOGECOIN_CPPFLAGS="-I$HOME -I$HOME/include"
  151. DOGECOIN_LDFLAGS="-L$HOME/$DB_PREFIX/lib -Wl,-rpath-link,$HOME/$DB_PREFIX/lib \
  152. -L$HOME/lib -Wl,-rpath-link,$HOME/lib"
  153. if [ \! -d dogecoin-$DOGECOIN_VERSION ]; then
  154.  if [ \! -f v$DOGECOIN_VERSION.tar.gz ]; then
  155.   wget https://github.com/dogecoin/dogecoin/archive/v$DOGECOIN_VERSION.tar.gz
  156.  fi
  157.  tar xfz v$DOGECOIN_VERSION.tar.gz
  158. fi
  159. if [ $HOME/bin/dogecoind.real -ot dogecoin-$DOGECOIN_VERSION ]; then
  160.  (cd dogecoin-$DOGECOIN_VERSION && \
  161.   ./autogen.sh && \
  162.   ./configure --prefix=$HOME --with-boost=$HOME --with-gui=no \
  163.    CPPFLAGS="$DOGECOIN_CPPFLAGS" LDFLAGS="$DOGECOIN_LDFLAGS" && \
  164.   make && \
  165.   cp src/dogecoind $HOME/bin/dogecoind.real)
  166. fi
  167. # we do not need the swapspace any more (we hope)
  168. if [ -e /tmp/boostswap ]; then
  169.  sudo swapoff /tmp/boostswap
  170.  rm /tmp/boostswap
  171. fi
  172. chmod +x $HOME/src/localcoind $HOME/src/simpleminer.py  # just to make sure
  173. for coin in bit american; do
  174.  (cd $HOME/bin && ln -sf ../src/localcoind ${coin}coind)
  175. done
  176. for coin in doge; do
  177.  (cd $HOME/bin && ln -sf ../src/localcoind-bdb5.1 ${coin}coind)
  178. done
  179. # you had to have uploaded simpleminer.* to $HOME/src
  180. cd $HOME/bin && ln -sf ../src/simpleminer.py .
  181. cd $HOME/bin && ln -sf /usr/bin/python simpleminer
  182. if [ -d /etc/init ]; then  # upstart system
  183.  (cd /etc/init && sudo ln -sf $HOME/src/simpleminer.conf americancoin.conf)
  184. fi
  185. if [ $(which initctl) ]; then
  186.  sudo initctl reload-configuration
  187.  sudo initctl start coinyecoin
  188. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement