build(controller): updates to not build the controller every time we update
this is incase we just want to test on a server then send this same build to all the other servers
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
param (
|
||||
[string]$App_Path = "C:\Users\matthes01\Documents\lst", # with this it makes it optional to pass a new parameter over.
|
||||
[string]$Server = "usmcd1vms036",
|
||||
[string]$Token = "test3",
|
||||
[string]$Remote_Path = "E$\LST"
|
||||
[string]$Remote_Path = "E$\LST",
|
||||
[string]$BuildController = "yes",
|
||||
[string]$PlantToUpdate = "all"
|
||||
)
|
||||
|
||||
# imports of the other functions
|
||||
@@ -11,7 +12,19 @@ param (
|
||||
. ".\update-controller-server"
|
||||
|
||||
# example string to pass over, you must be in the script dir when you run this script. or it will fail to find the linked scripts
|
||||
# .\update-controllers.ps1 -App_Path "C:\Users\matthes01\Documents\lst" -Server "usmcd1vms036" -Token "test3" -Remote_Path "E$\LST"
|
||||
|
||||
# If we do not pass plant to update over it will auto do all plants if we want a specific plant we need to do like below
|
||||
# .\update-controllers.ps1 -App_Path "C:\Users\matthes01\Documents\lst" -Token "test3" -BuildController no -PlantToUpdate "usmcd1vms006" -Remote_Path "E$\LST"
|
||||
|
||||
$Plants = @(
|
||||
@{ Server = "usmcd1vms036"; Token = "test3"; Remote_Path = "E$\LST"}
|
||||
@{ Server = "usmar1vms006"; Token = "usmar1" ; Remote_Path = "E$\LST"}
|
||||
@{ Server = "usbet1vms006"; Token = "usbet1"; Remote_Path = "E$\LST" }
|
||||
@{ Server = "usbow1vms006"; Token = "usbow1" ; Remote_Path = "E$\LST"}
|
||||
@{ Server = "usslc1vms006"; Token = "usslc1" ; Remote_Path = "E$\LST"}
|
||||
@{ Server = "usstp1vms006"; Token = "usstp1" ; Remote_Path = "D$\LST"}
|
||||
|
||||
)
|
||||
|
||||
$EnvFile = Join-Path $App_Path ".env"
|
||||
if (-Not (Test-Path $EnvFile)) {
|
||||
@@ -63,7 +76,7 @@ else {
|
||||
if (![string]::IsNullOrWhiteSpace($content)) {
|
||||
$BuildNumber = $content.Trim()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -77,35 +90,64 @@ if (-Not (Test-Path $ControlIncludes)) {
|
||||
|
||||
# last one to make sure we have is the build folder
|
||||
$BuildFolder = Join-Path $App_Path "controllerBuilds"
|
||||
|
||||
if (-Not (Test-Path $BuildFolder)) {
|
||||
write-host "Build folder missing creating it"
|
||||
New-Item -Path $BuildFolder -ItemType Directory | Out-Null
|
||||
}
|
||||
|
||||
# now we can create the zip
|
||||
Zip-Includes -IncludesFile $ControlIncludes -BuildNumber $BuildNumber -BuildFolder $BuildFolder -AppRoot $App_Path
|
||||
Start-Sleep -Seconds 3
|
||||
#------------------------------------------------------------------------------------
|
||||
|
||||
# Checking to make sure the server is up and online
|
||||
Write-Output "Checking if $($Token) is online to update."
|
||||
$pingResult = Test-Connection -ComputerName $Server -Count 2 -Quiet
|
||||
|
||||
if (-not $pingResult) {
|
||||
Write-Output "Server $($Server), token $($Token) is NOT reachable. Exiting script."
|
||||
exit 1 # Terminate the script with a non-zero exit code
|
||||
# only rebuild if we push yes over
|
||||
if ($BuildController -eq "yes") {
|
||||
# now we can create the zip
|
||||
Zip-Includes -IncludesFile $ControlIncludes -BuildNumber $BuildNumber -BuildFolder $BuildFolder -AppRoot $App_Path
|
||||
Start-Sleep -Seconds 3
|
||||
|
||||
}
|
||||
|
||||
Write-Output "Server $($Server), token $($Token) is online."
|
||||
|
||||
else {
|
||||
$BuildNumber = ([int]$BuildNumber - 1).ToString()
|
||||
}
|
||||
#------------------------------------------------------------------------------------
|
||||
|
||||
# now that the server is up lets update the server with the current build
|
||||
# do the update to the plant.
|
||||
Update-Server -ADM_USER $ADM_USER -ADM_PASS $ADM_PASS -AppRoot $App_Path -Destination $Remote_Path -Server $Server -Token $Token
|
||||
if ($PlantToUpdate -ne "all") {
|
||||
|
||||
# Checking to make sure the server is up and online
|
||||
Write-Output "Checking if $($Token) is online to update."
|
||||
$pingResult = Test-Connection -ComputerName $Server -Count 2 -Quiet
|
||||
|
||||
if (-not $pingResult) {
|
||||
Write-Output "Server $($PlantToUpdate), token $($Token) is NOT reachable. Exiting script."
|
||||
exit 1 # Terminate the script with a non-zero exit code
|
||||
}
|
||||
|
||||
Write-Output "Server $($PlantToUpdate), token $($Token) is online."
|
||||
|
||||
Update-Server -ADM_USER $ADM_USER -ADM_PASS $ADM_PASS -AppRoot $App_Path -Destination $Remote_Path -Server $PlantToUpdate -Token $Token -ControllerBuild $BuildController
|
||||
}
|
||||
else {
|
||||
foreach ($plant in $Plants) {
|
||||
|
||||
# Checking to make sure the server is up and online
|
||||
Write-Output "Checking if $($plant.Token) is online to update."
|
||||
$pingResult = Test-Connection -ComputerName $plant.Server -Count 2 -Quiet
|
||||
|
||||
if (-not $pingResult) {
|
||||
Write-Output "Server $($plant.Server), token $($plant.Token) is NOT reachable. Exiting script."
|
||||
exit 1 # Terminate the script with a non-zero exit code
|
||||
}
|
||||
|
||||
Write-Output "Server $($plant.Server), token $($plant.Token) is online."
|
||||
Write-Output "Plant to update: $($plant.Token)"
|
||||
Update-Server -ADM_USER $ADM_USER -ADM_PASS $ADM_PASS -AppRoot $App_Path -Destination $plant.Remote_Path -Server $plant.Server -Token $plant.Token
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# bump the build number
|
||||
$BuildNumber = Bump-Build -AppRoot $App_Path
|
||||
|
||||
if ($BuildController -eq "yes") {
|
||||
$BuildNumber = Bump-Build -AppRoot $App_Path
|
||||
}
|
||||
|
||||
# function to create the zip controller-1.zip
|
||||
|
||||
|
||||
Reference in New Issue
Block a user