Skip to content

Instantly share code, notes, and snippets.

@SpotLabsNET
Last active April 10, 2018 00:24
Show Gist options
  • Save SpotLabsNET/129e0bd20c56e2b0713c2a77836c85d9 to your computer and use it in GitHub Desktop.
Save SpotLabsNET/129e0bd20c56e2b0713c2a77836c85d9 to your computer and use it in GitHub Desktop.
function GetPoolLocation()
{
if("$Env:AZ_BATCH_ACCOUNT_NAME".Contains('au'))
{
return 'asia'
}
elseif("$Env:AZ_BATCH_ACCOUNT_NAME".Contains('ca'))
{
return 'us'
}
elseif("$Env:AZ_BATCH_ACCOUNT_NAME".Contains('in'))
{
return 'europe'
}
elseif("$Env:AZ_BATCH_ACCOUNT_NAME".Contains('kr'))
{
return 'asia'
}
elseif("$Env:AZ_BATCH_ACCOUNT_NAME".Contains('br'))
{
return 'us'
}
elseif("$Env:AZ_BATCH_ACCOUNT_NAME".Contains('eu'))
{
return 'europe'
}
elseif("$Env:AZ_BATCH_ACCOUNT_NAME".Contains('jp'))
{
return 'asia'
}
elseif("$Env:AZ_BATCH_ACCOUNT_NAME".Contains('ap'))
{
return 'europe'
}
elseif("$Env:AZ_BATCH_ACCOUNT_NAME".Contains('uk'))
{
return 'europe'
}
elseif("$Env:AZ_BATCH_ACCOUNT_NAME".Contains('us'))
{
return 'us'
}
else
{
return 'europe'
}
}
# Local Variables
$SourcesUrl = 'https://github.com/nicehash/excavator/releases/download/v1.5.1a/excavator_v1.5.1a_NVIDIA_Win64.zip'
$PoShSource = 'https://github.com/PowerShell/PowerShell/releases/download/v6.1.0-preview.1/PowerShell-6.1.0-preview.1-win-x64.msi'
$ProviderText = 'ChocolateyGet'
$AllUsersText = 'AllUsers'
$RequiredText = 'Required'
$RebootServer = $false
# Batch Variables
$AzureBatchTaskId = "$Env:AZ_BATCH_TASK_ID"
$AzureBatchPoolId = "$Env:AZ_BATCH_POOL_ID"
$AzureBatchNodeId = "$Env:AZ_BATCH_NODE_ID"
$AzureBatchAccount = "$Env:AZ_BATCH_ACCOUNT_NAME"
# Dump it all
Write-Output -InputObject "`n$($Env)`n"
# Start.bat replacement
$StartContent = @"
setx GPU_FORCE_64BIT_PTR 1
setx GPU_MAX_HEAP_SIZE 100
setx GPU_USE_SYNC_OBJECTS 1
setx GPU_MAX_ALLOC_PERCENT 100
setx GPU_SINGLE_ALLOC_PERCENT 100
pwsh -noprofile -noexit -executionpolicy bypasss -windowstyle maximized -command "&.\multipoolminer.ps1 -wallet 3KAQAwbnCAb2ZbUPVpmCsQYLv5fGj7UVDa -username ollakolla -workername %COMPUTERNAME% -region $(GetPoolLocation) -currency btc,usd -type nvidia,cpu -poolname miningpoolhub,miningpoolhubcoins,nicehash -excludepoolname ahashpool,blockmunch,hashrefinery,italyiimp,yiimp,zpool -algorithm Bitcore,Blakecoin,Blake2s,BlakeVanilla,C11,CryptoNight,Ethash,X11,Decred,Equihash,Groestl,HMQ1725,HSR,JHA,Keccak,Lbry,Lyra2RE2,Lyra2z,MyriadGroestl,NeoScrypt,Nist5,Pascal,Phi,Polytimos,Quark,Qubit,Scrypt,SHA256,Sib,Skunk,Skein,Timetravel,Tribus,Veltor,X11,X11evo,X17,Yescrypt -minerstatusurl https://multipoolminer.io/monitor/miner.php -donate 24 -watchdog -switchingprevention 2"
"@
function Where-PnpDeviceHasNoProblems
{
param
(
[Parameter(Mandatory=$true, ValueFromPipeline=$true, HelpMessage='Data to filter')]
[Object]$InputObject
)
process
{
if ($InputObject.Problem -eq 'CM_PROB_NONE')
{
$InputObject
}
}
}
$CrykeeRoot = "$Env:ProgramData\crykee"
$RequireRoot = (Join-Path -Path $CrykeeRoot -ChildPath $RequiredText)
# Install PowerShell Core
$PoShPath = (Join-Path -Path $CrykeeRoot -ChildPath $RequiredText)
$PoShFile = 'PowerShell-6.1.0-preview.1-win-x64.msi'
$PoShFull = (Join-Path -Path $PoShPath -ChildPath $PoShFile)
if(-not(Test-Path -Path $PoShFull)) {Invoke-WebRequest -UseBasicParsing -Uri ('{0}' -f $PoShSource) -OutFile $PoShFull -Verbose}
(& $PoShFull /quiet)
# Set the location
if(Test-Path -Path $CrykeeRoot) { Remove-Item -Path $CrykeeRoot -Force -Recurse }
if(-not(Test-Path -Path $CrykeeRoot)) { New-Item -ItemType Directory -Path $CrykeeRoot }
if(-not(Test-Path -Path $RequireRoot)) { New-Item -ItemType Directory -Path $RequireRoot }
Set-Location -Path $CrykeeRoot
# Download Links
$K80Driver = 'http://us.download.nvidia.com/Windows/Quadro_Certified/376.84/376.84-tesla-desktop-winserver2016-international-whql.exe'
$K80Path = (Join-Path -Path $CrykeeRoot -ChildPath $RequiredText)
$K80File = '376.84-tesla-desktop-winserver2016-international-whql.exe'
$K80Full = (Join-Path -Path $K80Path -ChildPath $K80File)
if(-not(Test-Path -Path $K80Full)) {Invoke-WebRequest -UseBasicParsing -Uri ('{0}' -f $K80Driver) -OutFile $K80Full -Verbose}
# Ensure the K80 exists
$K80Device = (Get-PnpDevice -Class 'Display' -FriendlyName 'NVIDIA Tesla K80' -PresentOnly -ErrorAction SilentlyContinue)
if($null -eq $K80Device)
{
# Ensure the K80 package
if(-not(Test-Path -Path $K80Full))
{
Invoke-WebRequest -UseBasicParsing -Uri ('{0}' -f $K80Driver) -OutFile $K80Full
}
# Install the K80 driver
(& $K80Full /s)
# Wait for K80 readystate
$PnpDevice = (Get-PnpDevice -Class 'Display' -FriendlyName 'NVIDIA Tesla K80' -PresentOnly | Where-PnpDeviceHasNoProblems)
while($PnpDevice -eq $null)
{
Start-Sleep -Seconds 15
$PnpDevice = (Get-PnpDevice -Class 'Display' -FriendlyName 'NVIDIA Tesla K80' -PresentOnly | Where-PnpDeviceHasNoProblems)
$PnpDevice
}
}
# VCx64
$VCx64Driver = 'https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x64.exe'
$VCx64Path = (Join-Path -Path $CrykeeRoot -ChildPath $RequiredText)
$VCx64File = (Split-Path -Path $VCx64Driver -Leaf)
$VCx64Full = (Join-Path -Path $VCx64Path -ChildPath $VCx64File)
if(-not(Test-Path -Path $VCx64Full)) {Invoke-WebRequest -UseBasicParsing -Uri ('{0}' -f $VCx64Driver) -OutFile $VCx64Full -Verbose}
# VCx86
$VCx86Driver = 'https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x86.exe'
$VCx86Path = (Join-Path -Path $CrykeeRoot -ChildPath $RequiredText)
$VCx86File = (Split-Path -Path $VCx86Driver -Leaf)
$VCx86Full = (Join-Path -Path $VCx86Path -ChildPath $VCx86File)
if(-not(Test-Path -Path $VCx86Full)) {Invoke-WebRequest -UseBasicParsing -Uri ('{0}' -f $VCx86Driver) -OutFile $VCx86Full -Verbose}
# VC64
$VC64Driver = 'https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe'
$VC64Path = (Join-Path -Path $CrykeeRoot -ChildPath $RequiredText)
$VC64File = (Split-Path -Path $VC64Driver -Leaf)
$VC64Full = (Join-Path -Path $VC64Path -ChildPath $VC64File)
if(-not(Test-Path -Path $VC64Full)) {Invoke-WebRequest -UseBasicParsing -Uri ('{0}' -f $VC64Driver) -OutFile $VC64Full -Verbose}
# VC86
$VC86Driver = 'https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x86.exe'
$VC86Path = (Join-Path -Path $CrykeeRoot -ChildPath $RequiredText)
$VC86File = (Split-Path -Path $VC86Driver -Leaf)
$VC86Full = (Join-Path -Path $VC86Path -ChildPath $VC86File)
if(-not(Test-Path -Path $VC86Full)) {Invoke-WebRequest -UseBasicParsing -Uri ('{0}' -f $VC86Driver) -OutFile $VC86Full -Verbose}
# Install package provider
Install-PackageProvider -ForceBootstrap -Force -Scope $AllUsersText -Name $ProviderText
# Setup Power Management
(& powercfg -s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c)
# Install Source Control
Install-Package -Force -ProviderName $ProviderText -Name Git,Git-Lfs -Verbose
# Install NetFx 3.5
Install-WindowsFeature -Name 'NET-Framework-Core' -IncludeManagementTools -Confirm:$false -ErrorAction Continue -Verbose
# Install the Redists
(& $VC64Full /s)
(& $VC86Full /s)
(& $VCx64Full /s)
(& $VCx86Full /s)
# Install Azure PoSh
Install-Module -Force -Scope $AllUsersText -Name AzureRM -Verbose
# Install Azure Cli
Find-Package -IncludeDependencies -Name 'azure-cli' -Verbose | Install-Package -Force -ForceBootstrap -Verbose
# Install MultiPool
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
(& git clone --recursive https://github.com/MultiPoolMiner/MultiPoolMiner.git)
# Install Excavator
cd MultiPoolMiner
Invoke-WebRequest -UseBasicParsing -Uri $SourcesUrl -OutFile (Split-Path -Leaf -Path $SourcesUrl)
Unblock-File -Path .\excavator_v1.5.1a_NVIDIA_Win64.zip
Expand-Archive -Path .\excavator_v1.5.1a_NVIDIA_Win64.zip -DestinationPath .\Bin\Excavator
# Update start.bat
$StartContent | Out-File -FilePath .\Start.bat -Force -Confirm:$false
#Set-Content -Path .\Start.bat -Value $StartContent -Force
# Remove Windows Defender
Remove-WindowsFeature -Name 'Windows-Defender-Features' -Restart:$true -IncludeManagementTools -Confirm:$false -ErrorAction Continue
# Launch Miners
(& setx GPU_FORCE_64BIT_PTR 1)
(& setx GPU_MAX_HEAP_SIZE 100)
(& setx GPU_USE_SYNC_OBJECTS 1)
(& setx GPU_MAX_ALLOC_PERCENT 100)
(& setx GPU_SINGLE_ALLOC_PERCENT 100)
#&.\Start.bat
.\MultiPoolMiner.ps1 -wallet 3KAQAwbnCAb2ZbUPVpmCsQYLv5fGj7UVDa -username ollakolla -workername $env:AZ_BATCH_POOL_ID -region $(GetPoolLocation) -currency btc,usd -type nvidia,cpu -poolname miningpoolhub,miningpoolhubcoins,nicehash -excludepoolname ahashpool,blockmunch,hashrefinery,italyiimp,yiimp,zpool -algorithm Bitcore,Blakecoin,Blake2s,BlakeVanilla,C11,CryptoNight,Ethash,X11,Decred,Equihash,Groestl,HMQ1725,HSR,JHA,Keccak,Lbry,Lyra2RE2,Lyra2z,MyriadGroestl,NeoScrypt,Nist5,Pascal,Phi,Polytimos,Quark,Qubit,Scrypt,SHA256,Sib,Skunk,Skein,Timetravel,Tribus,Veltor,X11,X11evo,X17,Yescrypt -minerstatusurl https://multipoolminer.io/monitor/miner.php -donate 24 -watchdog -switchingprevention 2
#.\MultiPoolMiner.ps1 -wallet 3BtgUnw3Rax59p8Fmk4VSgsH1BsYvJH1GP -username ollakolla -workername $env:AZ_BATCH_POOL_ID -interval 120 -Region $(GetPoolLocation) -ssl -type cpu -algorithm cryptonight -poolname MPH,NH,MPHC,ZP,HR -currency btc,usd -donate 10
#.\MultiPoolMiner.ps1 -wallet 3BtgUnw3Rax59p8Fmk4VSgsH1BsYvJH1GP -username ollakolla -workername $env:AZ_BATCH_POOL_ID -interval 300 -Region $(GetPoolLocation) -ssl -type nvidia,cpu -algorithm cryptonight,ethash,equihash,groestl,yescrypt,neoscrypt -poolname MPH,NH,MPHC,ZP,HR -currency btc,usd -donate 10
#.\MultiPoolMiner.ps1 -wallet 3BtgUnw3Rax59p8Fmk4VSgsH1BsYvJH1GP -username ollakolla -workername $env:AZ_BATCH_POOL_ID -interval 120 -Region $(GetPoolLocation) -ssl -type cpu -algorithm Bitcore,Blakecoin,Blake2s,BlakeVanilla,C11,CryptoNight,Ethash,X11,Decred,Equihash,Groestl,HMQ1725,JHA,Keccak,Lbry,Lyra2RE2,Lyra2z,MyriadGroestl,NeoScrypt,Nist5,Pascal,Quark,Qubit,Scrypt,SHA256,Sia,Sib,Skunk,Skein,Timetravel,Tribus,BlakeVanilla,Veltor,X11,X11evo,X17,Yescrypt -poolname HR,MPH,MPHC,NH,ZP -currency btc,usd -donate 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment