GithubHelp home page GithubHelp logo

miqueet / helium_miner_scripts Goto Github PK

View Code? Open in Web Editor NEW
45.0 11.0 31.0 139 KB

This repo was made out of the need to auto update DIY helium miners

Shell 100.00%
docker miner cron linux helium curl jq

helium_miner_scripts's Introduction

Helium miner update script

This script will automatically detect if that latest docker image is running and if this is not the case it will update to the latest docker image.

For the Validator scripts, see the /Validator directory

If this guide/script helped you please consider donating HNT the following address

13UcQB9B867b6Fp6cwtKgzxfwrr61sbxMpPsXChqPYRr9iFoTar

Setup

$ git clone https://github.com/Wheaties466/helium_miner_scripts
$ cd helium_miner_scripts/

Then run any of the scripts.

Updating the repo/script to get the lastest version of the script

$ cd helium_miner_scripts/
$ git pull

after you're in the same directory as the script and do a git pull. It will let you know if it is up to date or not.

Dependencies

Following dependencies shall be met:

  • Curl
  • jq
$ sudo apt install curl jq -y

Make sure the user that is running the script is allowed to run docker. Either add the user to the docker group or run the scipt as root. See: https://docs.docker.com/engine/install/linux-postinstall/

Configuration

After cloning this repository make the script executable:

$ chmod +x miner_latest.sh
$ sudo touch /var/log/miner_latest.log

Change architecture

Currently it is setup to use arm64 version, but it can be easily modified to use the amd64 docker image build by modifying the ARCH variable to equal amd instead of arm.

Change region

By default the script is configured for US915 frequencies. To use the miner in other regios like EU868 the script shall be changed by adding the --env REGION_OVERRIDE=EU868 to the line with docker run:

docker run -d --env REGION_OVERRIDE=EU868 --restart always --publish 1680:1680/udp --publish 44158:44158/tcp --name miner --mount type=bind,source=/home/pi/miner_data,target=/var/data quay.io/team-helium/mi$

Script useage

$ ./miner_latest.sh

This can be called from a cron or ran in a shell.

Using cron

Add the following lines to your crontab using sudo crontab -e to run the script daily at 1 o clock at night: The second line updates this repo on a regular basis.

# Check for updates on miner image every night at 1 o clock

# Use whatever path you have your repo setup with.
# If you need to test your cron you can use the following site and add "&& curl -s 'https://webhook.site/#!/~'" to the end of your cron and it will make a web request to your specific url when it completes.
0 */4 * * * /home/pi/helium_miner_scripts/miner_latest.sh 2>&1 >> /var/log/miner_latest.log

Extra

Check if your miner is running and receiving data from your gateway:

$ docker exec miner tail -f /var/log/miner/console.log | grep "lora"

Check progress of your miner on the blockchain:

$ docker exec miner miner info height

Check connectivity of your miner:

$ docker exec miner miner peer book -s

Check the current running miner version

$ docker container inspect -f '{{.Config.Image}}' miner | awk -F: '{print $2}'

helium_miner_scripts's People

Contributors

cascading-jox avatar clendaniel avatar j3rm avatar mfalkvidd avatar miqueet avatar olb1ue avatar pe1mew avatar snomu avatar tedder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

helium_miner_scripts's Issues

Stopping and Removing Miner Even on Latest Version

Hi,

Thank you so much for your script.

I am having an issue with it stopping the container and removing the miner software even when it is on the latest version.

I would prefer if it didn't stop the container and update every time unless it needs to actually update the software. Can you help me with that?

Many thanks

Zombie's in the house

It seems that if the miner process crashes within the docker it restarts but zombies occur the work around is to add --init to the docker run command to do this the docker creation command needs to include --init like this

docker run -d --init --env REGION_OVERRIDE=$REGION --restart always --publish $GWPORT:$GWPORT/udp --publish $MINERPORT:$MINERPORT/tcp --name $MINER --mount type=bind,source=$DA$

this was seen by othes in the diy thread on discord

https://discordapp.com/channels/404106811252408320/730246424666832947/770990904861261834

confusion between mainnet and testnet images

Due to the latest change, the script installs an image for mainnet on the server. I suggest making an option at the beginning of the file or in config.txt in order for the script to correctly download the correct image, depending on which network you need to make an update.

restarting

Is the restarting normal when I run a script?

Issue Updating miner software

Hello,

There is an issue when updating the miner software as it will often miss a firmware version,

The has been occasions where the GA has not been added to the filename. For example the update miner-arm64_2021.07.14.0 to miner-amd64_2021.07.14.2 does not contain the GA so that update is missed

miner_latest=$(echo "$miner_quay" | grep -v HTTP_Response | jq -c --arg ARCH "$ARCH" '[ .tags[] | select( .name | contains($ARCH)and contains("GA")) ][0].name' | cut -d'"' -f2)

Regards,

Andrew

docker image rm uses wrong format?

When the miner is more than 500 blocks behind, removal of the image does not work.

This is what the script tries to do:

docker image rm miner-amd64_2020.10.12.1_GA
Error response from daemon: invalid reference format: repository name must be lowercase

The command should probably be

docker image rm quay.io/team-helium/miner:miner-arm64_2020.10.12.1_GA
Untagged: quay.io/team-helium/miner:miner-arm64_2020.10.12.1_GA
Untagged: quay.io/team-helium/miner@sha256:0546a3dfa164943cfc5624fe467d0ae5c8446721be29adefef92b8a474702881
Deleted: sha256:528a9811811a3f9e5260285f5547b172a16ef0255d0e568c883aa235a4ca8306
Deleted: sha256:e6f2f7ea131c9b55aabcd74990f690f23054486cacc9ab8c8ce9572dffaccd93
Deleted: sha256:7f177e2014a00adca6235e9608a44d5426862a6bd8128a3102ba337a59c1e17e
Deleted: sha256:88ac2f8395988ec4a6199a917cb9795cfb0e27e00ba3d79b5911415028a523a5
Deleted: sha256:500340c4b43178cc5fe2218a059bf1cfbec51db3af48eae19c8753f3160423f1
Deleted: sha256:678a0785e7d29c77c56c1bb0af4b279374e731903506838956f7bc808665a6dd

But since I don't understand why we're removing the image, I'm not 100% sure how this should be fixed.

Also, the following code:

if [[ $height_diff -gt 50 ]]; then docker stop "$MINER" && docker start "$MINER" ; fi

#If the miner is more than 500 blocks behind, stop the image, remove the container, remove the image. It will be redownloaded later in the script.
if [[ $height_diff -gt 500 ]]; then docker stop "$MINER" && docker rm "$MINER" && docker image rm "$miner_latest" ; fi

will first stop the miner, due to height_diff being greater than 50. Then the second if clause (>500) will try to stop the miner again - which will fail with Error response from daemon: No such container: causing the docker rm and docker image rm to not be run.

Maybe it should be changed to

if [[ $height_diff -gt 50 ]]; then docker stop "$MINER" && docker start "$MINER" ; fi

#If the miner is more than 500 blocks behind, stop the image, remove the container, remove the image. It will be redownloaded later in the script.
if [[ $height_diff -gt 500 ]]; then docker image rm "$miner_latest" ; fi

There might be a race condition here though - if it takes time to stop and remove the container? I think docker stop and docker rm can return before the command has finished completely?

seems to be stopping the miner and deleting the local image

I haven't had time to get to the bottom of this but it appears to be deleting the local image and stopping the container. Add any relevant info here.

I believe this is related to the code that tries to assist in getting the miner back up and running if it falls behind a sync with the blockchain. Testing out additional code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.