Skip to content

Instantly share code, notes, and snippets.

@clintar
Created October 28, 2021 04:39
Show Gist options
  • Save clintar/4ce7060345949c0423a2f582ff63ee9c to your computer and use it in GitHub Desktop.
Save clintar/4ce7060345949c0423a2f582ff63ee9c to your computer and use it in GitHub Desktop.
param (
[Parameter(Mandatory=$false)][string]$miner_ip = "none"
)
if ($miner_ip -eq "none")
{
Write-Output "Please pass the IP address of your miner as an argument"
Exit 1
}
$miner_status = Invoke-RestMethod -Uri "http://$miner_ip/status.json"
if(!$?)
{
Write-Output "Failed to connect to miner... exiting"
Exit 1
}
Write-Output $response.miner_height
$snapshot_status = Invoke-RestMethod -Uri "https://us915.s3.amazonaws.com/assets/snaps/snapshot.json"
if(!$?)
{
Write-Output "Failed to check snapshot height"
Exit 1
}
Write-Output $snapshot_status.height
$auth = 'bobcat' + ':' + 'miner'
$Encoded = [System.Text.Encoding]::UTF8.GetBytes($auth)
$authorizationInfo = [System.Convert]::ToBase64String($Encoded)
$headers = @{"Authorization"="Basic $($authorizationInfo)"}
$basicAuthValue = "Basic Ym9iY2F0Om1pbmVy"
$Headers = @{"Authorization"="Basic Ym9iY2F0Om1pbmVy"}
if ($response.miner_height -lt $snapshot_status.height)
{
Invoke-WebRequest -Uri "http://$miner_ip/admin/fastsync" -UseBasicParsing -Method POST -Headers $($Headers)
}
else
{
Write-Output "Miner is synced"
}
@clintar
Copy link
Author

clintar commented Oct 28, 2021

Click start menu, start typing powershell, open the Powershell ISE,
click the New Script icon in the top left,
paste contents of this gist into the document body, click save,
name it check-miner-sync.ps1
This should save into the Documents folder.
then in the blue console area type
Documents\check-miner-sync.ps1 [MINER_IP]
the press enter, replacing [MINER_IP] with your miner's IP address.

@clintar
Copy link
Author

clintar commented Oct 28, 2021

If you it tells you that scripts are not allowed to run, go to start menu, start typing powershell,
right-click on the powershell application name, and select run as administrator. when it comes up, type:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted and then yes or yes to all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment