Bitcoin Forum
July 19, 2018, 12:54:45 AM *
News: Latest stable version of Bitcoin Core: 0.16.1  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Automate Your miners setup for ur S9 farm | Beta  (Read 850 times)
does
Copper Member
Member
**
Offline Offline

Activity: 103
Merit: 11


View Profile
January 21, 2018, 07:27:30 PM
Merited by bitcoin revo (1)
 #1

moved from there https://bitcointalk.org/index.php?topic=2788273.msg28619062#msg28619062
tips are welcome BTC/BCH: 1JpmzRLXErkhVU11TUe9Ee4nS1zv77tF7b  ETH: 0x6d8fc552f832f69D1EBf236A56F196C176aD5cf5


happen to u that u got tired to setup each miner in ur small/medium farm ? if yes this script is for u.
in short u wont need to enter the web application of each miner and configure them one by one. its tiring and not so fun when u have 10 20 30 50 miners.
i made a little script that will save u A lot of time.
u configure the script ones as u wish , and then run it, it take 5 seconds to configure ur miner (really only 5 sec)




so here is my first script. explanation below
https://pastebin.com/SeMJwsRP
Code:
#!/bin/sh

#https://bitcointalk.org/index.php?topic=2799605.msg

cp /config/bmminer.conf /config/bmminer.conf.backup
cp /config/network.conf /config/network.conf.backup

rm /config/bmminer.conf
rm /config/network.conf

touch /config/bmminer.conf
touch /config/network.conf

echo "{"                                                            >> /config/bmminer.conf
echo "\"pools\" : ["                                                            >> /config/bmminer.conf
echo "{"                                                            >> /config/bmminer.conf
echo "\"url\" : \"stratum.antpool.com:3333\","                                                            >> /config/bmminer.conf
echo "\"user\" : \"test.$1\","                                                            >> /config/bmminer.conf
echo "\"pass\" : \"123\""                                                            >> /config/bmminer.conf
echo "},"                                                            >> /config/bmminer.conf
echo "{"                                                            >> /config/bmminer.conf
echo "\"url\" : \"stratum.antpool.com:3333\","                                                            >> /config/bmminer.conf
echo "\"user\" : \"test.$2\","                                                            >> /config/bmminer.conf
echo "\"pass\" : \"123\""                                                            >> /config/bmminer.conf
echo "},"                                                            >> /config/bmminer.conf
echo "{"                                                            >> /config/bmminer.conf
echo "\"url\" : \"stratum.antpool.com:3333\","                                                            >> /config/bmminer.conf
echo "\"user\" : \"test.$3\","                                                            >> /config/bmminer.conf
echo "\"pass\" : \"123\""                                                            >> /config/bmminer.conf
echo "}"                                                            >> /config/bmminer.conf
echo "]"                                                            >> /config/bmminer.conf
echo ","                                                            >> /config/bmminer.conf
echo "\"api-listen\" : "true","                                                            >> /config/bmminer.conf
echo "\"api-network\" : "true","                                                            >> /config/bmminer.conf
echo "\"api-groups\" : \"A:stats:pools:devs:summary:version\","                                                            >> /config/bmminer.conf
echo "\"api-allow\" : \"A:0/0,W:*\","                                                            >> /config/bmminer.conf
echo "\"bitmain-use-vil\" : "true","                                                            >> /config/bmminer.conf
echo "\"bitmain-freq\" : \"550\","                                                            >> /config/bmminer.conf
echo "\"bitmain-voltage\" : \"0706\","                                                            >> /config/bmminer.conf
echo "\"multi-version\" : \"1\""                                                            >> /config/bmminer.conf
echo "}"                                                            >> /config/bmminer.conf


chmod 400 /config/bmminer.conf

echo "hostname=miner$4"                    >>  /config/network.conf
echo "ipaddress=10.0.0.$5"                  >> /config/network.conf
echo "netmask=255.255.255.0"                              >> /config/network.conf
echo "gateway=10.0.0.138"                              >> /config/network.conf
echo "dnsservers=\"8.8.8.8"\"    >> /config/network.conf

chmod 400 /config/network.conf

#/etc/init.d/bmminer.sh restart >/dev/null 2>&1
#/etc/init.d/network.sh
#/etc/init.d/avahi restart > /dev/null
#echo "root:antMiner Configuration:23c2a2d78c0d20ec069097d7d20c4392" >> /config/lighttpd-htdigest.user


ssh into ur miner
create a bash file and put the script inside or move it with scp/winscp

give it root permission to edit the files. with chmod 7777 filename.sh

u will need to do some manual modification at start.
u should manual change everything that static that should not change.
for example , pools,netmask,getway,dnsserver, the start of the miner name(hostname) and the start of the ip and the workername.
make sure u have backed up ur settings before if anything goes bad. and u can factory reset https://enforum.bitmain.com/bbs/topics/3957

running the script will be

sh filename.sh 1 2 3 4 5

1, is the first worker name
2, is the second worker name
3, is the third worker name
4, hostname
5, ip address.

please notice that the workername will be only the end of it. which mean useraccount.workernamehere, in the script its test.$1 (test = useraccount $1=workername)
if u want to change the password just uncomment the last line and put ur password instead. u can use http://www.md5.cz/ to generate a hash "password" for u.
root:antMiner Configuration:passwordhere = dad8edbc0681a4c03057417c19239983 = root:antMiner Configuration:dad8edbc0681a4c03057417c19239983 < u put this in the script

before uncomment

#/etc/init.d/bmminer.sh restart >/dev/null 2>&1
#/etc/init.d/network.sh
#/etc/init.d/avahi restart > /dev/null

please DO check the files if they are ok.
it should look like this.
/config/bmminer.conf
Code:
{
"pools" : [
{
"url" : "solo.antpool.com:3333",
"user" : "test.1",
"pass" : "123"
},
{
"url" : "stratum.antpool.com:443",
"user" : "test.1",
"pass" : "123"
},
{
"url" : "stratum+tcp://cn.ss.btc.com:3333",
"user" : "test",
"pass" : "123"
}
]
,
"api-listen" : true,
"api-network" : true,
"api-groups" : "A:stats:pools:devs:summary:version",
"api-allow" : "A:0/0,W:*",
"bitmain-use-vil" : true,
"bitmain-freq" : "550",
"bitmain-voltage" : "0706",
"multi-version" : "1"
}

/config/network.conf
Code:
hostname=miner1
ipaddress=10.0.0.1
netmask=255.255.255.0
gateway=10.0.0.200
dnsservers="8.8.8.8"

after checking the files is right. uncomment these 3 commands

will apply the pools settings
/etc/init.d/bmminer.sh restart >/dev/null 2>&1

and this will apply hostname and ip settings.
/etc/init.d/network.sh
/etc/init.d/avahi restart > /dev/null



for a real example that will be
sh script.sh m1 m1 m1 1 1
the result will be
first pool   second pool   third pool     hostname   IP
test.m1    test.m1         test.m1        miner1       10.0.0.1

if u need any help, or u want to report a bug please tell me.
or want to help to make it better welcome ur self to edit and share it



tips are welcome BTC/BCH: 1JpmzRLXErkhVU11TUe9Ee4nS1zv77tF7b  ETH: 0x6d8fc552f832f69D1EBf236A56F196C176aD5cf5
1531961685
Hero Member
*
Offline Offline

Posts: 1531961685

View Profile Personal Message (Offline)

Ignore
1531961685
Reply with quote  #2

1531961685
Report to moderator
1531961685
Hero Member
*
Offline Offline

Posts: 1531961685

View Profile Personal Message (Offline)

Ignore
1531961685
Reply with quote  #2

1531961685
Report to moderator
1531961685
Hero Member
*
Offline Offline

Posts: 1531961685

View Profile Personal Message (Offline)

Ignore
1531961685
Reply with quote  #2

1531961685
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1531961685
Hero Member
*
Offline Offline

Posts: 1531961685

View Profile Personal Message (Offline)

Ignore
1531961685
Reply with quote  #2

1531961685
Report to moderator
1531961685
Hero Member
*
Offline Offline

Posts: 1531961685

View Profile Personal Message (Offline)

Ignore
1531961685
Reply with quote  #2

1531961685
Report to moderator
fanatic26
Hero Member
*****
Offline Offline

Activity: 756
Merit: 560


View Profile
January 22, 2018, 06:40:17 PM
 #2

This is something I am sure people will find value in.

I do have a few small suggestions. Using a combination of Ansible and sed, you can make this more efficient and batch program many miners at once. You can use sed to replace individual lines rather than deleting, creating, and then modifying a new file. With ansible, you can batch them and auto generate worker names and batch program multiple miners at once and restart all the services in one shot.

Stop buying industrial miners, running them at home, and then complaining about the noise.
does
Copper Member
Member
**
Offline Offline

Activity: 103
Merit: 11


View Profile
January 22, 2018, 08:38:42 PM
 #3

This is something I am sure people will find value in.

I do have a few small suggestions. Using a combination of Ansible and sed, you can make this more efficient and batch program many miners at once. You can use sed to replace individual lines rather than deleting, creating, and then modifying a new file. With ansible, you can batch them and auto generate worker names and batch program multiple miners at once and restart all the services in one shot.

thanks alot! for ur comment Smiley i was looking for a good compliment ^.^

i did decide to backup the file and deleting it than creating it from scratch to avoid any miss writing into the file.
its safer this way.

about doing that multiple miners at ones im not yet sure how to do so. the reason for this script is to be organized .
what i mean by that is if u have 10 20 30 miners on shelf u want to know where is each miner .
me myself i wouldn't plug them all at ones and try to discover which miner is which and configuring them all at ones.

my thought is more like this, if u want to plug them all at ones, bitmain as a tool which called IP reporter. https://shop.bitmain.com/support.htm?pid=00720160906053730999PVD2K0vz0693
what u can do is press the button on the miner for 5 second (open their program before), and then u will get the miner ip , so u know which one to ssh to
lets say
u press on shelf 2 miner 6, u will get a dhcp ip lets say 10.0.0.51 , u just ssh to 10.0.0.51 and move over the script and run it sh script.sh 6 6 6 6 6 so the miner will be on ip 10.0.0.6

i guess u understand that already when reading the first post.


fanatic26
Hero Member
*****
Offline Offline

Activity: 756
Merit: 560


View Profile
January 22, 2018, 10:21:04 PM
 #4

An alternate way to get around the location issue would be to power the miners up 1 by 1 so they grab sequential DHCP IPs before staticing. Theres always multiple ways to do things and in the end most of them work. Good job on the script!

Stop buying industrial miners, running them at home, and then complaining about the noise.
SkyLakeMine
Member
**
Offline Offline

Activity: 98
Merit: 11


View Profile WWW
February 04, 2018, 02:02:11 AM
 #5

I am building a similar utility and will incorporate some of the ideas on this thread.

I agree with use of sed command to update the conf file.

For example the following command sets up miner to privileged mode so it can be controlled through api

sed -i 's_^\("api-allow" : \).*_\1"W:your.remote.ip.address,W:192.168.0.1/16,A:0/0",_' bmminer.conf


The general idea of something I would like to do is to
    - scan local subnet addresses to find ip addresses that respond on port 4028
    - check if the miner has already been "provisioned" with my custom settings
    - run the setup batch file if needed

I don't have all of these steps automated yet but I have a few steps ready.

https://github.com/dfoderick/Mining/blob/master/Antminer/antminerS9api_privileged.sh

mining smarter @Where2Mine
does
Copper Member
Member
**
Offline Offline

Activity: 103
Merit: 11


View Profile
March 07, 2018, 05:12:41 PM
 #6

as more i think of it.
its even easier to download the file (script) to ur antminer.
u can ssh to it, and instead of copy pasting or sharing it with wincp
u can either open a localhost web which will host the script that u want for example SimpleHTTPServer (python) or putting ur script in pastbin (register allowed so u can edit the file online) or github.
then what u have to do is just wget link.com/file
Morescratch
Newbie
*
Offline Offline

Activity: 6
Merit: 0


View Profile
March 08, 2018, 11:54:02 PM
 #7

Hi all, excellent thread. I think I am going to want to do the same thing. My issue is I want to do this using Python. I can send commands such as 'status' to a miner and get some info but what I really want to do is set the pools, assign an IP, change the root password, etc.

Any ideas on how I might do what SkyLakeMine suggests:

Code:
sed -i 's_^\("api-allow" : \).*_\1"W:your.remote.ip.address,W:192.168.0.1/16,A:0/0",_' bmminer.conf

I want to do the same but with Python... Possible?

Also, assuming I can use the API, is there any docs for it? I looked on BMMiner and I can't find anything...

Cheers,

Morton.
SkyLakeMine
Member
**
Offline Offline

Activity: 98
Merit: 11


View Profile WWW
March 09, 2018, 03:51:24 AM
 #8

I want to do the same but with Python... Possible?


I am putting everything together to be released as open source.

Here it is in python. miner and login are my classes. You can use tuples or just hard code the ip, user, pwd for testing.

The basic idea is to connect to miner using ssh, run the commands and reboot the miner. Then you can hit the api and add and switch pools.

forum wont let me post.

https://pastebin.com/15feyq1Q

mining smarter @Where2Mine
Morescratch
Newbie
*
Offline Offline

Activity: 6
Merit: 0


View Profile
March 11, 2018, 01:54:24 AM
 #9

Many thanks, SkyLakeMine!

I now need to find out what port in the switch that miner is plugged into. In the configuration on the miner I can see the hostname which is the port. How can get this via the API? I am getting the following but none of it gives me the hostname:

print miner.version()
print miner.stats()
print miner.summary()
print miner.pools()
print miner.config()
print miner.devs()

Any ideas? I guess worst case I can get it through the cgi interface but that seems kludgy.
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!