wareck 2 years ago
parent
commit
929a689c94
5 changed files with 131 additions and 271 deletions
  1. 0 47
      bfgminer.conf
  2. BIN
      bfgminer.tar.xz
  3. 66 196
      buildit.sh
  4. 65 0
      install_hotspot.sh
  5. 0 28
      rc.local

+ 0 - 47
bfgminer.conf

@@ -1,47 +0,0 @@
-{
-"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"
-]
-}

BIN
bfgminer.tar.xz


+ 66 - 196
buildit.sh

@@ -1,214 +1,68 @@
 #!/bin/bash
-locat=$PWD
-echo "automated installation for oknode"
-echo "need several reboot"
-sleep 5
-
-if [ ! -f .step0 ]
-then
+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 -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:"
+}
+function okcash_download_mod {
 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;
-  }
+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
+}
 
-  location ~ \.php$ {
-    include snippets/fastcgi-php.conf;
-    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
-  }
-  location ~ /\.ht {
-    deny all;
-  }
+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;
@@ -228,11 +82,27 @@ server {
   }
 }
 EOF
-sudo cp default /etc/nginx/sites-available/
-rm default
-sudo /etc/init.d/nginx restart
-touch .step5
-echo "Terminé !"
+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
+}
 
+bfgminer
+okcash_download_mod
+hotspot
+website_ext
 
+echo "normalement tout est ok..."
+echo "reboot et tests"

+ 65 - 0
install_hotspot.sh

@@ -0,0 +1,65 @@
+#!/bin/bash
+# Based on Adafruit Learning Technologies Onion Pi project
+# But mainly fixed by Raspberry Pi FR...
+
+if (( $EUID != 0 )); then
+   echo "This must be run as root. Try 'sudo bash $0'." 
+   exit 1
+fi
+apt-get update -y
+apt install dnsmasq -y
+systemctl stop dnsmasq
+
+echo "interface wlan0
+    static ip_address=192.0.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=192.0.4.2,192.0.4.22,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
+exit 0

+ 0 - 28
rc.local

@@ -1,28 +0,0 @@
-#!/bin/sh -e
-#
-# rc.local
-#
-# This script is executed at the end of each multiuser runlevel.
-# Make sure that the script will "" on success or any other
-# value on error.
-#
-# In order to enable or disable this script just change the execution
-# bits.
-#
-# By default this script does nothing.
-
-# Print the IP address
-_IP=$(hostname -I) || true
-if [ "$_IP" ]; then
-  printf "My IP address is %s\n" "$_IP"
-fi
-#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 --api-allow 127.0.0.1 --api-listen'
-
-iptables-restore < /etc/iptables.ipv4.nat
-
-#OKcash Node Start
-su - pi -c 'okcashd --printtoconsole'
-exit 0