Yedek alıyor, uygulamayı durduruyor, dosyaları güncelliyor, uygulamayı açıyor.
WebApi
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")){
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit
}
Write-Host "Yedekleniyor...";
$from = "C:\WebSites\akifsite.com\_Current\*"
$to = "C:\WebSites\akifsite.com\_Old\"+(get-date).ToString('yyyy_MM_dd-hh_mm_ss')+"\"
New-Item -ItemType Directory -Force -Path $to
Copy-Item $from $to -recurse
Write-Host $to " klasorune yedeklendi";
$FileName = "C:\WebSites\akifsite.com\_New\Api\web.config"
if (Test-Path $FileName) {
Remove-Item $FileName
}
$FileName = "C:\WebSites\akifsite.com\_New\Api\appsettings.json"
if (Test-Path $FileName) {
Remove-Item $FileName
}
$siteName = "akifsite.com"; #poolState name aynı diye bunu kullanıyorum, farklı olsa poolName eklemek lazım - akif 30.09.2020
$poolState="";
$siteState ="";
$currentRetry = 0;
Write-Host $siteName " durduruluyor...";
do{
$siteState = (Get-WebsiteState $siteName).Value;
$poolState = (Get-WebAppPoolState $siteName).Value
if($siteState -eq "Started"){
STOP-Website $siteName;
}
if($poolState -eq "Started"){
Stop-WebAppPool -Name $siteName;
}
if($siteState -eq "Started" -or $poolState -eq "Started"){
Start-Sleep -s 5;
}
$currentRetry = $currentRetry + 1;
}while ($siteState -eq "Started" -and $currentRetry -le 20)
Write-Host $siteName " Durdu (" $currentRetry "sn)";
Write-Host "Uygulama guncelleniyor...";
$from = "C:\WebSites\akifsite.com\_New\Api\*"
$to = "C:\WebSites\akifsite.com\_Current\Api\"
New-Item -ItemType Directory -Force -Path $to
Copy-Item $from $to -recurse
Write-Host "Uygulama guncellendi";
Write-Host $siteName " calistiriliyor.."
if($siteState -eq "Stopped"){
Start-Website $siteName;
}
if($poolState -eq "Stopped"){
Start-WebAppPool -Name $siteName;
}
Write-Host $siteName " calisiyor"
Write-Host "Bitti"
Read-Host
UiUpdate
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")){
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit
}
Write-Host "Yedekleniyor...";
$from = "C:\WebSites\akifsite.com\_Current\*"
$to = "C:\WebSites\akifsite.com\_Old\"+(get-date).ToString('yyyy_MM_dd-hh_mm_ss')+"\"
New-Item -ItemType Directory -Force -Path $to
Copy-Item $from $to -recurse
Write-Host $to " klasorune yedeklendi";
$siteName = "akifsite.com"; #poolState name aynı diye bunu kullanıyorum, farklı olsa poolName eklemek lazım - akif 30.09.2020
$poolState="";
$siteState ="";
$currentRetry = 0;
Write-Host $siteName " durduruluyor...";
do{
$siteState = (Get-WebsiteState $siteName).Value;
$poolState = (Get-WebAppPoolState $siteName).Value
if($siteState -eq "Started"){
STOP-Website $siteName;
}
if($poolState -eq "Started"){
Stop-WebAppPool -Name $siteName;
}
if($siteState -eq "Started" -or $poolState -eq "Started"){
Start-Sleep -s 5;
}
$currentRetry = $currentRetry + 1;
}while ($siteState -eq "Started" -and $currentRetry -le 20)
Write-Host $siteName " Durdu (" $currentRetry "sn)";
Get-ChildItem "C:\WebSites\akifsite.com\_Current" -Exclude api,web.config | Remove-Item -Recurse; #api uygulamsı ve config ayarları olduğu için onları silmiyoruz
Write-Host "Uygulama guncelleniyor...";
$from = "C:\WebSites\akifsite.com\_New\ui\*"
$to = "C:\WebSites\akifsite.com\_Current\"
New-Item -ItemType Directory -Force -Path $to
Copy-Item $from $to -recurse
Write-Host "Uygulama guncellendi";
Write-Host $siteName " calistiriliyor.."
if($siteState -eq "Stopped"){
Start-Website $siteName;
}
if($poolState -eq "Stopped"){
Start-WebAppPool -Name $siteName;
}
Write-Host $siteName " calisiyor"
Write-Host "Bitti"
Read-Host
Hiç yorum yok:
Yorum Gönder