Post
Topic
Board Hardware
Re: GekkoScience 2Pac BM1384 Stickminer Official Support Thread
by
jogger1
on 17/04/2018, 23:04:38 UTC

Yes, ^M is interpreted by screen to send a (Cr) into the terminal.

The remaining piece:

forever run cgminer with a restart every 4 hours.

second terminal
Code:
while [ true ]; do
    timeout 4h /home/pi/git/vthoang/cgminer/cgminer --gekko-2pac-freq 180 -o stratum+tcp://bch.viabtc.com:3333 -u usaminer.2 -p 1 --suggest-diff 64
    sleep 5
done

finishing it up:

runtask.sh
Code:
#!/bin/bash
screen_name=miner1

if [[ `screen -ls | grep $screen_name | wc -l` -eq 0 ]]; then
    screen -dmS $screen_name
fi

screen -S $screen_name -X stuff ^C^C^C

screen -S $screen_name -X stuff "
while [ true ]; do
    timeout 4h /home/pi/git/vthoang/cgminer/cgminer --gekko-2pac-freq 180 -o stratum+tcp://bch.viabtc.com:3333 -u usaminer.2 -p 1 --suggest-diff 64
    sleep 5
done
"

crontab
Code:
@reboot /home/pi/git/vthoang/cgminer/runtask.sh


on reboot:
check for existing screens, and attach to confirm
Code:
screen -ls
screen -x miner1



So my script writing abilities arent that good, but im just trying to make a simple script (i mean ELI5 simple) and here is what i got so far.

Code:
#!/bin/bash
screen -dmS miner1
screen -S miner1 -X stuff "timeout 10s /home/pi/git/vthoang/cgminer/cgminer --gekko-2pac-freq 180 -o stratum+tcp://bch.viabtc.com:3333 -u usaminer.2 -p 1 --suggest-diff 64 ^M
done"
screen -S miner1 -r

Now here is where i am stuck. (i know i have this timeout at 10s) but once the timeout is done the screen goes back to command line and the rest of my script doesnt run. Now when i type in exit on the command line then the next part of my script starts up (which is a replica of the above script). I have tried everything to get the exit command to go into the command line after the first part of the script runs, but nothing happens.

What can i do to get my screen to exit so the rest of my script can run?

Thanks and sorry for the elementary abilities. I am having fun learning on the way, it has taken me 5 days to get where i am now!

Here is where i am stuck

Code:
#!/bin/bash
{
#
#first instance
#
screen -dmS miner1
screen -S miner1 -X stuff "timeout 10s /home/pi/git/vthoang/cgminer/cgminer --gekko-2pac-freq 180 -o stratum+tcp://bch.viabtc.com:3333 -u usaminer.2 -p 1 --suggest-diff 64 ^M
done"
screen -S miner1 -r

i need this to insert exit into the command line and go

#
#second instance
#
screen -dmS miner1
screen -S miner1 -X stuff "timeout 30s /home/pi/git/vthoang/cgminer/cgminer --gekko-2pac-freq 180 -o stratum+tcp://bch.viabtc.com:3333 -u usaminer.2 -p 1 --suggest-diff 64 ^M
done"
screen -S miner1 -r

i need this to insert exit into the command line and go

#
#third instance
#
screen -dmS miner1
screen -S miner1 -X stuff "killall screen
exit"
screen -S miner1 -r

} 2>&1 | tee script-error.log