#!/bin/bash curdir=$PWD function update { sudo apt-get update sudo apt-get upgrade sudo apt-get install git screen build-essential autoconf automake -y 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 } function bfgminer { cd ~ git clone https://github.com/wareck/bfgminer.git cd ~/bfgminer/ sudo usermod -a -G dialout,plugdev $USER CFLAGS="-O2 -march=native" ./autogen.sh ./configure --enable-scrypt --enable-futurebit make -j4 cd ~ cp $curdir/bfgminer.tar.xz . tar xvfJ bfgminer.tar.xz rm bfgminer.tar.xz if ! grep "#bfgminer" /etc/rc.local >/dev/null then sudo cp /etc/rc.local . bash -c 'sed -i -e "s/exit 0//g" rc.local' cat <<'EOF'>> rc.local.tmp #bfgminer 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' exit 0 EOF cat rc.local.tmp >> rc.local sudo cp rc.local /etc/rc.local rm rc.local rm rc.local.tmp fi } function okcash_download_mod { cd ~ git clone https://github.com/wareck/okcash_node.git echo "patch:" sed -i -e "s/GPIO_PIN=4/GPIO_PIN=18/g" /home/pi/okcash_node/hardware/fan-control.sh sed -i -e "s/sudo reboot/#sudo reboot/g" /home/pi/okcash_node/build_node.sh cd /home/pi/okcash_node/hardware/ /home/pi/okcash_node/hardware/fan-control.sh /home/pi/okcash_node/hardware/led-status.sh cd /home/pi/okcash_node/ /home/pi/okcash_node/build_node.sh } function hotspot { cd $curdir sudo ./install_hotspot.sh sudo ufw allow 21 sudo ufw allow 8080 sudo ufw allow 4028 sudo ufw allow 3333 sudo ufw allow in on wlan0 sudo ufw route allow out on eth0 sudo ufw status numbered } function website_ext { if ! grep "/var/www/miner;" /etc/nginx/sites-available/default >/dev/null then cat <<'EOF'>> ng.txt server { listen 8080; root /var/www/miner; index index.php index.html index.htm index.nginx-debian.html; server_name _; location / { try_files $uri $uri/ =404; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; } location ~ /\.ht { deny all; } } EOF cp /etc/nginx/sites-available/default . cat ng.txt >> default sudo mv default /etc/nginx/sites-available/default rm ng.txt fi if ! [ -d /var/www/miner ] then mkdir /var/www/miner/ fi cp /home/pi/bfgminer/miner.php . sed -i -e "s/13pt/9pt/g" miner.php sed -i -e "s/18pt/13pt/g" miner.php sudo mv miner.php /var/www/miner/index.php sudo /etc/init.d/nginx restart } update bfgminer okcash_download_mod hotspot website_ext echo "normalement tout est ok..." echo "reboot et tests"