Setting Up The ML2 To Auto Run In Detached Screen Using Raspberry pi3Some might find this useful and possibly it will work as well for you as it does for me on my setup using Raspian (debian) on a Raspberry pi3+ to control the Moonlander 2 USB ASIC Miners.The directories are those that I have renamed and yours will most likely be different so alter the structure accordingly. Also your choice of difficulty and frequency may be different so make changes there as well. This assumes that you have installed BFGminer correctly and any JSON libraries needed and that you can call the program successfully from the command line already.
1.) If you don't already have 'Screen' installed then install it:
sudo apt-get update
sudo apt-get install screen2.) Using 'Putty' navigate to directory 'etc' (cd ./etc)
3.) Command Line:
sudo nano rc.local 4.) After the
'fi' and before the
'exit 0' within
rc.local paste the following lines (you have to arrow down with keyboard prior to right clicking mouse to paste)
#Run bfgminer as `pi` from the home folder
#in a screen named `moonlander`
sudo su - pi -c "screen -dm -S moonlander /home/pi/bfgminer/bfgminer --scrypt -o stratum+tcp://hash-to-coins.com:3333 -u username.workername -p 1,d=512 -S ALL --set MLD:clock=900"5.) Using the keyboard to navigate make the required changes to reflect your path, chosen server, your username, difficulty, frequency, etc..
6.) When all has been changed that needs to be, 'CTRL-O' and then 'Enter' to write the changes to file and then 'CTRL-X' to exit the nano editor.
7.) Command Line: ./rc.local to test it out and see if it is able to execute the program in a screen.
8.) If the program executes properly and the miner starts operating then from the command line you can enter: screen -r and that will reattach the screen 'moonlander' to your putty session.
9.) To exit putty without stopping the screen, just close putty using the 'X' on your window. (closing the window using 'Q' or 'CTRL-C' will end the screen process - you don't want to do that.)
10.) You can then bring up a new session of putty and after logging in, from the command line enter:
sudo reboot and check if it auto starts the BFGminer once the pi3 restarts.
In the command line used above the following are variable:
- moonlander - that is just any arbitrary name used to identify the screen session created.
- /home/pi/bfgminer/ -the path on my particular pi3 setup.
- hash-to-coins.com_3333 - my choice of server to use_
- -u username.workername -p 1,d=512 - you may only have one username or possibly a wallet address - also in place of password on the server I use the 512 is the difficulty. You may not even wish to have a set difficulty or the server may not support it.
- clock=900 - the various core clock speeds vary and yours might be higher or lower depending on how you tuned your device_
I will also note that in the 'sudo su - pi -c "screen -dm -S moonlander ' section, the 'sudo' is placed in front of the 'su' command to eliminate the password requirement otherwise everytime it went to boot it would hang waiting on a password that is not coming and then the program would not start. There may very well be a password switch to use in conjunction with the 'su' command but I just went with what worked for me.
Good Luck!