Added script for PROD deploy
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
# Script di installazione in macchina zip dell'ultima release di ThermoActive
|
||||
|
||||
# Check parameters
|
||||
Param (
|
||||
[Parameter(Mandatory=$True)]
|
||||
[ValidateNotNull()]
|
||||
$zipPath
|
||||
)
|
||||
|
||||
# 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 c:\tmp\Script.log -Append
|
||||
}
|
||||
|
||||
function checkFolder($dirPath)
|
||||
{
|
||||
if(!(Test-Path -path $dirPath))
|
||||
{
|
||||
New-Item -ItemType directory -Path $dirPath
|
||||
DoLog("Folder path has been created successfully at $dirPath")
|
||||
}
|
||||
}
|
||||
|
||||
function mirrorData($dirFrom, $dirTo, $LogPath, $XDirs)
|
||||
{
|
||||
robocopy $dirFrom $dirTo /MIR /Z /LOG:$LogPath /XD $XDirs
|
||||
}
|
||||
|
||||
Write-Output "-------------------------------- START script --------------------------------" | Out-File c:\tmp\Script.log
|
||||
$StopWatch = New-Object System.Diagnostics.Stopwatch
|
||||
$StopWatch.Start()
|
||||
|
||||
# directory di base
|
||||
$BaseDir = "C:\CMS\ThermoActive\"
|
||||
$ArchiveDir = "$BaseDir\Archive\"
|
||||
$BackupDir = "$BaseDir\Backup\"
|
||||
$ConfDir = "$BaseDir\Conf\"
|
||||
$LogDir = "$BaseDir\Logs\"
|
||||
$UnzipDir = "$BaseDir\Unzip\"
|
||||
$ProgramDir = "$BaseDir\ThermoActive\"
|
||||
|
||||
$adesso = Get-Date -Format "yyyy-MM-dd_HH.mm"
|
||||
|
||||
# mi sposto in Dir di base
|
||||
cd $BaseDir
|
||||
|
||||
# creo se non ci fosse dir varie
|
||||
checkf($BaseDir)
|
||||
checkf($ArchiveDir)
|
||||
checkf($BackupDir)
|
||||
checkf($ConfDir)
|
||||
checkf($LogDir)
|
||||
checkf($ProgramDir)
|
||||
|
||||
# Salvo CONF varie
|
||||
mirrorData($BaseDir+"\TMP\", $BackupDir+"\TMP\", $LogDir+"Tmp.1.log","")
|
||||
mirrorData($ProgramDir+"\Config\", $BackupDir+"\Config\", $LogDir+"Config.1.log", "")
|
||||
mirrorData($ProgramDir+"\Dict\", $BackupDir+"\Dict\", $LogDir+"Dict.1.log","")
|
||||
mirrorData($ProgramDir+"\Recipes\", $BackupDir+"\Dict\", $LogDir+"Recipes.1.log", "")
|
||||
|
||||
# Move versione attuale
|
||||
Move-Item -Path $ProgramDir -Destination $BackupDir+"ThermoActive\$adesso"
|
||||
|
||||
# Faccio unzip NUOVA versione
|
||||
Expand-Archive -Path $zipPath -DestinationPath $UnzipDir
|
||||
|
||||
# copio da ZIP a program
|
||||
mirrorData($UnzipDir, $ProgramDir, $LogDir+"Newversion.log","Config Dict Recipes")
|
||||
|
||||
# Ripristino CONF
|
||||
mirrorData($BackupDir+"\TMP\", $BaseDir+"\TMP\", $LogDir+"Tmp.2.log","")
|
||||
mirrorData($BackupDir+"\Config\", $ProgramDir+"\Config\", $LogDir+"Config.2.log", "")
|
||||
mirrorData($BackupDir+"\Dict\", $ProgramDir+"\Dict\", $LogDir+"Dict.2.log","")
|
||||
mirrorData($BackupDir+"\Recipes\", $ProgramDir+"\Dict\", $LogDir+"Recipes.2.log", "")
|
||||
|
||||
$StopWatch.Stop()
|
||||
$StopWatch.Elapsed | Out-File c:\tmp\Script.log -Append
|
||||
DoLog("-------------------------------- END script --------------------------------")
|
||||
@@ -11,7 +11,8 @@ Param (
|
||||
$npmInstall,
|
||||
[Parameter(Mandatory=$True)]
|
||||
[ValidateNotNull()]
|
||||
$npmBuild,[Parameter(Mandatory=$True)]
|
||||
$npmBuild,
|
||||
[Parameter(Mandatory=$True)]
|
||||
[ValidateNotNull()]
|
||||
$version
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user