bozza script installazione
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
#-------------------------------------------------------------------
|
||||
# Egalware 2021.05.25
|
||||
#
|
||||
# AppDeploy -AppPool MP.STATS -SourceDir c:\Steamware\installers\MP.STATS -ZipFile MP.STATS.zip -DestDir c:\inetpub\wwwroot\MP\STATS
|
||||
#
|
||||
# Powershell script per deploy applicazione Blazor / dotnet core
|
||||
#
|
||||
# requisito: modulo powershell x 7zip:
|
||||
# Set-ExecutionPolicy Bypass -Scope CurrentUser -Force
|
||||
# Install-Module -Name 7Zip4Powershell
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# step 0: lettura variabili
|
||||
param (
|
||||
[Parameter(Mandatory=$true)]
|
||||
[ValidateNotNull()]
|
||||
[string]$AppPool = "MP.STATS",
|
||||
|
||||
[Parameter(Mandatory=$true)]
|
||||
[ValidateNotNull()]
|
||||
[string]$SourceDir,
|
||||
|
||||
[Parameter(Mandatory=$true)]
|
||||
[ValidateNotNull()]
|
||||
[string]$ZipFile,
|
||||
|
||||
[Parameter(Mandatory=$true)]
|
||||
[ValidateNotNull()]
|
||||
[string]$DestDir
|
||||
)
|
||||
|
||||
# recupera timestamp x logging
|
||||
function Get-TimeStamp
|
||||
{
|
||||
return "[{0:MM/dd/yy} {0:HH:mm:ss}]" -f (Get-Date)
|
||||
}
|
||||
# registra log!
|
||||
function DoLog($txt2log)
|
||||
{
|
||||
Write-Output "$(Get-TimeStamp) $txt2log" | Out-File $filelog -Append
|
||||
}
|
||||
# esegue e registra log
|
||||
function ExecuteLog($txt2log)
|
||||
{
|
||||
Write-Output "-------------------------------------------------------------------------------------------------------------------------------------------------" | Out-File -FilePath "$filelog" -Append
|
||||
Write-Output "$(Get-TimeStamp) $txt2log" | Out-File -FilePath "$filelog" -Append
|
||||
Invoke-Expression "$txt2log 2>&1 | Out-File -FilePath $filelog -Append"
|
||||
if( $LASTEXITCODE -ne 0)
|
||||
{
|
||||
Write-Host "Error during cmmand: $txt2log" -ForegroundColor Red ;
|
||||
Write-Host "Exit...." -ForegroundColor Red ;
|
||||
Set-Location $PSScriptRoot
|
||||
exit
|
||||
}
|
||||
}
|
||||
# conf x logging
|
||||
$filelog = "c:\Steamware\tmp\Script.log"
|
||||
$utilDir = "c:\Steamware\tmp\"
|
||||
|
||||
Write-Output "-------------------------------- START script --------------------------------" | Out-File $filelog
|
||||
$StopWatch = New-Object System.Diagnostics.Stopwatch
|
||||
$StopWatch.Start()
|
||||
|
||||
|
||||
# step 1 : stop del pool applicazioni IIS
|
||||
Write-Host "Stop AppPool"
|
||||
ExecuteLog "Stop-WebAppPool -Name '$AppPool'"
|
||||
|
||||
# step 2 : unzip
|
||||
ExecuteLog "Expand-7Zip -ArchiveFileName '$SourceDir\$ZipFile' -TargetPath '$utilDir'"
|
||||
|
||||
# step 3 : replica applicazione
|
||||
Write-Host "START copy step"
|
||||
ExecuteLog "robocopy '$utilDir\publish\net5.0\' '$DestDir' /MIR /Z /LOG:C:\tmp\ViewMirror.log /XF logs/*.txt logs/*.log"
|
||||
Write-Host "END copy step"
|
||||
|
||||
# step 4 : riavvio pool
|
||||
Write-Host "Start AppPool"
|
||||
ExecuteLog "Start-WebAppPool -Name '$AppPool'"
|
||||
Reference in New Issue
Block a user