-
Notifications
You must be signed in to change notification settings - Fork 0
/
remove-nodes.ps1
executable file
·43 lines (35 loc) · 982 Bytes
/
remove-nodes.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/pwsh
Param(
[int]$NumberOfNodes = 1,
[switch]$Force
)
# Import modules
$requiredModules = "ErdCore","ErdIO","ErdUtils","ErdGit","ErdNode","ErdSystem"
foreach($requiredModule in $requiredModules){
Import-Module "$PSScriptRoot/.modules/$requiredModule/$requiredModule.psd1" -Force
}
#
# Start section
#
Clear-Host
Write-Section "Removing Elrond Node/s"
Invoke-Command -ScriptBlock {sudo ls} | Out-Null
$nodesConfig = Get-ElrondNodesConfig
if($nodesConfig.Count -eq 0){
Write-WarningResult "There isn't any node deployed on current system. Aborting..."
exit
}
if($NumberOfNodes -gt $nodesConfig.Count){
$NumberOfNodes = $nodesConfig.Count
}
if(!$Force.IsPresent){
Get-ContinueApproval -Message "$NumberOfNodes node will be removed! Are you sure you want to remove the nodes?" -Warn
}
for($i=0; $i -lt $NumberOfNodes; $i++){
Write-Host ""
Remove-ElrondNode -Force:$Force
}
#
# End section
#
Write-Section "Finished removing nodes"