|
@@ -0,0 +1,238 @@
|
|
|
+#!/bin/bash
|
|
|
+locat=$PWD
|
|
|
+echo "automated installation for oknode"
|
|
|
+echo "need several reboot"
|
|
|
+sleep 5
|
|
|
+
|
|
|
+if [ ! -f .step0 ]
|
|
|
+then
|
|
|
+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 -o stratum+tcp://litecoinpool.org:3333 -u wareck.1 -p 1,d=128 -S all --set MLD:clock=660 --set ZUS:clock=328 --set ZUS:chips=6'
|
|
|
+#su - pi -c 'screen -dmS miner /home/pi/bfgminer/bfgminer --scrypt -o stratum+tcp://eu-01.miningrigrentals.com:3333/#skipcbcheck#xnsub -u wareck.262669 -p x -S all --set MLD:clock=660 --set ZUS:clock=328 --set ZUS:chips=6 --api-allow 127.0.0.1 --api-listen'
|
|
|
+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
|
|
|
+
|
|
|
+cat <<'EOF'>> bfgminer.conf
|
|
|
+{
|
|
|
+"pools" : [
|
|
|
+ {
|
|
|
+ "url" : "stratum+tcp://eu-01.miningrigrentals.com:3333/#skipcbcheck#xnsub",
|
|
|
+ "user" : "wareck.262669",
|
|
|
+ "pass" : "x",
|
|
|
+ "pool-priority" : "0"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "url" : "stratum+tcp://eu-uk01.miningrigrentals.com:3333/#skipcbcheck#xnsub",
|
|
|
+ "user" : "wareck.262669",
|
|
|
+ "pass" : "x",
|
|
|
+ "pool-priority" : "0"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "url" : "stratum+tcp://hk-01.miningrigrentals.com:3333/#skipcbcheck#xnsub",
|
|
|
+ "user" : "wareck.262669",
|
|
|
+ "pass" : "x",
|
|
|
+ "pool-priority" : "0"
|
|
|
+ }
|
|
|
+]
|
|
|
+,
|
|
|
+"api-mcast-port" : "4028",
|
|
|
+"api-port" : "4028",
|
|
|
+"expiry" : "120",
|
|
|
+"expiry-lp" : "3600",
|
|
|
+"failover-switch-delay" : "300",
|
|
|
+"failover-only" : true,
|
|
|
+"log" : "20",
|
|
|
+"no-pool-disable" : true,
|
|
|
+"no-client-reconnect" : true,
|
|
|
+"no-show-processors" : true,
|
|
|
+"no-show-procs" : true,
|
|
|
+"no-unicode" : true,
|
|
|
+"queue" : "1",
|
|
|
+"quiet-work-updates" : true,
|
|
|
+"quiet-work-update" : true,
|
|
|
+"scan-time" : "60",
|
|
|
+"skip-security-checks" : "0",
|
|
|
+"submit-stale" : true,
|
|
|
+"temp-hysteresis" : "3",
|
|
|
+"shares" : 0,
|
|
|
+"kernel-path" : "/usr/local/share/bfgminer",
|
|
|
+"scan" : [
|
|
|
+ "all"
|
|
|
+]
|
|
|
+}
|
|
|
+EOF
|
|
|
+mkdir /home/pi/.bfgminer
|
|
|
+cp bfgminer.conf /home/pi/.bfgminer/
|
|
|
+rm bfgminer.conf
|
|
|
+fi
|
|
|
+cd $locat
|
|
|
+touch .step0
|
|
|
+fi
|
|
|
+
|
|
|
+if [ ! -f .step1 ]
|
|
|
+then
|
|
|
+cat <<'EOF'>> install_hotspot.sh
|
|
|
+apt-get update -y
|
|
|
+apt install dnsmasq -y
|
|
|
+systemctl stop dnsmasq
|
|
|
+echo "interface wlan0
|
|
|
+ static ip_address=10.30.4.1/24
|
|
|
+ nohook wpa_supplicant" >> /etc/dhcpcd.conf
|
|
|
+service dhcpcd restart
|
|
|
+mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
|
|
|
+echo "interface=wlan0 # Use the require wireless interface - usually wlan0
|
|
|
+dhcp-range=10.30.4.2,10.30.4.20,255.255.255.0,24h" > /etc/dnsmasq.conf
|
|
|
+systemctl unmask dnsmasq
|
|
|
+systemctl enable dnsmasq
|
|
|
+systemctl restart dnsmasq
|
|
|
+if command -v rfkill &> /dev/null
|
|
|
+then
|
|
|
+ rfkill unblock wlan
|
|
|
+fi
|
|
|
+apt-get install hostapd -y
|
|
|
+systemctl unmask hostapd
|
|
|
+systemctl enable hostapd
|
|
|
+ssid=Pyrale
|
|
|
+passphrase=Paypoo2016
|
|
|
+echo "interface=wlan0
|
|
|
+driver=nl80211
|
|
|
+ssid=$ssid
|
|
|
+hw_mode=g
|
|
|
+channel=7
|
|
|
+wmm_enabled=0
|
|
|
+macaddr_acl=0
|
|
|
+auth_algs=1
|
|
|
+ignore_broadcast_ssid=0
|
|
|
+wpa=2
|
|
|
+wpa_passphrase=$passphrase
|
|
|
+wpa_key_mgmt=WPA-PSK
|
|
|
+wpa_pairwise=TKIP
|
|
|
+rsn_pairwise=CCMP
|
|
|
+" > /etc/hostapd/hostapd.conf
|
|
|
+echo 'DAEMON_CONF="/etc/hostapd/hostapd.conf"' >> /etc/default/hostapd
|
|
|
+systemctl start hostapd
|
|
|
+cp /etc/sysctl.conf /etc/sysctl.bak
|
|
|
+echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
|
|
|
+echo "up iptables-restore < /etc/iptables.ipv4.nat" >> /etc/network/interfaces
|
|
|
+sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
|
|
|
+iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
|
|
+iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
|
|
|
+iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
|
|
|
+sh -c "iptables-save > /etc/iptables.ipv4.nat"
|
|
|
+sed -i '/exit 0/ i iptables-restore < /etc/iptables.ipv4.nat' /etc/rc.local
|
|
|
+EOF
|
|
|
+chmod +x install_hotspot.sh
|
|
|
+sudo ./install_hotspot.sh
|
|
|
+rm install_hotspot.sh
|
|
|
+touch .step1
|
|
|
+fi
|
|
|
+
|
|
|
+
|
|
|
+if [ ! -f .step2 ]
|
|
|
+then
|
|
|
+sudo apt-get install git build-essential autoconf automake \
|
|
|
+ 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
|
|
|
+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
|
|
|
+sudo cp 70-bfgminer.rules /etc/udev/rules.d/
|
|
|
+cd $locat
|
|
|
+touch .step2
|
|
|
+fi
|
|
|
+
|
|
|
+if [ ! -f .step3 ]
|
|
|
+then
|
|
|
+echo "Download Okcash Node:"
|
|
|
+cd ~
|
|
|
+git clone https://github.com/wareck/okcash_node.git
|
|
|
+echo "Préconfiguration de Oknode"
|
|
|
+cd ~/okcash_node/hardware/
|
|
|
+./led-status.sh
|
|
|
+./fan-control.sh
|
|
|
+./rtc.sh
|
|
|
+./rtc.sh
|
|
|
+./usb.sh
|
|
|
+cd $locat
|
|
|
+touch .step3
|
|
|
+echo "Reboot"
|
|
|
+exit
|
|
|
+fi
|
|
|
+
|
|
|
+if [ ! -f .step4 ]
|
|
|
+then
|
|
|
+echo "Build Okcash Node:"
|
|
|
+cd /home/pi/okcash_node/build_node.sh
|
|
|
+cd $locat
|
|
|
+touch .step4
|
|
|
+fi
|
|
|
+
|
|
|
+if [ ! -f .step5 ]
|
|
|
+then
|
|
|
+sudo mkdir /var/www/miner/
|
|
|
+sudo cp /home/pi/bfgminer/miner.php /var/www/miner/index.php
|
|
|
+cd $locat
|
|
|
+cat <<'EOF'>> default
|
|
|
+server {
|
|
|
+ listen 80 default_server;
|
|
|
+ listen [::]:80 default_server;
|
|
|
+ root /var/www/node_status;
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+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
|
|
|
+sudo cp default /etc/nginx/sites-available/
|
|
|
+rm default
|
|
|
+sudo /etc/init.d/nginx restart
|
|
|
+touch .step5
|
|
|
+echo "Terminé !"
|
|
|
+fi
|
|
|
+
|
|
|
+
|