Skip to content

Commit

Permalink
windows update test version
Browse files Browse the repository at this point in the history
  • Loading branch information
MaynardMiner committed Dec 17, 2018
1 parent 7e99f03 commit 41ac91a
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 4 deletions.
Binary file removed HiveReset.lnk
Binary file not shown.
Binary file removed SWARM.lnk
Binary file not shown.
98 changes: 98 additions & 0 deletions build/powershell/get.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,18 @@ param(
)

Set-Location (Split-Path (Split-Path (Split-Path $script:MyInvocation.MyCommand.Path)))
$dir = Split-Path (Split-Path (Split-Path $script:MyInvocation.MyCommand.Path))

$Get = @()

. .\build\powershell\hashrates.ps1
. .\build\powershell\octune.ps1
. .\build\powershell\commandweb.ps1
. .\build\powershell\powerup.ps1
. .\build\powershell\statcommand.ps1
. .\build\powershell\response.ps1
. .\build\powershell\hiveoc.ps1

Switch($argument1)
{
"help"
Expand Down Expand Up @@ -179,6 +189,17 @@ wallets
OPTIONS: none
update
Windows version will perform a remote update. HiveOS version
will list SWARM's current version.
USES:
get wallet
OPTIONS: none
to see all available SWARM commands, go to:
https://github.com/MaynardMiner/SWARM/wiki/HiveOS-management
Expand Down Expand Up @@ -239,6 +260,57 @@ Get-BenchTable | Out-File ".\build\txt\get.txt"
}
else{$Get = "No Stats Found"}
}

"update"
{
$os = Get-Content ".\build\txt\os.txt"
$version = Get-Content ".\build\txt\version.txt"
$versionnumber = $version -replace "SWARM.",""
$version1 = $versionnumber[4]
$version1 = $version1 | % {iex $_}
$version1 = $version1+1
$version2 = $versionnumber[2]
$version3 = $versionnumber[0]
if($version1 -eq 10)
{
$version1 = 0;
$version2 = $version2 | % {iex $_}
$version2 = $version2+1
}
if($version2 -eq 10)
{
$version2 = 0;
$version3 = $version3 | % {iex $_}
$version3 = $version3+1
}
$versionnumber = "$version3.$version2.$version1"

if($os -eq "windows")
{
$Failed = $false
$Get += "Operating System Is Windows: Updating via 'get' is possible"
$versionlink = "https://github.com/MaynardMiner/SWARM/releases/download/v$VersionNumber/SWARM.$VersionNumber.zip"
$Get += "Detected New Version Should Be $VersionNumber"
$Get += "Attempting To Download New Version at $Versionlink"
$Location = Split-Path $dir
$NewLocation = Join-Path (Split-Path $dir) "SWARM.$VersionNumber"
$FileName = "x64/SWARM.$VersionNumber.zip"
$URI = "https://github.com/MaynardMiner/SWARM/releases/download/v$versionNumber/SWARM.$VersionNumber.zip"
[System.Net.ServicePointManager]::SecurityProtocol = ("Tls12","Tls11","Tls")
try{Invoke-WebRequest $URI -OutFile $FileName -UseBasicParsing -ErrorAction Stop}catch{$Failed = $true; $Get += "Failed To Contact Github For Download! Must Do So Manually"}
if($Failed -eq $false)
{
Start-Process "7z" "x `"$([IO.Path]::GetFullPath($FileName))`" -o`"$([IO.Path]::GetFullPath($Location))`" -y -spe" -Wait
$Get += "Downloaded and extracted SWARM successfully"
$Trigger = "update"
Copy-Item ".\SWARM.bat" -Destination $NewLocation -Force
Copy-Item ".\config\parameters\newarguments.json" -Destination "$NewLocation\config\parameters\" -Force
}
else{$Get += "Did not perform update."}
}
else{$Get += Get-Content ".\build\txt\version.txt"}
}

"wallets"
{
. .\build\powershell\statcommand.ps1
Expand Down Expand Up @@ -389,4 +461,30 @@ if($get -ne $null)
{
$Get
$Get | Out-File ".\build\txt\get.txt"
Start-Sleep -S .5
}

if($Trigger -ne $null)
{
if($Trigger -eq "update")
{
$ID = Get-Content ".\build\pid\miner_pid.txt"
Stop-Process -Id $ID
Start-Sleep -S 5
$method = "message"
$messagetype = "info"
$data = "get update"
$getpayload = Get-Content ".\build\txt\get.txt"
$line = @()
$getpayload | foreach {$line += "$_`n"}
$payload = $line
$DoResponse = Add-HiveResponse -Method $method -messagetype $messagetype -Data $data -HiveID $HiveID -HivePassword $HivePassword -CommandID $command.result.id -Payload $payload
$DoResponse = $DoResponse | ConvertTo-JSon -Depth 1
$SendResponse = Invoke-RestMethod "$HiveMirror/worker/api" -TimeoutSec 15 -Method POST -Body $DoResponse -ContentType 'application/json'
Start-Process "$NewLocation\SWARM.bat"
Start-Sleep -S 2
$ID = ".\build\pid\background_pid.txt"
$BackGroundID = Get-Process -id (Get-Content "$ID" -ErrorAction SilentlyContinue) -ErrorAction SilentlyContinue
Stop-Process $BackGroundID | Out-Null
}
}
16 changes: 13 additions & 3 deletions build/powershell/remoteupdate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
function start-update {
param (
[Parameter(Mandatory=$true)]
[String]$Update
[String]$Update,
[Parameter(Mandatory=$true)]
[String]$Dir,
[Parameter(Mandatory=$true)]
[String]$Platforms
)

if($Update -eq "Yes")
$Location = split-Path $Dir
$StartUpdate = $True
if($Platforms -eq "linux" -and $Update -eq "No"){$StartUpdate = $false}

if($StartUpdate -eq $true)
{
$PreviousVersions = @()
$PreviousVersions += "SWARM.1.7.6"
Expand All @@ -26,11 +34,13 @@ $PreviousVersions += "SWARM.1.7.7"
$PreviousVersions += "SWARM.1.7.8"
$PreviousVersions += "SWARM.1.7.9"
$PreviousVersions += "SWARM.1.8.0"
$PreviousVersions += "SWARM.1.8.1"

Write-Host "User Specfied Updates: Searching For Previous Version" -ForegroundColor Yellow
Write-Host "Check $Location For any Previous Versions"

$PreviousVersions | foreach {
$PreviousPath = Join-Path "/hive/miners/custom" "$_"
$PreviousPath = Join-Path "$Location" "$_"
if(Test-Path $PreviousPath)
{
Write-Host "Detected Previous Version"
Expand Down
4 changes: 3 additions & 1 deletion swarm.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ if(-Not (Test-Path ".\wallet\keys")){new-item -Path ".\wallet" -Name "keys" -Ite
$Wallets | %{ $_ | ConvertTo-Json | Set-Content ".\wallet\keys\$($_.Wallet).txt"}

$Version = Get-Content ".\h-manifest.conf" | ConvertFrom-StringData
$Version.CUSTOM_NAME | Set-Content ".\build\txt\version.txt"
$Version = $Version.CUSTOM_VERSION

if($HiveOS -eq "Yes" -and $Platform -eq "linux"){Start-Process ".\build\bash\screentitle.sh" -Wait}
Expand Down Expand Up @@ -414,7 +415,6 @@ if($Platform -eq "linux"){start-killscript}
if($platform -eq "linux")
{
$cuda | Out-file ".\build\txt\cuda.txt" -Force
start-update -Update $update
if($HiveOS -eq "Yes"){
Write-Host "Getting Data"
Get-Data -CmdDir $dir
Expand All @@ -425,6 +425,8 @@ start-update -Update $update
}
}

start-update -Update $update -Dir $dir -Platforms $Platform

Write-Host "HiveOS = $HiveOS"
#Startings Settings:
$BenchmarkMode = "No"
Expand Down

0 comments on commit 41ac91a

Please sign in to comment.