123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- #!/bin/bash
- export VERSION=1.2
- export REV=21-04-2017
- set -e
- set +x
- export SRC_DIR=$(cd $(dirname $0) && pwd)
- ESC=$(echo -en \\0033)
- BOLD="$ESC[1m"
- OFF="$ESC[0m"
- bold() {
- echo "$BOLD$1$OFF"
- }
- fail() {
- bold "$@"
- exit 1
- }
- full() { # full automation
- clear
- echo -e "\e[031m${BOLD}Minera auto_install v:$VERSION rev:$REV $OFF"
- echo -e "\e[031m${BOLD}Full installation$OFF"
- sudo apt-get update
- sudo apt-get install git postfix -y
- sleep 3
- init
- deploy
- sudo rm -r -f /var/www/minera/minera-bin/src/libblkmaker
- miners
- }
- init() { # Update and install prerequise
- clear
- echo -e "\e[031m${BOLD}Minera auto_install v:$VERSION rev:$REV $OFF"
- echo -e "\e[033m${BOLD}Raspberry Update:$OFF"
- sudo apt-get update
- sudo apt-get upgrade -y
- echo -e "\e[033m${BOLD}Install prerequises:$OFF"
- sudo apt-get install lighttpd php5-cgi dosfstools -y
- #sudo lighty-enable-mod fastcgi
- #sudo lighty-enable-mod fastcgi-php
- sleep 1
- if [ -f "/usr/sbin/rpi-clone" ];
- then echo -e "\e[039m${BOLD}Install rpi-clone: Already installed$OFF"
- else
- echo -e "\e[033m${BOLD}Install: rpi-clone$OFF"
- cd ..
- git clone https://github.com/billw2/rpi-clone.git
- cd rpi-clone
- sudo cp rpi-clone /usr/sbin
- fi
- echo -e "\e[033m${BOLD}Install: fastcgi$OFF"
- sudo apt-get install -y redis-server git screen php5-cli php5-curl
- sudo apt-get autoremove -y
- sudo /etc/init.d/lighttpd restart
- cd "$SRC_DIR"
- }
- deploy() { # Install Minera with my patched files
- if [ ! -d "/var/www/minera" ];
- then cd /var/www/
- sudo git clone https://github.com/michelem09/minera
- cd minera
- sudo git checkout 8890458b3dbb36cdc4bfb29c350759aec2588baf
- fi
- cd /var/www/minera
- echo -e "\e[033m${BOLD}Install: Patch:$OFF"
- sudo cp $SRC_DIR/files/patch_no_ads.diff .
- sudo patch -p1 <patch_no_ads.diff
- sudo ./install_minera.sh
- }
- miners() { # Install all modded miners
- cd /var/www/minera
- echo -e "\e[033m${BOLD}Building miners software:$OFF"
- sudo apt-get install build-essential autoconf automake libtool pkg-config libcurl4-openssl-dev libncursesw5-dev libgcrypt20-dev -y
- sudo apt-get install libjansson-dev uthash-dev libncurses5-dev libudev-dev libusb-1.0-0-dev libevent-dev libmicrohttpd-dev -y
- sudo cp $SRC_DIR/files/build_miner_mod.sh .
- cd /var/www/minera/minera-bin/src/
- if [ -d "/var/www/minera/minera-bin/src/libbase58" ];
- then cd /var/www/minera/minera-bin/src/libbase58
- LOCAL=$(git rev-parse @)
- REMOTE=$(git rev-parse @{u})
- if [ $LOCAL = $REMOTE ]; then
- sudo make install
- echo -e "\e[039m${BOLD}Install libbase58 library: Up-to-date$OFF"
- elif [ $LOCAL = $BASE ]; then
- echo -e "\e[033m${BOLD}Install libbase58 drivers:$OFF"
- echo "Need to pull"
- sudo git pull
- sudo ./autogen.sh
- sudo ./configure
- sudo make
- sudo make install
- sudo ldconfig
- fi
- else echo -e "\e[033m${BOLD}Install libbase58 library:$OFF"
- cd /var/www/minera/minera-bin/src/
- git clone https://github.com/luke-jr/libbase58.git
- cd libbase58
- sudo ./autogen.sh
- sudo ./configure
- sudo make
- sudo make install
- sudo ldconfig
- fi
- if [ -d "/var/www/minera/minera-bin/src/hidapi" ];
- then cd /var/www/minera/minera-bin/src/hidapi
- LOCAL=$(git rev-parse @)
- REMOTE=$(git rev-parse @{u})
- if [ $LOCAL = $REMOTE ]; then
- sudo make install
- echo -e "\e[039m${BOLD}Install Hidapi drivers: Up-to-date$OFF"
- elif [ $LOCAL = $BASE ]; then
- echo -e "\e[033m${BOLD}Install Hidapi drivers:$OFF"
- echo "Need to pull"
- sudo git pull
- sudo ./bootstrap
- sudo ./configure
- sudo make
- sudo make install
- fi
- else echo -e "\e[033m${BOLD}Install Hidapi drivers:$OFF"
- cd /var/www/minera/minera-bin/src/
- git clone https://github.com/signal11/hidapi.git
- cd /var/www/minera/minera-bin/src/hidapi
- sudo apt-get install libudev-dev libusb-1.0-0-dev libfox-1.6-dev -y
- sudo ./bootstrap
- sudo ./configure
- sudo make
- sudo make install
- fi
- if [ -d "/var/www/minera/minera-bin/src/libblkmaker" ];
- then cd /var/www/minera/minera-bin/src/libblkmaker
- LOCAL=$(git rev-parse @)
- REMOTE=$(git rev-parse @{u})
- if [ $LOCAL = $REMOTE ]; then
- sudo make install
- echo -e "\e[039m${BOLD}Install libblmaker libs: Up-to-date$OFF"
- elif [ $LOCAL = $BASE ]; then
- echo -e "\e[033m${BOLD}Install libblmaker libs:$OFF"
- echo "Need to pull"
- sudo git pull
- sudo ./autogen.sh
- sudo ./configure
- sudo make
- sudo make install
- fi
- else echo -e "\e[033m${BOLD}Install libblmaker libs:$OFF"
- cd /var/www/minera/minera-bin/src
- git clone https://github.com/bitcoin/libblkmaker.git
- cd /var/www/minera/minera-bin/src/libblkmaker
- sudo ./autogen.sh
- sudo ./configure
- sudo make
- sudo make install
- fi
- cd /var/www/minera
- sudo ./build_miner_mod.sh all
- }
- patch_only() { # Patch only for original minera v7
- echo -e "\e[033m${BOLD}Install: Patch:$OFF"
- cd /var/www/minera
- sudo cp $SRC_DIR/files/patch_no_ads.diff .
- sudo patch -p1 <patch_no_ads.diff
- echo -e "\e[033m${BOLD}Patch : installed $OFF"
- }
- cd "$SRC_DIR"
- case "$1" in
- full) full;;
- init) init;;
- deploy) deploy;;
- miners) miners;;
- patch_only) patch_only;;
- *)
- echo -e "\e[031m${BOLD}Minera auto_install v:$VERSION rev:$REV $OFF"
- echo -e "${BOLD}Usage: $0 ( full | init | deploy | patch_only | miners )$OFF"
- echo >&2
- echo >&2 "Build actions:"
- grep "() { #" $0 | grep -v grep | sed -e "s:^: :" -e "s:() { #: @:" | while read i; do
- echo " " $(eval "echo $i") | tr @ \\t
- done
- exit 1
- ;;
- esac
|