use Windows convention for batch file newline

This commit is contained in:
gmega 2024-10-04 20:00:02 -03:00
parent 9161f77968
commit 1616dbe3ca
5 changed files with 290 additions and 290 deletions

View File

@ -1,72 +1,72 @@
@echo off
setlocal enabledelayedexpansion
call utils.bat
:: Set variables
set "OS=windows"
call :get_arch ARCH
set "ARCHIVE_EXT=.zip"
set "EXE_EXT=.exe"
set "VERSION=v0.1.4"
set "BASE_URL=https://github.com/codex-storage/nim-codex/releases/download/%VERSION%"
set "EXTRACT_DIR=.\"
set "BINARY_NAMES=codex"
:: Download, verify, and extract each binary
for %%B in (%BINARY_NAMES%) do (
set "FILE_NAME=%%B-%VERSION%-%OS%-%ARCH%-libs%ARCHIVE_EXT%"
set "DOWNLOAD_URL=%BASE_URL%/!FILE_NAME!"
set "CHECKSUM_URL=%BASE_URL%/!FILE_NAME!.sha256"
echo Downloading !FILE_NAME!...
powershell -Command "& {Invoke-WebRequest -Uri '!DOWNLOAD_URL!' -OutFile '!FILE_NAME!'}"
if errorlevel 1 (
echo Download failed for !FILE_NAME!
exit /b 1
)
echo Downloading SHA256 checksum for !FILE_NAME!...
powershell -Command "& {Invoke-WebRequest -Uri '!CHECKSUM_URL!' -OutFile '!FILE_NAME!.sha256'}"
if errorlevel 1 (
echo Checksum download failed for !FILE_NAME!
exit /b 1
)
echo Verifying checksum for !FILE_NAME!...
for /f "tokens=1" %%a in (!FILE_NAME!.sha256) do set "EXPECTED_SHA256=%%a"
for /f "tokens=* usebackq" %%a in (`powershell -Command "& {Get-FileHash '!FILE_NAME!' -Algorithm SHA256 | Select-Object -ExpandProperty Hash}"`) do set "ACTUAL_SHA256=%%a"
if /I not "!ACTUAL_SHA256!"=="!EXPECTED_SHA256!" (
echo Checksum verification failed for !FILE_NAME!.
echo Expected: !EXPECTED_SHA256!
echo Got: !ACTUAL_SHA256!
exit /b 1
)
echo Checksum verification successful for !FILE_NAME!.
echo Extracting !FILE_NAME!...
powershell -Command "& {Expand-Archive -Path '!FILE_NAME!' -DestinationPath '!EXTRACT_DIR!' -Force}"
if errorlevel 1 (
echo Extraction failed for !FILE_NAME!
exit /b 1
)
:: Cleanup
del !FILE_NAME!
del !FILE_NAME!.sha256
)
echo Setup completed successfully!
exit /b 0
:get_arch
set "arch_result=unknown"
for /f "tokens=2 delims=:" %%a in ('systeminfo ^| find "System Type"') do (
echo %%a | find "x64" > nul
if not errorlevel 1 set "arch_result=amd64"
echo %%a | find "ARM" > nul
if not errorlevel 1 set "arch_result=arm64"
)
set "%1=%arch_result%"
exit /b
@echo off
setlocal enabledelayedexpansion
call utils.bat
:: Set variables
set "OS=windows"
call :get_arch ARCH
set "ARCHIVE_EXT=.zip"
set "EXE_EXT=.exe"
set "VERSION=v0.1.4"
set "BASE_URL=https://github.com/codex-storage/nim-codex/releases/download/%VERSION%"
set "EXTRACT_DIR=.\"
set "BINARY_NAMES=codex"
:: Download, verify, and extract each binary
for %%B in (%BINARY_NAMES%) do (
set "FILE_NAME=%%B-%VERSION%-%OS%-%ARCH%-libs%ARCHIVE_EXT%"
set "DOWNLOAD_URL=%BASE_URL%/!FILE_NAME!"
set "CHECKSUM_URL=%BASE_URL%/!FILE_NAME!.sha256"
echo Downloading !FILE_NAME!...
powershell -Command "& {Invoke-WebRequest -Uri '!DOWNLOAD_URL!' -OutFile '!FILE_NAME!'}"
if errorlevel 1 (
echo Download failed for !FILE_NAME!
exit /b 1
)
echo Downloading SHA256 checksum for !FILE_NAME!...
powershell -Command "& {Invoke-WebRequest -Uri '!CHECKSUM_URL!' -OutFile '!FILE_NAME!.sha256'}"
if errorlevel 1 (
echo Checksum download failed for !FILE_NAME!
exit /b 1
)
echo Verifying checksum for !FILE_NAME!...
for /f "tokens=1" %%a in (!FILE_NAME!.sha256) do set "EXPECTED_SHA256=%%a"
for /f "tokens=* usebackq" %%a in (`powershell -Command "& {Get-FileHash '!FILE_NAME!' -Algorithm SHA256 | Select-Object -ExpandProperty Hash}"`) do set "ACTUAL_SHA256=%%a"
if /I not "!ACTUAL_SHA256!"=="!EXPECTED_SHA256!" (
echo Checksum verification failed for !FILE_NAME!.
echo Expected: !EXPECTED_SHA256!
echo Got: !ACTUAL_SHA256!
exit /b 1
)
echo Checksum verification successful for !FILE_NAME!.
echo Extracting !FILE_NAME!...
powershell -Command "& {Expand-Archive -Path '!FILE_NAME!' -DestinationPath '!EXTRACT_DIR!' -Force}"
if errorlevel 1 (
echo Extraction failed for !FILE_NAME!
exit /b 1
)
:: Cleanup
del !FILE_NAME!
del !FILE_NAME!.sha256
)
echo Setup completed successfully!
exit /b 0
:get_arch
set "arch_result=unknown"
for /f "tokens=2 delims=:" %%a in ('systeminfo ^| find "System Type"') do (
echo %%a | find "x64" > nul
if not errorlevel 1 set "arch_result=amd64"
echo %%a | find "ARM" > nul
if not errorlevel 1 set "arch_result=arm64"
)
set "%1=%arch_result%"
exit /b

View File

@ -1,71 +1,71 @@
@echo off
setlocal enabledelayedexpansion
call utils.bat
:: Set variables
set "OS=windows"
call :get_arch ARCH
set "ARCHIVE_EXT=.zip"
set "EXE_EXT=.exe"
set "VERSION=v0.1.4"
set "BASE_URL=http://192.168.88.253:8080"
set "EXTRACT_DIR=.\"
set "BINARY_NAMES=codex"
:: Download, verify, and extract each binary
for %%B in (%BINARY_NAMES%) do (
set "FILE_NAME=%%B-%VERSION%-%OS%-%ARCH%%ARCHIVE_EXT%"
set "DOWNLOAD_URL=%BASE_URL%/!FILE_NAME!"
set "CHECKSUM_URL=%BASE_URL%/!FILE_NAME!.sha256"
echo Downloading !FILE_NAME!...
powershell -Command "& {Invoke-WebRequest -Uri '!DOWNLOAD_URL!' -OutFile '!FILE_NAME!'}"
if errorlevel 1 (
echo Download failed for !FILE_NAME!
echo Try download-online.bat instead
exit /b 1
)
echo Downloading SHA256 checksum for !FILE_NAME!...
powershell -Command "& {Invoke-WebRequest -Uri '!CHECKSUM_URL!' -OutFile '!FILE_NAME!.sha256'}"
if errorlevel 1 (
echo Checksum download failed for !FILE_NAME!
echo Try download-online.bat instead
exit /b 1
)
echo Verifying checksum for !FILE_NAME!...
for /f "tokens=1" %%a in (!FILE_NAME!.sha256) do set "EXPECTED_SHA256=%%a"
for /f "tokens=* usebackq" %%a in (`powershell -Command "& {Get-FileHash '!FILE_NAME!' -Algorithm SHA256 | Select-Object -ExpandProperty Hash}"`) do set "ACTUAL_SHA256=%%a"
if /I not "!ACTUAL_SHA256!" == "!EXPECTED_SHA256!" (
echo Checksum verification failed for !FILE_NAME!. Expected: !EXPECTED_SHA256!, Got: !ACTUAL_SHA256!
exit /b 1
)
echo Extracting !FILE_NAME!...
powershell -Command "& {Expand-Archive -Path '!FILE_NAME!' -DestinationPath '!EXTRACT_DIR!' -Force}"
if errorlevel 1 (
echo Extraction failed for !FILE_NAME!
exit /b 1
)
:: Cleanup
del !FILE_NAME!
del !FILE_NAME!.sha256
)
echo Setup completed successfully!
exit /b 0
:get_arch
set "arch_result=unknown"
for /f "tokens=2 delims=:" %%a in ('systeminfo ^| find "System Type"') do (
echo %%a | find "x64" > nul
if not errorlevel 1 set "arch_result=amd64"
echo %%a | find "ARM" > nul
if not errorlevel 1 set "arch_result=arm64"
)
set "%1=%arch_result%"
exit /b
@echo off
setlocal enabledelayedexpansion
call utils.bat
:: Set variables
set "OS=windows"
call :get_arch ARCH
set "ARCHIVE_EXT=.zip"
set "EXE_EXT=.exe"
set "VERSION=v0.1.4"
set "BASE_URL=http://192.168.88.253:8080"
set "EXTRACT_DIR=.\"
set "BINARY_NAMES=codex"
:: Download, verify, and extract each binary
for %%B in (%BINARY_NAMES%) do (
set "FILE_NAME=%%B-%VERSION%-%OS%-%ARCH%%ARCHIVE_EXT%"
set "DOWNLOAD_URL=%BASE_URL%/!FILE_NAME!"
set "CHECKSUM_URL=%BASE_URL%/!FILE_NAME!.sha256"
echo Downloading !FILE_NAME!...
powershell -Command "& {Invoke-WebRequest -Uri '!DOWNLOAD_URL!' -OutFile '!FILE_NAME!'}"
if errorlevel 1 (
echo Download failed for !FILE_NAME!
echo Try download-online.bat instead
exit /b 1
)
echo Downloading SHA256 checksum for !FILE_NAME!...
powershell -Command "& {Invoke-WebRequest -Uri '!CHECKSUM_URL!' -OutFile '!FILE_NAME!.sha256'}"
if errorlevel 1 (
echo Checksum download failed for !FILE_NAME!
echo Try download-online.bat instead
exit /b 1
)
echo Verifying checksum for !FILE_NAME!...
for /f "tokens=1" %%a in (!FILE_NAME!.sha256) do set "EXPECTED_SHA256=%%a"
for /f "tokens=* usebackq" %%a in (`powershell -Command "& {Get-FileHash '!FILE_NAME!' -Algorithm SHA256 | Select-Object -ExpandProperty Hash}"`) do set "ACTUAL_SHA256=%%a"
if /I not "!ACTUAL_SHA256!" == "!EXPECTED_SHA256!" (
echo Checksum verification failed for !FILE_NAME!. Expected: !EXPECTED_SHA256!, Got: !ACTUAL_SHA256!
exit /b 1
)
echo Extracting !FILE_NAME!...
powershell -Command "& {Expand-Archive -Path '!FILE_NAME!' -DestinationPath '!EXTRACT_DIR!' -Force}"
if errorlevel 1 (
echo Extraction failed for !FILE_NAME!
exit /b 1
)
:: Cleanup
del !FILE_NAME!
del !FILE_NAME!.sha256
)
echo Setup completed successfully!
exit /b 0
:get_arch
set "arch_result=unknown"
for /f "tokens=2 delims=:" %%a in ('systeminfo ^| find "System Type"') do (
echo %%a | find "x64" > nul
if not errorlevel 1 set "arch_result=amd64"
echo %%a | find "ARM" > nul
if not errorlevel 1 set "arch_result=arm64"
)
set "%1=%arch_result%"
exit /b

View File

@ -1,19 +1,19 @@
@echo off
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 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); }"
:: Set file permissions to read-only for the current user
icacls %cd%\%key_file% /inheritance:r >nul 2>&1
icacls %cd%\%key_file% /grant:r %USERNAME%:F >nul 2>&1
exit /b 0
@echo off
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 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); }"
:: Set file permissions to read-only for the current user
icacls %cd%\%key_file% /inheritance:r >nul 2>&1
icacls %cd%\%key_file% /grant:r %USERNAME%:F >nul 2>&1
exit /b 0

View File

@ -1,93 +1,93 @@
@echo off
setlocal enabledelayedexpansion
call utils.bat
:: Check if LOCALIP is provided as an argument
if "%1" neq "" (
set "LOCALIP=%1"
) else if not defined LOCALIP (
if %NETWORK% == workshop (
call :get_ip LOCALIP
) else (
call :get_ip_public LOCALIP
)
)
echo LOCAL IP: %LOCALIP%
if not defined BOOTSPR (
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 (
echo eth.key does not exist. Please run generate.bat to create it.
exit /b 1
)
:: Set proper permissions for eth.key
echo Setting proper permissions for eth.key...
icacls eth.key /reset
icacls eth.key /inheritance:r
icacls eth.key /grant:r %USERNAME%:(R,F)
icacls eth.key /remove "Authenticated Users" "BUILTIN\Users"
icacls eth.key
if errorlevel 1 (
echo Failed to set permissions for eth.key. Please run this script as administrator.
exit /b 1
)
:: Set variables
set "VERSION=v0.1.4"
set "OS=windows"
call :get_arch ARCH
set "DATA_DIR=data_client"
if not exist %DATA_DIR% mkdir %DATA_DIR%
icacls %DATA_DIR% /inheritance:r
icacls %DATA_DIR% /grant:r %USERNAME%:(OI)(CI)F
codex-%VERSION%-%OS%-%ARCH%.exe ^
--data-dir=%DATA_DIR% ^
--storage-quota=11811160064 ^
--nat=%LOCALIP% ^
--api-port=8080 ^
--disc-port=8090 ^
--listen-addrs=/ip4/0.0.0.0/tcp/8070 ^
--bootstrap-node=%BOOTSPR% ^
persistence ^
--eth-private-key=eth.key ^
--eth-provider=https://rpc.testnet.codex.storage
exit /b 0
:get_arch
set "arch_result=unknown"
for /f "tokens=2 delims=:" %%a in ('systeminfo ^| find "System Type"') do (
echo %%a | find "x64" > nul
if not errorlevel 1 set "arch_result=amd64"
echo %%a | find "ARM" > nul
if not errorlevel 1 set "arch_result=arm64"
)
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"
set "%1=!%1: =!"
goto :break
)
: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
@echo off
setlocal enabledelayedexpansion
call utils.bat
:: Check if LOCALIP is provided as an argument
if "%1" neq "" (
set "LOCALIP=%1"
) else if not defined LOCALIP (
if %NETWORK% == workshop (
call :get_ip LOCALIP
) else (
call :get_ip_public LOCALIP
)
)
echo LOCAL IP: %LOCALIP%
if not defined BOOTSPR (
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 (
echo eth.key does not exist. Please run generate.bat to create it.
exit /b 1
)
:: Set proper permissions for eth.key
echo Setting proper permissions for eth.key...
icacls eth.key /reset
icacls eth.key /inheritance:r
icacls eth.key /grant:r %USERNAME%:(R,F)
icacls eth.key /remove "Authenticated Users" "BUILTIN\Users"
icacls eth.key
if errorlevel 1 (
echo Failed to set permissions for eth.key. Please run this script as administrator.
exit /b 1
)
:: Set variables
set "VERSION=v0.1.4"
set "OS=windows"
call :get_arch ARCH
set "DATA_DIR=data_client"
if not exist %DATA_DIR% mkdir %DATA_DIR%
icacls %DATA_DIR% /inheritance:r
icacls %DATA_DIR% /grant:r %USERNAME%:(OI)(CI)F
codex-%VERSION%-%OS%-%ARCH%.exe ^
--data-dir=%DATA_DIR% ^
--storage-quota=11811160064 ^
--nat=%LOCALIP% ^
--api-port=8080 ^
--disc-port=8090 ^
--listen-addrs=/ip4/0.0.0.0/tcp/8070 ^
--bootstrap-node=%BOOTSPR% ^
persistence ^
--eth-private-key=eth.key ^
--eth-provider=https://rpc.testnet.codex.storage
exit /b 0
:get_arch
set "arch_result=unknown"
for /f "tokens=2 delims=:" %%a in ('systeminfo ^| find "System Type"') do (
echo %%a | find "x64" > nul
if not errorlevel 1 set "arch_result=amd64"
echo %%a | find "ARM" > nul
if not errorlevel 1 set "arch_result=arm64"
)
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"
set "%1=!%1: =!"
goto :break
)
: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

View File

@ -1,35 +1,35 @@
@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 (
echo %%a | find "x64" > nul
if not errorlevel 1 set "arch_result=amd64"
echo %%a | find "ARM" > nul
if not errorlevel 1 set "arch_result=arm64"
)
if "%arch_result%"=="unknown" (
echo Unsupported architecture: %PROCESSOR_ARCHITECTURE%
exit /b 1
)
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"
set "%1=!%1: =!"
goto :break
)
:break
exit /b
@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 (
echo %%a | find "x64" > nul
if not errorlevel 1 set "arch_result=amd64"
echo %%a | find "ARM" > nul
if not errorlevel 1 set "arch_result=arm64"
)
if "%arch_result%"=="unknown" (
echo Unsupported architecture: %PROCESSOR_ARCHITECTURE%
exit /b 1
)
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"
set "%1=!%1: =!"
goto :break
)
:break
exit /b