Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Update SAFE_ROOT_DIR & SAFE_LOG_DIR before executing script
- # Assumes safe & sn_node are accessible and are part of your $PATH
- function set_env_vars
- {
- [System.Environment]::SetEnvironmentVariable('NODES','15')
- [System.Environment]::SetEnvironmentVariable('RUST_LOG','sn_node=info')
- [System.Environment]::SetEnvironmentVariable('SAFE_ROOT_DIR','/mnt/remoteceph/safe_node_vault')
- [System.Environment]::SetEnvironmentVariable('SAFE_LOG_DIR','/mnt/remoteceph/safe_node_json_logs')
- [System.Environment]::SetEnvironmentVariable('TESTNET_NAME','local')
- }
- function clean_up($nodes_count,$root_dir,$log_dir)
- {
- if (Test-Path "$HOME/.safe/network_contacts")
- {
- Remove-Item "$HOME/.safe/network_contacts" -Recurse -Force
- }
- Get-Process -Name sn_node -ErrorAction SilentlyContinue| Stop-Process -Force
- Get-Process -Name safe -ErrorAction SilentlyContinue | Stop-Process -Force
- for($i=1; $i -le $nodes_count; $i++)
- {
- if (test-path "$root_dir/node-$i")
- {
- Remove-Item "$root_dir/node-$i" -Recurse -Force
- }
- if (test-path "$log_dir/node-$i")
- {
- Remove-Item "$log_dir/node-$i" -Recurse -Force
- }
- }
- }
- function init_network($nodes_count,$root_dir,$log_dir)
- {
- #GENESIS NODE
- New-Item -Path "$root_dir/node-1" -ItemType Directory
- New-Item -Path "$log_dir/node-1" -ItemType Directory
- sn_node -vvv --local-addr 127.0.0.1:0 --first 127.0.0.1:0 --root-dir $root_dir/node-1 --log-dir $log_dir/node-1 --json-logs &
- Start-sleep -Seconds 1
- for($i=2; $i -le $nodes_count; $i++)
- {
- New-Item -Path "$root_dir/node-$i" -ItemType Directory
- New-Item -Path "$log_dir/node-$i" -ItemType Directory
- sn_node -vvv --local-addr 127.0.0.1:0 --network-contacts-file $root_dir/node-1/section_tree --root-dir $config_dir/node-$i --log-dir $log_dir/node-$i --json-logs &
- Start-Sleep -Seconds 1
- }
- }
- function check_network($testnet_name,$root_dir)
- {
- safe networks
- safe networks add local $root_dir/node-1/section_tree
- safe networks switch $testnet_name
- safe networks
- safe networks check
- safe networks sections $testnet_name
- }
- set_env_vars
- clean_up $([System.Environment]::GetEnvironmentVariable('NODES')) $([System.Environment]::GetEnvironmentVariable('SAFE_ROOT_DIR')) $([System.Environment]::GetEnvironmentVariable('SAFE_LOG_DIR'))
- init_network $([System.Environment]::GetEnvironmentVariable('NODES')) $([System.Environment]::GetEnvironmentVariable('SAFE_ROOT_DIR')) $([System.Environment]::GetEnvironmentVariable('SAFE_LOG_DIR'))
- check_network $([System.Environment]::GetEnvironmentVariable('TESTNET_NAME')) $([System.Environment]::GetEnvironmentVariable('SAFE_ROOT_DIR'))
- $userInput = read-host "Enter to exit"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement