buildit.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #!/bin/bash
  2. curdir=$PWD
  3. function update {
  4. sudo apt-get update
  5. sudo apt-get upgrade
  6. sudo apt-get install git screen build-essential autoconf automake -y
  7. sudo apt-get install libtool pkg-config libcurl4-gnutls-dev libjansson-dev uthash-dev libncursesw5-dev libudev-dev libusb-1.0-0-dev libevent-dev libmicrohttpd-dev libhidapi-dev libgcrypt20-dev -y
  8. }
  9. function bfgminer
  10. {
  11. cd ~
  12. git clone https://github.com/wareck/bfgminer.git
  13. cd ~/bfgminer/
  14. sudo usermod -a -G dialout,plugdev $USER
  15. CFLAGS="-O2 -march=native" ./autogen.sh
  16. ./configure --enable-scrypt --enable-futurebit
  17. make -j4
  18. cd ~
  19. cp $curdir/bfgminer.tar.xz .
  20. tar xvfJ bfgminer.tar.xz
  21. rm bfgminer.tar.xz
  22. if ! grep "#bfgminer" /etc/rc.local >/dev/null
  23. then
  24. sudo cp /etc/rc.local .
  25. bash -c 'sed -i -e "s/exit 0//g" rc.local'
  26. cat <<'EOF'>> rc.local.tmp
  27. #bfgminer
  28. su - pi -c 'screen -dmS miner /home/pi/bfgminer/bfgminer --scrypt -S all --set MLD:clock=660 --set ZUS:clock=328 --set ZUS:chips=6 --api-allow 127.0.0.1 --api-listen'
  29. exit 0
  30. EOF
  31. cat rc.local.tmp >> rc.local
  32. sudo cp rc.local /etc/rc.local
  33. rm rc.local
  34. rm rc.local.tmp
  35. fi
  36. }
  37. function okcash_download_mod {
  38. cd ~
  39. git clone https://github.com/wareck/okcash_node.git
  40. echo "patch:"
  41. sed -i -e "s/GPIO_PIN=4/GPIO_PIN=18/g" /home/pi/okcash_node/hardware/fan-control.sh
  42. sed -i -e "s/sudo reboot/#sudo reboot/g" /home/pi/okcash_node/build_node.sh
  43. cd /home/pi/okcash_node/hardware/
  44. /home/pi/okcash_node/hardware/fan-control.sh
  45. /home/pi/okcash_node/hardware/led-status.sh
  46. cd /home/pi/okcash_node/
  47. /home/pi/okcash_node/build_node.sh
  48. }
  49. function hotspot {
  50. cd $curdir
  51. sudo ./install_hotspot.sh
  52. sudo ufw allow 21
  53. sudo ufw allow 8080
  54. sudo ufw allow 4028
  55. sudo ufw allow 3333
  56. sudo ufw allow in on wlan0
  57. sudo ufw route allow out on eth0
  58. sudo ufw status numbered
  59. }
  60. function website_ext {
  61. if ! grep "/var/www/miner;" /etc/nginx/sites-available/default >/dev/null
  62. then
  63. cat <<'EOF'>> ng.txt
  64. server {
  65. listen 8080;
  66. root /var/www/miner;
  67. index index.php index.html index.htm index.nginx-debian.html;
  68. server_name _;
  69. location / {
  70. try_files $uri $uri/ =404;
  71. }
  72. location ~ \.php$ {
  73. include snippets/fastcgi-php.conf;
  74. fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
  75. }
  76. location ~ /\.ht {
  77. deny all;
  78. }
  79. }
  80. EOF
  81. cp /etc/nginx/sites-available/default .
  82. cat ng.txt >> default
  83. sudo mv default /etc/nginx/sites-available/default
  84. rm ng.txt
  85. fi
  86. if ! [ -d /var/www/miner ]
  87. then
  88. mkdir /var/www/miner/
  89. fi
  90. cp /home/pi/bfgminer/miner.php .
  91. sed -i -e "s/13pt/9pt/g" miner.php
  92. sed -i -e "s/18pt/13pt/g" miner.php
  93. sudo mv miner.php /var/www/miner/index.php
  94. sudo /etc/init.d/nginx restart
  95. }
  96. update
  97. bfgminer
  98. okcash_download_mod
  99. hotspot
  100. website_ext
  101. echo "normalement tout est ok..."
  102. echo "reboot et tests"