mirror of
https://github.com/logos-storage/logos-storage-testnet-starter.git
synced 2026-01-28 10:13:08 +00:00
Set auto IP on Windows (#31)
* Rename URI to URL * Be more explicit in requesting remote ETH keys for Windows * Handle NETWORK variable for Windows scripts with defaults to testnet * Set Public IP and Bootstrap on Windows based on the NETWORK variable, defaults to testnet
This commit is contained in:
parent
e2d94a2bb9
commit
123c6861eb
@ -4,11 +4,10 @@ set -e
|
||||
# Variables
|
||||
key_file="eth.key"
|
||||
address_file="eth.address"
|
||||
|
||||
uri=https://key.codex.storage
|
||||
url=https://key.codex.storage
|
||||
|
||||
# Generate
|
||||
echo "Generating private key from remote <${uri}>..."
|
||||
echo "Generating private key from remote <${url}>..."
|
||||
|
||||
response=$(curl -s ${uri})
|
||||
awk -F ': ' '/private/ {print $2}' <<<"${response}" >"${key_file}"
|
||||
|
||||
@ -4,9 +4,10 @@ setlocal enabledelayedexpansion
|
||||
:: Variables
|
||||
set key_file="%cd%\eth.key"
|
||||
set address_file="%cd%\eth.address"
|
||||
set url="https://key.codex.storage/json"
|
||||
|
||||
:: Generate
|
||||
echo Generating private key...
|
||||
echo "Generating private key from remote <%url%>..."
|
||||
|
||||
:: Use PowerShell to make the API call and process the response
|
||||
powershell -Command "& { $response = Invoke-RestMethod -Uri 'https://key.codex.storage/json'; $privateKey = $response.private; $address = $response.address; $privateKey | Out-File -Encoding ASCII -FilePath '%key_file%'; $address | Out-File -Encoding ASCII -FilePath '%address_file%'; Write-Host ' * your private key has been saved to %key_file%'; Write-Host ' * your address has been saved to %address_file%'; Write-Host (' * your ethereum address is ' + $address); }"
|
||||
|
||||
@ -7,14 +7,22 @@ call utils.bat
|
||||
if "%1" neq "" (
|
||||
set "LOCALIP=%1"
|
||||
) else if not defined LOCALIP (
|
||||
call :get_ip LOCALIP
|
||||
if %NETWORK% == workshop (
|
||||
call :get_ip LOCALIP
|
||||
) else (
|
||||
call :get_ip_public LOCALIP
|
||||
)
|
||||
)
|
||||
echo LOCAL IP: %LOCALIP%
|
||||
|
||||
if not defined BOOTSPR (
|
||||
:: workshop
|
||||
:: set "BOOTSPR=spr:CiUIAhIhAnBsex_7L5xKJQpmAuOtubQEtKsgCOXE2vaJoTJXrprbEgIDARo8CicAJQgCEiECcGx7H_svnEolCmYC4625tAS0qyAI5cTa9omhMleumtsQnbm0tAYaCwoJBMCoWP2RAh-aKkcwRQIhANjwAV9DGFe4zcMUEHjuTsGWAPc7WB7uoSS86HATwouqAiA8dFhsALCSLsQbSOPF1j7NF643oEmPEJAwU9dIwjM6TA"
|
||||
set BOOTSPR="spr:CiUIAhIhAiJvIcA_ZwPZ9ugVKDbmqwhJZaig5zKyLiuaicRcCGqLEgIDARo8CicAJQgCEiECIm8hwD9nA9n26BUoNuarCEllqKDnMrIuK5qJxFwIaosQ3d6esAYaCwoJBJ_f8zKRAnU6KkYwRAIgM0MvWNJL296kJ9gWvfatfmVvT-A7O2s8Mxp8l9c8EW0CIC-h-H-jBVSgFjg3Eny2u33qF7BDnWFzo7fGfZ7_qc9P"
|
||||
if %NETWORK% == workshop (
|
||||
:: workshop
|
||||
set BOOTSPR="spr:CiUIAhIhAnBsex_7L5xKJQpmAuOtubQEtKsgCOXE2vaJoTJXrprbEgIDARo8CicAJQgCEiECcGx7H_svnEolCmYC4625tAS0qyAI5cTa9omhMleumtsQnbm0tAYaCwoJBMCoWP2RAh-aKkcwRQIhANjwAV9DGFe4zcMUEHjuTsGWAPc7WB7uoSS86HATwouqAiA8dFhsALCSLsQbSOPF1j7NF643oEmPEJAwU9dIwjM6TA"
|
||||
) else if %NETWORK% == testnet (
|
||||
:: testnet
|
||||
set BOOTSPR="spr:CiUIAhIhAiJvIcA_ZwPZ9ugVKDbmqwhJZaig5zKyLiuaicRcCGqLEgIDARo8CicAJQgCEiECIm8hwD9nA9n26BUoNuarCEllqKDnMrIuK5qJxFwIaosQ3d6esAYaCwoJBJ_f8zKRAnU6KkYwRAIgM0MvWNJL296kJ9gWvfatfmVvT-A7O2s8Mxp8l9c8EW0CIC-h-H-jBVSgFjg3Eny2u33qF7BDnWFzo7fGfZ7_qc9P"
|
||||
)
|
||||
)
|
||||
|
||||
if not exist eth.key (
|
||||
@ -69,6 +77,7 @@ exit /b 0
|
||||
set "%1=%arch_result%"
|
||||
exit /b
|
||||
|
||||
:: Function to get IP
|
||||
:get_ip
|
||||
for /f "tokens=2 delims=:" %%a in ('ipconfig ^| findstr /c:"IPv4 Address"') do (
|
||||
set "%1=%%a"
|
||||
@ -77,3 +86,8 @@ exit /b
|
||||
)
|
||||
:break
|
||||
exit /b
|
||||
|
||||
:: Function to get Public IP using ip lookup service
|
||||
:get_ip_public
|
||||
for /f "tokens=1" %%a in ('curl -m 5 -s https://ip.codex.storage') do set "%1=%%a"
|
||||
exit /b
|
||||
|
||||
@ -1,9 +1,14 @@
|
||||
@echo off
|
||||
|
||||
:: Variables
|
||||
if not defined NETWORK set NETWORK=testnet
|
||||
|
||||
:: Function to detect OS
|
||||
:get_os
|
||||
echo windows
|
||||
exit /b
|
||||
|
||||
:: Function to detect CPU architecture
|
||||
:get_arch
|
||||
set "arch_result=unknown"
|
||||
for /f "tokens=2 delims=:" %%a in ('systeminfo ^| find "System Type"') do (
|
||||
@ -19,6 +24,7 @@ exit /b
|
||||
set "%1=%arch_result%"
|
||||
exit /b
|
||||
|
||||
:: Function to get IP
|
||||
:get_ip
|
||||
for /f "tokens=2 delims=:" %%a in ('ipconfig ^| findstr /c:"IPv4 Address"') do (
|
||||
set "%1=%%a"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user