Skip to content

Commit

Permalink
Merge pull request #6 from inkadnb/windows_install_scripts
Browse files Browse the repository at this point in the history
Windows install scripts
  • Loading branch information
0xn3bs committed Jan 1, 2021
2 parents d5cd893 + b1d4f76 commit 253600e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cypnode/Runners/cypnode.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
pushd %USERPROFILE%\.cypher\dist & dotnet TGMNode.dll %* & popd
3 changes: 3 additions & 0 deletions cypnode/cypnode.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
<None Include="**/*" />
</ItemGroup>
<ItemGroup>
<None Update="Runners\cypnode.cmd">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Runners\cypnode.sh">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
40 changes: 40 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Create a temporary folder to download to.
$tempFolder = Join-Path $env:TEMP "cypher"
New-Item $tempFolder -ItemType Directory -Force

# Get the latest release
$latestRelease = Invoke-WebRequest "https://api.github.com/repos/cypher-network/cypher/releases/latest" |
ConvertFrom-Json |
Select-Object tag_name
$tag_name = $latestRelease.tag_name

# Download the zip
Write-Host "Downloading latest version ($tag_name)"
$client = New-Object "System.Net.WebClient"
$url = "https://github.com/cypher-network/cypher/releases/download/$tag_name/cypher.$tag_name.zip"
$zipFile = Join-Path $tempFolder "cypher.zip"
$client.DownloadFile($url,$zipFile)

$installationFolder = Join-Path $env:USERPROFILE ".cypher"
Microsoft.PowerShell.Archive\Expand-Archive $zipFile -DestinationPath $installationFolder -Force
Remove-Item $tempFolder -Recurse -Force

$binFolder = Join-Path $installationFolder "bin"
$runner = Join-Path $installationFolder "dist\Runners"
$runner = Join-Path $runner "cypnode.cmd"

If (!(Test-Path $binFolder))
{
New-Item -Path $binFolder -ItemType "directory"
}
Copy-Item $runner -Destination $binFolder -Force

$path = [System.Environment]::GetEnvironmentVariable("path", [System.EnvironmentVariableTarget]::User);
$paths = $path.Split(";") -inotlike $binFolder
# Add the bin folder to the path
$paths += $binFolder
# Create the new path string
$path = $paths -join ";"

[System.Environment]::SetEnvironmentVariable("path", $path, [System.EnvironmentVariableTarget]::User)
Write-Host "cypher was installed successfully!"

0 comments on commit 253600e

Please sign in to comment.