Compare commits
84 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 674ce894b5 | |||
| 23137a0fed | |||
| dfe2f63787 | |||
| bc9d2048a9 | |||
| 8bcbb1fd04 | |||
| f11d2ac73a | |||
| 1e9b24a3df | |||
| 370530efd5 | |||
| afc5aa990d | |||
| bb5bc6d9fb | |||
| 9c1585a22a | |||
| 04de457e27 | |||
| 9b8a7c3b4e | |||
| c6de62fe2c | |||
| 5170c62ad4 | |||
| d4d8fdc80c | |||
| 9d479d67ae | |||
| 130e7b6107 | |||
| 6233c981ae | |||
| 9c59909908 | |||
| c428c02edc | |||
| bf3a6972fe | |||
| 35cc6630cd | |||
| a65dcfac89 | |||
| 400114d664 | |||
| f802a95b0d | |||
| 4e73d7c80f | |||
| ac4288c7d0 | |||
| cb7aa64781 | |||
| fc3ec2dc62 | |||
| 190f816973 | |||
| bf3500e3d4 | |||
| 7e08a303e1 | |||
| 99a83665dc | |||
| 200fb08bf9 | |||
| db43d8b2cd | |||
| 21243a3e25 | |||
| 40c588c93a | |||
| 657be39f4e | |||
| bcf20b5cff | |||
| 86280a6f63 | |||
| ad98d1faff | |||
| dada78a521 | |||
| b7c3b05833 | |||
| 6754ac45f2 | |||
| 48be4fe6df | |||
| b3c84c1c5f | |||
| 0c7820d65b | |||
| f0cbd66cd9 | |||
| 784cc17af4 | |||
| 6cb9452018 | |||
| 75a450b8b3 | |||
| 0c705a2ff0 | |||
| 56a1f349ab | |||
| 0073b9f36d | |||
| 0d3068339a | |||
| 3a7976779d | |||
| 0c864d3e31 | |||
| 23fee5e969 | |||
| f3e5d2165c | |||
| f654a54ace | |||
| 6dad8f36a8 | |||
| aae5a09a1c | |||
| 4ed53af2e3 | |||
| fd82959253 | |||
| 9b7f39b478 | |||
| dad0224875 | |||
| e6546d8230 | |||
| d19492c1ce | |||
| c7cea2a994 | |||
| 08e2a3b950 | |||
| e8b5f7b089 | |||
| dd2bea19ab | |||
| 4d417ba679 | |||
| b0657e9ad4 | |||
| ae07acbfdb | |||
| 7f87236961 | |||
| 236bcf195c | |||
| 4cf95d844d | |||
| 7ee6e03cbf | |||
| ab51312788 | |||
| a9c0f5fbd8 | |||
| 4a902ad6f8 | |||
| 5eacc77691 |
@@ -0,0 +1,68 @@
|
||||
######### FILE DI CONFIGURAZIONE PER SCRIPT API GIT #########
|
||||
|
||||
#### CONF LOG ####
|
||||
#cartella file di log
|
||||
$logFolder = "c:\Steamware\Logs\Gitlab\"
|
||||
#livello di log: 0=log sintetico, 1=log errori, 2=log full, 3=log ampolloso
|
||||
$logLevel = 3
|
||||
#output a terminale: 0=disattivo, 1=abilitato
|
||||
$terminalOutput = 1
|
||||
|
||||
#### CONF GITLAB ####
|
||||
#access token per autenticazione gitlab da profilo marco.locatelli@egalware.com con scadenza 31 dicembre 2024
|
||||
#$gitlabHead2024 = @{"PRIVATE-TOKEN" = "glpat-VjT_SAsBk3s-yWE1LDUF" }
|
||||
#access token per autenticazione gitlab da profilo marco.locatelli@egalware.com con scadenza 31 dicembre 2025
|
||||
#$tokenGitlab = "glpat-AGzz46yrxj7rTjzSVYCH"
|
||||
#access token per autenticazione gitlab da profilo marco.locatelli@egalware.com con scadenza 31 dicembre 2026
|
||||
$tokenGitlab = "glpat-CnHov-GaFjozv34MsnRx8m86MQp1OjgH.01.0w1or5g5w"
|
||||
$gitlabHead = @{"PRIVATE-TOKEN" = "$($tokenGitlab)" }
|
||||
#nome utente che effettua i mirror push
|
||||
$userName = "replica"
|
||||
|
||||
#### CONF gitea.steamware.net ####
|
||||
#destinazione mirror per gitea
|
||||
$giteaSteamw = "gitea.steamware.net"
|
||||
#nome utente gitea che effettua i mirror push
|
||||
$giteaSteamwUser = "replica"
|
||||
#autenticazione replica gitea
|
||||
$giteaSteamwPass = "viadante16"
|
||||
#token autenticazione utente replica gitea
|
||||
$tokenGiteaSteamw = "e6e6944da93bbaf230e4223012035f2cd55d27a6"
|
||||
#access token per autenticazione gitea da profilo replica
|
||||
$giteaSteamwHead = @{"Authorization" = "token $($tokenGiteaSteamw)" }
|
||||
|
||||
#### CONF gogs.steamware.net ####
|
||||
#destinazione mirror per gogs
|
||||
$gogsDestination = "gogs.steamware.net"
|
||||
#nome utente gogs che effettua i mirror push
|
||||
$gogsUser = "replica"
|
||||
#password replica gogs
|
||||
$gogsPass = "viaDante16!"
|
||||
#token autenticazione utente replica gogs
|
||||
$tokenGogs = "bb6d8e9a4d76445e33b12e1664140043fdaa8d87"
|
||||
#access token per autenticazione gogs da profilo replica
|
||||
$gogsHead = @{"Authorization" = "token $($tokenGogs)" }
|
||||
|
||||
#### CONF gitea-azzano.steamware.net ####
|
||||
#destinazione mirror per gitea
|
||||
$giteaAzzano = "gitea-azzano.steamware.net"
|
||||
#nome utente gitea che effettua i mirror push
|
||||
$giteaAzzanoUser = "replica"
|
||||
#autenticazione replica gitea
|
||||
$giteaAzzanoPass = "kj5uQz9QpVdrwXj"
|
||||
#token autenticazione utente replica gitea
|
||||
$tokenGiteaAzzano = "9e9958e9d46d78cc098b3ba7341e750f2d2fd8a3"
|
||||
#access token per autenticazione gitea da profilo replica
|
||||
$giteaAzzanoHead = @{"Authorization" = "token $($tokenGiteaAzzano)" }
|
||||
|
||||
#### CONF gitea-nembro.steamware.net ####
|
||||
#destinazione mirror per gitea
|
||||
$giteaNembro = "gitea-nembro.steamware.net"
|
||||
#nome utente gitea che effettua i mirror push
|
||||
$giteaNembroUser = "replica"
|
||||
#autenticazione replica gitea
|
||||
$giteaNembroPass = "IXQkDchDwMah8E"
|
||||
#token autenticazione utente replica gitea
|
||||
$tokenGiteaNembro = "c58a2fdf6493bb690e8c39b393e06a121f8a6761"
|
||||
#access token per autenticazione gitea da profilo replica
|
||||
$giteaNembroHead = @{"Authorization" = "token $($tokenGiteaNembro)" }
|
||||
@@ -0,0 +1,82 @@
|
||||
######### FUNZIONI COMUNI PER SCRIPT API GIT #########
|
||||
|
||||
#scrittura output & log
|
||||
Function WriteLogOutput {
|
||||
Param ($logFile, $logType, [string]$logString)
|
||||
#compongo path per file di log
|
||||
$logPath = Join-Path $logFolder $logFile
|
||||
#scrivo su file la stringa se il tipo di log è > o uguale al livello richiesto
|
||||
if ($logType -le $logLevel) {
|
||||
Add-content $logPath -value "$logString"
|
||||
#scrivo su terminale la stringa se $terminalOutput=1
|
||||
if ($terminalOutput -eq 1) {
|
||||
Write-Output($logString)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#verifica esistenza folder di log
|
||||
Function CheckLogFolder {
|
||||
if (Test-Path $logFolder) {
|
||||
}
|
||||
else {
|
||||
New-Item $logFolder -ItemType Directory
|
||||
}
|
||||
}
|
||||
|
||||
#rotazione file .log in .old
|
||||
Function RotateOldLog {
|
||||
$logPath = Join-Path $logFolder $logFile
|
||||
$oldLogPath = Join-Path $logFolder $oldLogFile
|
||||
#se file .old esiste sposto contenuto di attuale .log in coda a attuale .old e cancello attuale .log
|
||||
if (Test-Path $logPath){
|
||||
if (Test-Path $oldLogPath) {
|
||||
$from = Get-Content -Path $logPath
|
||||
Add-Content -Path $oldLogPath -Value $from
|
||||
Remove-Item -Path $logPath
|
||||
}
|
||||
#se file .old non esiste rinomino attuale file.log in file.old
|
||||
else {
|
||||
Get-ChildItem $logPath | Rename-Item -NewName { $_.Name -replace '.log','.old' }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#creazione nuovo mirror
|
||||
Function FreshMirrorCreation {
|
||||
Param ($projectNumber, $user, $auth, $destination, $path)
|
||||
#compongo url da chiamare per creazione nuovo mirror
|
||||
$callUrlCreateMirror = "https://gitlab.steamware.net/api/v4/projects/" + $projectNumber + "/remote_mirrors"
|
||||
#creo url del nuovo mirror con username e token relativi a gitlab
|
||||
$newMirror = "http://" + $user + ":" + $auth + "@" + $destination + "/" + $path
|
||||
#creo body da convertire in json
|
||||
$body =
|
||||
@{
|
||||
url = $newMirror
|
||||
enabled = 1
|
||||
}
|
||||
#converto body in json prima di passarlo alla chiamata POST
|
||||
$jsonBody = ConvertTo-Json -InputObject $body
|
||||
#chiamata api POST che crea mirror con url e body specificati
|
||||
$rebuildResponse = Invoke-WebRequest -Method Post -URI $callUrlCreateMirror -Headers $gitlabHead -ContentType "application/json" -Body $jsonBody -UseBasicParsing
|
||||
#conversione da Json della risposta alla chiamata POST
|
||||
$parsedRebuild = $rebuildResponse.Content | ConvertFrom-Json
|
||||
#rilevo ID e URL nuovo mirror per scriverli nel log
|
||||
foreach ($item in $parsedRebuild) {
|
||||
$mirrorId = $($item.id)
|
||||
$mirrorUrl = $($item.url)
|
||||
}
|
||||
#scrivo ID e URL nuovo mirror
|
||||
WriteLogOutput $logFile 1 "NEW ID: $mirrorId - URL: $mirrorUrl - Mirror creato con successo"
|
||||
}
|
||||
|
||||
Function TryParse-Json {
|
||||
param([string]$InputString)
|
||||
|
||||
try {
|
||||
return $InputString | ConvertFrom-Json -ErrorAction Stop
|
||||
}
|
||||
catch {
|
||||
return $null
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
###Gitlab: controllo lo stato dei JobArtifacts dei singoli progetti###
|
||||
|
||||
#Questo script passa in rassegna tutti i progetti esistenti sul gitlab aziendale e per ognuno verifica lo stato dei JobArtifacts, poi invia a zabbix le statistiche.
|
||||
#Tendenzialmente ogni progetto dovrebbe avere 4 JobArtifacts abilitati: nembro, azzano, gitea, gogs
|
||||
|
||||
#importo file contenente configurazioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsConfig.ps1
|
||||
#importo file contenente funzioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsFunctions.ps1
|
||||
|
||||
#rilevo time per log inizio analisi
|
||||
$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
# avvio stopwatch
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$projectCount = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$projectNumber = 1
|
||||
#conteggio progetti trovati
|
||||
$existingProjects = 0
|
||||
#conteggio job trovati
|
||||
$jobFound = 0
|
||||
#nome file di log
|
||||
$logFile = "GitlabJobArtifacts.log"
|
||||
#nome file di log old
|
||||
$oldLogFile = "GitlabJobArtifacts.old"
|
||||
|
||||
#creazione folder di Log se non esiste
|
||||
CheckLogFolder
|
||||
|
||||
#rotazione vecchio logFile da .log a .old se esiste
|
||||
RotateOldLog
|
||||
|
||||
#scrivo intestazione e inizio analisi
|
||||
WriteLogOutput $logFile 0 "--------------------"
|
||||
Switch ($logLevel) {
|
||||
0 { WriteLogOutput $logFile 0 "LOG SINTETICO GITLAB Job Artifacts" }
|
||||
1 { WriteLogOutput $logFile 0 "LOG ERRORI GITLAB Job Artifacts" }
|
||||
2 { WriteLogOutput $logFile 0 "LOG FULL GITLAB Job Artifacts" }
|
||||
3 { WriteLogOutput $logFile 0 "LOG AMPOLLOSO GITLAB Job Artifacts" }
|
||||
}
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Percorso log: $logFolder"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Inizio Esecuzione Script: $startTime"
|
||||
|
||||
#ciclo principale do/while che cicla da 1 a N projectNumber
|
||||
do {
|
||||
#chiamata api che restituisce informazioni sullo stato dei JobArtifacts
|
||||
$callUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/jobs"
|
||||
WriteLogOutput $logFile 1 ""
|
||||
WriteLogOutput $logFile 1 "--------------------"
|
||||
WriteLogOutput $logFile 1 "**PROGETTO $projectCount**"
|
||||
try {
|
||||
#parsing della risposta api convertita da json
|
||||
$Response = Invoke-WebRequest -URI $callUrl -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
$parsedResponse = $Response.Content | ConvertFrom-Json
|
||||
#scrivo il numero del progetto nel terminale e su file
|
||||
$deleteAllUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/artifacts"
|
||||
$deleteAllResponse = Invoke-WebRequest -URI $deleteAllUrl -Method DELETE -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
$parsedDeleteAllResponse = $deleteAllResponse.Content | ConvertFrom-Json
|
||||
|
||||
#foreach ($item in $parsedResponse) {
|
||||
# WriteLogOutput $logFile 1 "ID: $($item.id) | Creato il: $($item.created_at) | URL: $($item.web_url)"
|
||||
# $projectJobFound++
|
||||
# $jobFound++
|
||||
#compongo chiamata api per erase job
|
||||
#$eraseUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/jobs/" + $item.id + "/erase"
|
||||
#$EraseResponse = Invoke-WebRequest -URI $eraseUrl -Method DELETE -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
#$parsedEraseResponse = $EraseResponse.Content | ConvertFrom-Json
|
||||
#compongo chiamata api per delete all job artifacts in a project
|
||||
# $deleteAllUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/artifacts"
|
||||
# $deleteAllResponse = Invoke-WebRequest -URI $deleteAllUrl -Method DELETE -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
# $parsedDeleteAllResponse = $deleteAllResponse.Content | ConvertFrom-Json
|
||||
#}
|
||||
#WriteLogOutput $logFile 1 "Job trovati per il progetto $($projectCount): $($projectJobFound)"
|
||||
#$projectJobFound = 0
|
||||
$existingProjects++
|
||||
}
|
||||
#scrivo se trovo un errore durante il try/catch
|
||||
catch {
|
||||
$parsedError = $_ | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 3 $($parsedError.message)
|
||||
}
|
||||
$projectCount++
|
||||
}
|
||||
#fine ciclo principale
|
||||
while ($projectCount -le $projectNumber)
|
||||
|
||||
# fermo stopwatch e calcolo durata script
|
||||
$mainStopWatch.Stop()
|
||||
$durataScript = $mainStopWatch.Elapsed.TotalSeconds
|
||||
|
||||
#rilevo time per log fine analisi
|
||||
$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#invio a zabbix le metriche rilevate tramite zabbix_sender.exe
|
||||
#WriteLogOutput $logFile 0 ""
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.Projects -o $existingProjects
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.TotalJobArtifacts -o $JobArtifactsCount
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.SuccessJobArtifacts -o $JobArtifactsSuccessCount
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.ErrorsJobArtifacts -o $JobArtifactsErrorsCount
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.SuccessJobArtifactsPercent -o $JobArtifactsSuccessPercentage
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.ErrorsJobArtifactsPercent -o $JobArtifactsErrorsPercentage
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.CheckJobArtifactsDuration -o $durataScript
|
||||
|
||||
#scrivo a video le statistiche
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "PROGETTI ANALIZZATI: $existingProjects"
|
||||
WriteLogOutput $logFile 0 "Job Artifacts TOTALI: $jobFound"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Fine Esecuzione Script: $endTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Durata Esecuzione Script: $durataScript secondi"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
@@ -0,0 +1,126 @@
|
||||
###Gitlab: controllo i commit recenti dei singoli progetti###
|
||||
|
||||
#Questo script passa in rassegna tutti i progetti esistenti sul gitlab aziendale e per ognuno verifica la presenza di commit recenti in una finestra di giorni specificata
|
||||
#Poi invia le statistiche rilevate a zabbix per avere lo storico dei progetti con commit recenti
|
||||
|
||||
#importo file contenente configurazioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsConfig.ps1
|
||||
#importo file contenente funzioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsFunctions.ps1
|
||||
|
||||
#rilevo time per log inizio analisi
|
||||
$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
# avvio stopwatch
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$startProj = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$endProj = 250
|
||||
#conteggio progetti trovati
|
||||
$projectsFound = 0
|
||||
#conteggio progetti con commit negli ultimi giorni
|
||||
$projectWithCommits = 0
|
||||
#conteggio progetti senza commit negli ultimi giorni
|
||||
$projectWithNoCommits = 0
|
||||
#conteggio commits degli ultimi giorni
|
||||
$recentCommits = 0
|
||||
#ultimi giorni da considerare
|
||||
$lastDays = 7
|
||||
#data per conteggio commits degli ultimi giorni
|
||||
$requestDate = (Get-Date).AddDays(-$lastDays).toString("yyyy-MM-dd")
|
||||
#nome file di log
|
||||
$logFile = "GitlabCommits.log"
|
||||
#nome file di log old
|
||||
$oldLogFile = "GitlabCommits.old"
|
||||
|
||||
#creazione folder di Log se non esiste
|
||||
CheckLogFolder
|
||||
|
||||
#rotazione vecchio logFile da .log a .old se esiste
|
||||
RotateOldLog
|
||||
|
||||
#scrivo intestazione e inizio analisi
|
||||
WriteLogOutput $logFile 0 "--------------------"
|
||||
Switch ($logLevel) {
|
||||
0 { WriteLogOutput $logFile 0 "LOG SINTETICO GITLAB COMMITS" }
|
||||
1 { WriteLogOutput $logFile 0 "LOG ERRORI GITLAB COMMITS" }
|
||||
2 { WriteLogOutput $logFile 0 "LOG FULL GITLAB COMMITS" }
|
||||
3 { WriteLogOutput $logFile 0 "LOG AMPOLLOSO GITLAB COMMITS" }
|
||||
}
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Percorso log: $logFolder"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Inizio Esecuzione Script: $startTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "RICERCA DA $requestDate | ULTIMI $lastDays GIORNI"
|
||||
|
||||
#ciclo principale for che cicla da 1 a N projectNumber
|
||||
for ($projectCount = $startProj; $projectCount -le $endProj; $projectCount++) {
|
||||
$callUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/repository/commits?per_page=100&since=" + $requestDate
|
||||
try {
|
||||
$Response = Invoke-WebRequest -URI $callUrl -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
$parsedResponse = $Response.Content | ConvertFrom-Json
|
||||
#scrivo il numero del progetto nel terminale e su file
|
||||
WriteLogOutput $logFile 1 ""
|
||||
WriteLogOutput $logFile 1 "--------------------"
|
||||
WriteLogOutput $logFile 1 "**PROGETTO $projectCount**"
|
||||
if ($parsedResponse.Count -eq 0 ) {
|
||||
$projectWithNoCommits++
|
||||
}
|
||||
else {
|
||||
$projectWithCommits++
|
||||
foreach ($item in $parsedResponse) {
|
||||
if ($item.web_url) {
|
||||
WriteLogOutput $logFile 1 "Date: $($item.committed_date) - Web Url: $($item.web_url)"
|
||||
$recentCommits++
|
||||
}
|
||||
}
|
||||
}
|
||||
$projectsFound++
|
||||
}
|
||||
#scrivo se trovo un errore durante il try/catch
|
||||
catch {
|
||||
$parsedError = $_ | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 3 ""
|
||||
WriteLogOutput $logFile 3 "--------------------"
|
||||
WriteLogOutput $logFile 3 "**ERRORE NEL PROGETTO $projectCount**"
|
||||
WriteLogOutput $logFile 3 $($parsedError.message)
|
||||
}
|
||||
}
|
||||
#fine ciclo principale
|
||||
|
||||
#percentuale di projectWithCommits sul totale
|
||||
$projectWithCommitsPercentage = [math]::Round(($projectWithCommits / $projectsFound) * 100, 1)
|
||||
|
||||
#percentuale di projectWithNoCommits sul totale
|
||||
$projectWithNoCommitsPercentage = [math]::Round(($projectWithNoCommits / $projectsFound) * 100, 1)
|
||||
|
||||
# fermo stopwatch e calcolo durata script
|
||||
$mainStopWatch.Stop()
|
||||
$durataScript = $mainStopWatch.Elapsed.TotalSeconds
|
||||
|
||||
#rilevo time per log fine analisi
|
||||
$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#invio a zabbix le metriche rilevate tramite zabbix_sender.exe
|
||||
WriteLogOutput $logFile 0 ""
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.ProjectsFound -o $projectsFound
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.LastDaysCommits -o $lastDays
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.RecentCommits -o $recentCommits
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.ProjectWithCommits -o $projectWithCommits
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.ProjectWithNoCommits -o $projectWithNoCommits
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.ProjectWithCommitsPercentage -o $projectWithCommitsPercentage
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.ProjectWithNoCommitsPercentage -o $projectWithNoCommitsPercentage
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.CheckCommitsDuration -o $durataScript
|
||||
|
||||
#scrivo a video le statistiche
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "PROGETTI TOTALI: $projectsFound"
|
||||
WriteLogOutput $logFile 0 "COMMITS TOTALI: $recentCommits"
|
||||
WriteLogOutput $logFile 0 "PROGETTI CON COMMITS: $projectWithCommits ($projectWithCommitsPercentage%)"
|
||||
WriteLogOutput $logFile 0 "PROGETTI SENZA COMMITS: $projectWithNoCommits ($projectWithNoCommitsPercentage%)"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Fine Esecuzione Script: $endTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Durata Esecuzione Script: $durataScript secondi"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
@@ -0,0 +1,119 @@
|
||||
###Gitlab: controllo lo stato dei mirror dei singoli progetti###
|
||||
|
||||
#Questo script passa in rassegna tutti i progetti esistenti sul gitlab aziendale e per ognuno verifica lo stato dei mirror, poi invia a zabbix le statistiche.
|
||||
#Tendenzialmente ogni progetto dovrebbe avere 4 mirror abilitati: nembro, azzano, gitea, gogs
|
||||
|
||||
#importo file contenente configurazioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsConfig.ps1
|
||||
#importo file contenente funzioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsFunctions.ps1
|
||||
|
||||
#rilevo time per log inizio analisi
|
||||
$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
# avvio stopwatch
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$startProj = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$endProj = 300
|
||||
#conteggio progetti trovati
|
||||
$existingProjects = 0
|
||||
#conteggio mirroring in errore
|
||||
$mirrorErrorsCount = 0
|
||||
#conteggio mirroring riusciti
|
||||
$mirrorSuccessCount = 0
|
||||
#nome file di log
|
||||
$logFile = "GitlabCheckMirrors.log"
|
||||
#nome file di log old
|
||||
$oldLogFile = "GitlabCheckMirrors.old"
|
||||
|
||||
#creazione folder di Log se non esiste
|
||||
CheckLogFolder
|
||||
|
||||
#rotazione vecchio logFile da .log a .old se esiste
|
||||
RotateOldLog
|
||||
|
||||
#scrivo intestazione e inizio analisi
|
||||
WriteLogOutput $logFile 0 "--------------------"
|
||||
Switch ($logLevel) {
|
||||
0 { WriteLogOutput $logFile 0 "LOG SINTETICO GITLAB MIRRORING" }
|
||||
1 { WriteLogOutput $logFile 0 "LOG ERRORI GITLAB MIRRORING" }
|
||||
2 { WriteLogOutput $logFile 0 "LOG FULL GITLAB MIRRORING" }
|
||||
3 { WriteLogOutput $logFile 0 "LOG AMPOLLOSO GITLAB MIRRORING" }
|
||||
}
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Percorso log: $logFolder"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Inizio Esecuzione Script: $startTime"
|
||||
|
||||
#ciclo principale for che cicla da startProj a endProj
|
||||
for ($projectCount = $startProj; $projectCount -le $endProj; $projectCount++){
|
||||
#chiamata api che restituisce informazioni sullo stato dei mirror
|
||||
$callUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/remote_mirrors"
|
||||
WriteLogOutput $logFile 1 ""
|
||||
WriteLogOutput $logFile 1 "--------------------"
|
||||
WriteLogOutput $logFile 1 "**PROGETTO $projectCount**"
|
||||
try {
|
||||
#parsing della risposta api convertita da json
|
||||
$Response = Invoke-WebRequest -URI $callUrl -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
$parsedResponse = $Response.Content | ConvertFrom-Json
|
||||
#scrivo il numero del progetto nel terminale e su file
|
||||
foreach ($item in $parsedResponse) {
|
||||
#verifico se i mirroring trovati per il progetto corrente hanno status "finished" e scrivo log
|
||||
if ($item.update_status.Equals("finished")) {
|
||||
WriteLogOutput $logFile 2 "Mirror: $($item.url) - Status: $($item.update_status) - Last Success: $($item.last_successful_update_at)"
|
||||
$mirrorSuccessCount++
|
||||
}
|
||||
#per i mirroring che non hanno status "finished" scrivo log con relativo errore
|
||||
else {
|
||||
WriteLogOutput $logFile 1 "Mirror: $($item.url) - Status: $($item.update_status) - Last Success: $($item.last_successful_update_at) - Last Attempt: $($item.last_update_started_at)"
|
||||
WriteLogOutput $logFile 1 "Error: $($item.last_error)"
|
||||
$mirrorErrorsCount++
|
||||
}
|
||||
}
|
||||
$existingProjects++
|
||||
}
|
||||
#scrivo se trovo un errore durante il try/catch
|
||||
catch {
|
||||
$parsedError = $_ | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 3 $($parsedError.message)
|
||||
}
|
||||
}
|
||||
|
||||
#somma di mirrorSuccess e mirrorErrors
|
||||
$mirrorCount = $mirrorSuccessCount + $mirrorErrorsCount
|
||||
|
||||
#percentuale di mirrorSuccess sul totale
|
||||
$mirrorSuccessPercentage = [math]::Round(($mirrorSuccessCount / $mirrorCount) * 100, 1)
|
||||
|
||||
#percentuale di mirrorErrors sul totale
|
||||
$mirrorErrorsPercentage = [math]::Round(($mirrorErrorsCount / $mirrorCount) * 100, 1)
|
||||
|
||||
# fermo stopwatch e calcolo durata script
|
||||
$mainStopWatch.Stop()
|
||||
$durataScript = $mainStopWatch.Elapsed.TotalSeconds
|
||||
|
||||
#rilevo time per log fine analisi
|
||||
$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#invio a zabbix le metriche rilevate tramite zabbix_sender.exe
|
||||
WriteLogOutput $logFile 0 ""
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.Projects -o $existingProjects
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.TotalMirror -o $mirrorCount
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.SuccessMirror -o $mirrorSuccessCount
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.ErrorsMirror -o $mirrorErrorsCount
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.SuccessMirrorPercent -o $mirrorSuccessPercentage
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.ErrorsMirrorPercent -o $mirrorErrorsPercentage
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.CheckMirrorDuration -o $durataScript
|
||||
|
||||
#scrivo a video le statistiche
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "PROGETTI ANALIZZATI: $existingProjects"
|
||||
WriteLogOutput $logFile 0 "MIRRORING TOTALI: $mirrorCount"
|
||||
WriteLogOutput $logFile 0 "MIRRORING RIUSCITI: $mirrorSuccessCount ($mirrorSuccessPercentage%)"
|
||||
WriteLogOutput $logFile 0 "MIRRORING FALLITI: $mirrorErrorsCount ($mirrorErrorsPercentage%)"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Fine Esecuzione Script: $endTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Durata Esecuzione Script: $durataScript secondi"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
@@ -0,0 +1,112 @@
|
||||
###Gitlab: creazione 4 mirror se assenti###
|
||||
|
||||
#Questo script passa in rassegna tutti i progetti esistenti sul gitlab aziendale e per ognuno controlla se esistono i 4 mirror standard (gitea gogs nembro azzano)
|
||||
#Se trova che manca uno di questi quattro, viene creato
|
||||
|
||||
#importo file contenente configurazioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsConfig.ps1
|
||||
#importo file contenente funzioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsFunctions.ps1
|
||||
|
||||
#rilevo time per log inizio analisi
|
||||
$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
# avvio stopwatch
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$startProj = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$endProj = 300
|
||||
#contatore mirror creati
|
||||
$createdMirrors = 0
|
||||
#nome file di log
|
||||
$logFile = "NewMirrorsCreation.log"
|
||||
#nome file di log old
|
||||
$oldLogFile = "NewMirrorsCreation.old"
|
||||
|
||||
#creazione folder di Log se non esiste
|
||||
CheckLogFolder
|
||||
|
||||
#rotazione vecchio logFile da .log a .old se esiste
|
||||
RotateOldLog
|
||||
|
||||
#scrivo intestazione e inizio analisi
|
||||
WriteLogOutput $logFile 0 "--------------------"
|
||||
Switch ($logLevel) {
|
||||
0 { WriteLogOutput $logFile 0 "LOG SINTETICO NUOVI MIRROR" }
|
||||
1 { WriteLogOutput $logFile 0 "LOG ERRORI NUOVI MIRROR" }
|
||||
2 { WriteLogOutput $logFile 0 "LOG FULL NUOVI MIRROR" }
|
||||
3 { WriteLogOutput $logFile 0 "LOG AMPOLLOSO NUOVI MIRROR" }
|
||||
}
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Percorso log: $logFolder"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Inizio Esecuzione Script: $startTime"
|
||||
|
||||
#ciclo principale for che cicla da 1 a N projectNumber
|
||||
for ($projectCount = $startProj; $projectCount -le $endProj; $projectCount++) {
|
||||
$callUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/remote_mirrors"
|
||||
try {
|
||||
$gitlabResponse = Invoke-WebRequest -URI $callUrl -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
#$parsedGitlabResponse = $gitlabResponse.Content | ConvertFrom-Json
|
||||
#scrivo il numero del progetto nel terminale e su file
|
||||
WriteLogOutput $logFile 1 ""
|
||||
WriteLogOutput $logFile 1 "--------------------"
|
||||
WriteLogOutput $logFile 1 "**PROGETTO $projectCount**"
|
||||
#ricavo nome del progetto per poter creare mirror
|
||||
$nameCall = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount
|
||||
$nameResponse = Invoke-WebRequest -URI $nameCall -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
#parsing del contenuto della risposta da gitlab
|
||||
$parsedNameResponse = $nameResponse.Content | ConvertFrom-Json
|
||||
#compongo path con struttura Egalware/NomeProgetto.git
|
||||
$simplePath = "Egalware/" + $($parsedNameResponse.path) + ".git"
|
||||
#se la risposta non contiene "gitea" procedo a creare mirror relativo
|
||||
if ($gitlabResponse.Content -inotmatch "gitea.steamware.net") {
|
||||
#chiamo funzione per creare mirror verso gitea-steamware
|
||||
FreshMirrorCreation $projectCount $giteaSteamwUser $giteaSteamwPass $giteaSteamw $simplePath
|
||||
$createdMirrors++
|
||||
}
|
||||
#se la risposta non contiene "gogs" procedo a creare mirror relativo
|
||||
if ($gitlabResponse.Content -inotmatch "gogs.steamware.net") {
|
||||
#chiamo funzione per creare mirror verso gogs
|
||||
FreshMirrorCreation $projectCount $gogsUser $gogsPass $gogsDestination $simplePath
|
||||
$createdMirrors++
|
||||
}
|
||||
#se la risposta non contiene "gitea-nembro" procedo a creare mirror relativo
|
||||
if ($gitlabResponse.Content -inotmatch "gitea-nembro") {
|
||||
#chiamo funzione per creare mirror verso gitea-nembro
|
||||
FreshMirrorCreation $projectCount $giteaNembroUser $giteaNembroPass $giteaNembro $simplePath
|
||||
$createdMirrors++
|
||||
}
|
||||
#se la risposta non contiene "gitea-azzano" procedo a creare mirror relativo
|
||||
if ($gitlabResponse.Content -inotmatch "gitea-azzano") {
|
||||
#chiamo funzione per creare mirror verso gitea-azzano
|
||||
FreshMirrorCreation $projectCount $giteaAzzanoUser $giteaAzzanoPass $giteaAzzano $simplePath
|
||||
$createdMirrors++
|
||||
}
|
||||
}
|
||||
#scrivo se trovo un errore durante il try/catch
|
||||
catch {
|
||||
$parsedError = $_ | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 3 ""
|
||||
WriteLogOutput $logFile 3 "--------------------"
|
||||
WriteLogOutput $logFile 3 "**ERRORE NEL PROGETTO $projectCount**"
|
||||
WriteLogOutput $logFile 3 $($parsedError.message)
|
||||
}
|
||||
}
|
||||
#fine ciclo principale
|
||||
|
||||
# fermo stopwatch e calcolo durata script
|
||||
$mainStopWatch.Stop()
|
||||
$durataScript = $mainStopWatch.Elapsed.TotalSeconds
|
||||
|
||||
#rilevo time per log fine analisi
|
||||
$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#scrivo a video le statistiche
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Nuovi mirror creati: $createdMirrors"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Fine Esecuzione Script: $endTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Durata Esecuzione Script: $durataScript secondi"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
@@ -0,0 +1,93 @@
|
||||
###Gitlab: delete mirrors###
|
||||
|
||||
#Questo script passa in rassegna tutti i progetti esistenti sul gitlab aziendale e per ognuno può cancellare i mirror desiderati
|
||||
|
||||
#IMPORTANTE: SCRIPT PERICOLOSO. TOGLIERE COMMENTO A RIGA 62 PER CANCELLARE.
|
||||
|
||||
#importo file contenente configurazioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsConfig.ps1
|
||||
#importo file contenente funzioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsFunctions.ps1
|
||||
|
||||
#rilevo time per log inizio analisi
|
||||
$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
# avvio stopwatch
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$startProj = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$endProj = 300
|
||||
#contatore numero mirror cancellati
|
||||
$deletedMirrors = 0
|
||||
#nome file di log
|
||||
$logFile = "MirrorsDelete.log"
|
||||
#nome file di log old
|
||||
$oldLogFile = "MirrorsDelete.old"
|
||||
#stringa da cercare per cancellare il mirror
|
||||
$mirrorToDelete = "gitlab-azzano"
|
||||
|
||||
#creazione folder di Log se non esiste
|
||||
CheckLogFolder
|
||||
|
||||
#rotazione vecchio logFile da .log a .old se esiste
|
||||
RotateOldLog
|
||||
|
||||
#scrivo intestazione e inizio analisi
|
||||
WriteLogOutput $logFile 0 "--------------------"
|
||||
Switch ($logLevel) {
|
||||
0 { WriteLogOutput $logFile 0 "LOG SINTETICO DELETE MIRROR" }
|
||||
1 { WriteLogOutput $logFile 0 "LOG ERRORI DELETE MIRROR" }
|
||||
2 { WriteLogOutput $logFile 0 "LOG FULL DELETE MIRROR" }
|
||||
3 { WriteLogOutput $logFile 0 "LOG AMPOLLOSO DELETE MIRROR" }
|
||||
}
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Percorso log: $logFolder"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Inizio Esecuzione Script: $startTime"
|
||||
|
||||
#ciclo principale for che cicla da 1 a N projectNumber
|
||||
for ($projectCount = $startProj; $projectCount -le $endProj; $projectCount++) {
|
||||
$callUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/remote_mirrors"
|
||||
try {
|
||||
$gitlabResponse = Invoke-WebRequest -URI $callUrl -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
$parsedGitlabResponse = $gitlabResponse.Content | ConvertFrom-Json
|
||||
#scrivo il numero del progetto nel terminale e su file
|
||||
WriteLogOutput $logFile 1 ""
|
||||
WriteLogOutput $logFile 1 "--------------------"
|
||||
WriteLogOutput $logFile 1 "**PROGETTO $projectCount**"
|
||||
foreach ($gitResponse IN $parsedGitlabResponse){
|
||||
if ($gitResponse -match $mirrorToDelete) {
|
||||
#Cancello mirror verso gitlab-nembro
|
||||
$deleteUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/remote_mirrors/" + $gitResponse.id
|
||||
#Invoke-WebRequest -URI $deleteUrl -Method DELETE -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
WriteLogOutput $logFile 1 "Eliminato mirror: $gitResponse"
|
||||
$deletedMirrors++
|
||||
}
|
||||
}
|
||||
}
|
||||
#scrivo se trovo un errore durante il try/catch
|
||||
catch {
|
||||
$parsedError = $_ | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 3 ""
|
||||
WriteLogOutput $logFile 3 "--------------------"
|
||||
WriteLogOutput $logFile 3 "**ERRORE NEL PROGETTO $projectCount**"
|
||||
WriteLogOutput $logFile 3 $($parsedError.message)
|
||||
}
|
||||
}
|
||||
#fine ciclo principale
|
||||
|
||||
# fermo stopwatch e calcolo durata script
|
||||
$mainStopWatch.Stop()
|
||||
$durataScript = $mainStopWatch.Elapsed.TotalSeconds
|
||||
|
||||
#rilevo time per log fine analisi
|
||||
$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#scrivo a video le statistiche
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Numero mirror cancellati: $deletedMirrors"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Fine Esecuzione Script: $endTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Durata Esecuzione Script: $durataScript secondi"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
@@ -0,0 +1,95 @@
|
||||
###Gitlab: forzo push verso i mirror dei singoli progetti###
|
||||
|
||||
#Questo script passa in rassegna tutti i progetti esistenti sul gitlab aziendale e per ognuno verifica lo stato dei mirror, poi forza il push di tutti.
|
||||
|
||||
#importo file contenente configurazioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsConfig.ps1
|
||||
#importo file contenente funzioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsFunctions.ps1
|
||||
|
||||
#rilevo time per log inizio analisi
|
||||
$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
# avvio stopwatch
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$startProj = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$endProj = 300
|
||||
#conteggio progetti trovati
|
||||
$existingProjects = 0
|
||||
#contatore mirror trovati
|
||||
$mirrorCount = 0
|
||||
#nome file di log
|
||||
$logFile = "GitlabForcePushMirror.log"
|
||||
#nome file di log old
|
||||
$oldLogFile = "GitlabForcePushMirror.old"
|
||||
|
||||
#creazione folder di Log se non esiste
|
||||
CheckLogFolder
|
||||
|
||||
#rotazione vecchio logFile da .log a .old se esiste
|
||||
RotateOldLog
|
||||
|
||||
#scrivo intestazione e inizio analisi
|
||||
WriteLogOutput $logFile 0 "--------------------"
|
||||
Switch ($logLevel) {
|
||||
0 { WriteLogOutput $logFile 0 "LOG SINTETICO GITLAB FORCE PUSH MIRROR" }
|
||||
1 { WriteLogOutput $logFile 0 "LOG ERRORI GITLAB FORCE PUSH MIRROR" }
|
||||
2 { WriteLogOutput $logFile 0 "LOG FULL GITLAB FORCE PUSH MIRROR" }
|
||||
3 { WriteLogOutput $logFile 0 "LOG AMPOLLOSO GITLAB FORCE PUSH MIRROR" }
|
||||
}
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Percorso log: $logFolder"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Inizio Esecuzione Script: $startTime"
|
||||
|
||||
#ciclo principale for che cicla da 1 a N projectNumber
|
||||
for ($projectCount = $startProj; $projectCount -le $endProj; $projectCount++) {
|
||||
#chiamata api che restituisce informazioni sullo stato dei mirror
|
||||
$callUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/remote_mirrors"
|
||||
WriteLogOutput $logFile 1 ""
|
||||
WriteLogOutput $logFile 1 "--------------------"
|
||||
WriteLogOutput $logFile 1 "**PROGETTO $projectCount**"
|
||||
try {
|
||||
#parsing della risposta api convertita da json
|
||||
$Response = Invoke-WebRequest -URI $callUrl -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
$parsedResponse = $Response.Content | ConvertFrom-Json
|
||||
#per ogni mirror forzo il push
|
||||
foreach ($item in $parsedResponse) {
|
||||
#compongo URL per chiamata POST per forzare PUSH
|
||||
$callUrlForcePush = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/remote_mirrors/" + $item.id + "/sync"
|
||||
$PushResponse = Invoke-WebRequest -URI $callUrlForcePush -Method POST -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
if ($PushResponse.StatusCode -eq 204){
|
||||
WriteLogOutput $logFile 0 $("Mirror Push: Success - " + $item.url)
|
||||
}
|
||||
else {
|
||||
WriteLogOutput $logFile 0 $("Mirror Push: Unknown - " + $item.url)
|
||||
}
|
||||
$mirrorCount++
|
||||
}
|
||||
$existingProjects++
|
||||
}
|
||||
#scrivo se trovo un errore durante il try/catch
|
||||
catch {
|
||||
$parsedError = $_ | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 3 $($parsedError.message)
|
||||
}
|
||||
}
|
||||
#fine ciclo principale
|
||||
|
||||
# fermo stopwatch e calcolo durata script
|
||||
$mainStopWatch.Stop()
|
||||
$durataScript = $mainStopWatch.Elapsed.TotalSeconds
|
||||
|
||||
#rilevo time per log fine analisi
|
||||
$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#scrivo a video le statistiche
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "PROGETTI ANALIZZATI: $existingProjects"
|
||||
WriteLogOutput $logFile 0 "MIRRORING TOTALI: $mirrorCount"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Fine Esecuzione Script: $endTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Durata Esecuzione Script: $durataScript secondi"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
@@ -0,0 +1,146 @@
|
||||
###Gitlab: riscrive i mirror verso gitea###
|
||||
|
||||
#Questo script passa in rassegna tutti i progetti esistenti sul gitlab aziendale e per ognuno riscrive il mirror verso gitea (cancella mirror e ricrea)
|
||||
|
||||
#importo file contenente configurazioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsConfig.ps1
|
||||
#importo file contenente funzioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsFunctions.ps1
|
||||
|
||||
#rilevo time per log inizio analisi
|
||||
$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
# avvio stopwatch
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$startProj = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$endProj = 250
|
||||
#inizializzo variabili vuote
|
||||
$mirrorId = ""
|
||||
$mirrorUrl = ""
|
||||
$body = ""
|
||||
$jsonBody = ""
|
||||
#nome file di log
|
||||
$logFile = "GitlabMirroringGitea.log"
|
||||
#nome file di log old
|
||||
$oldLogFile = "GitlabMirroringGitea.old"
|
||||
|
||||
#gitea di destinazione (scegliere prima di esecuzione)
|
||||
#$target = "steamware"
|
||||
$target = "nembro"
|
||||
|
||||
#creazione folder di Log se non esiste
|
||||
CheckLogFolder
|
||||
|
||||
#rotazione vecchio logFile da .log a .old se esiste
|
||||
RotateOldLog
|
||||
|
||||
if ($target = "steamware"){
|
||||
#destinazione mirror per gitea Steamw
|
||||
$giteaDestination = $giteaSteamw
|
||||
#nome utente gitea Steamw che effettua i mirror push
|
||||
$giteaUser = $giteaSteamwUser
|
||||
#autenticazione replica gitea Steamw
|
||||
$giteaPass = $giteaSteamwPass
|
||||
#access token per autenticazione gitea Steamw da profilo replica
|
||||
$giteaHead = $giteaSteamwHead
|
||||
}
|
||||
if ($target = "nembro"){
|
||||
#destinazione mirror per gitea nembro
|
||||
$giteaDestination = $giteaNembro
|
||||
#nome utente gitea nembro che effettua i mirror push
|
||||
$giteaUser = $giteaNembroUser
|
||||
#autenticazione replica gitea nembro
|
||||
$giteaPass = $tokenGiteaNembro
|
||||
#access token per autenticazione gitea nembro da profilo replica
|
||||
$giteaHead = $giteaNembroHead
|
||||
}
|
||||
|
||||
#scrivo intestazione e inizio analisi
|
||||
WriteLogOutput $logFile 0 "--------------------"
|
||||
Switch ($logLevel) {
|
||||
0 { WriteLogOutput $logFile 0 "LOG SINTETICO GITLAB MIRRORING" }
|
||||
1 { WriteLogOutput $logFile 0 "LOG ERRORI GITLAB MIRRORING" }
|
||||
2 { WriteLogOutput $logFile 0 "LOG FULL GITLAB MIRRORING" }
|
||||
3 { WriteLogOutput $logFile 0 "LOG AMPOLLOSO GITLAB MIRRORING" }
|
||||
}
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Percorso log: $logFolder"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Inizio Esecuzione Script: $startTime"
|
||||
|
||||
#ciclo principale for che cicla da startProj a endProj
|
||||
for ($projectCount = $startProj; $projectCount -le $endProj; $projectCount++){
|
||||
#chiamata api che restituisce informazioni sullo stato dei mirror
|
||||
$callUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/remote_mirrors"
|
||||
try {
|
||||
#parsing della risposta api convertita da json
|
||||
$Response = Invoke-WebRequest -URI $callUrl -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
$parsedResponse = $Response.Content | ConvertFrom-Json
|
||||
#scrivo il numero del progetto
|
||||
WriteLogOutput $logFile 1 ""
|
||||
WriteLogOutput $logFile 1 "--------------------"
|
||||
WriteLogOutput $logFile 1 "**PROGETTO $projectCount**"
|
||||
foreach ($item in $parsedResponse) {
|
||||
$mirrorUrl = ""
|
||||
$trunkedPath = ""
|
||||
#controllo se l'url del mirror contiene gitea
|
||||
if ($item.url.Contains($giteaDestination)) {
|
||||
#salvo id mirror e url mirror
|
||||
$mirrorId = $($item.id)
|
||||
$mirrorUrl = $($item.url)
|
||||
WriteLogOutput $logFile 1 "ID: $mirrorId - URL: $mirrorUrl"
|
||||
#tronco url fino a ".net"
|
||||
$splitUrl = $mirrorUrl -split '.steamware.net/'
|
||||
$trunkedPath = $splitUrl[1]
|
||||
#compongo URL per cancellare mirror con ID trovato
|
||||
$callUrlDeleteMirror = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/remote_mirrors/" + $mirrorId
|
||||
#chiamata api con method delete che cancella mirror con id specificato
|
||||
Invoke-WebRequest -Method Delete -URI $callUrlDeleteMirror -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
#compongo url da chiamare per creazione nuovo mirror
|
||||
$callUrlCreateMirror = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/remote_mirrors"
|
||||
#creo url del nuovo mirror con username e pass relativi a gitlab
|
||||
$newMirror = "https://" + $giteaUser + ":" + $giteaPass + "@" + $giteaDestination + "/" + $trunkedPath
|
||||
#creo body da convertire in json
|
||||
$body =
|
||||
@{
|
||||
url = $newMirror
|
||||
enabled = 1
|
||||
}
|
||||
#converto body in json prima di passarlo alla chiamata POST
|
||||
$jsonBody = ConvertTo-Json -InputObject $body
|
||||
#chiamata api POST che crea mirror con url e body specificati
|
||||
$rebuildResponse = Invoke-WebRequest -Method Post -URI $callUrlCreateMirror -Headers $gitlabHead -ContentType "application/json" -Body $jsonBody -UseBasicParsing
|
||||
$parsedRebuild = $rebuildResponse.Content | ConvertFrom-Json
|
||||
foreach ($item in $parsedRebuild) {
|
||||
$mirrorId = $($item.id)
|
||||
$mirrorUrl = $($item.url)
|
||||
}
|
||||
WriteLogOutput $logFile 1 "NEW ID: $mirrorId - URL: $mirrorUrl - Mirror ricostruito con successo"
|
||||
}
|
||||
}
|
||||
}
|
||||
#scrivo se trovo un errore durante il try/catch
|
||||
catch {
|
||||
$parsedError = $_ | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 3 ""
|
||||
WriteLogOutput $logFile 3 "--------------------"
|
||||
WriteLogOutput $logFile 3 "**ERRORE NEL PROGETTO $projectCount**"
|
||||
WriteLogOutput $logFile 3 $($parsedError.message)
|
||||
}
|
||||
}
|
||||
#fine ciclo principale
|
||||
|
||||
# fermo stopwatch e calcolo durata script
|
||||
$mainStopWatch.Stop()
|
||||
$durataScript = $mainStopWatch.Elapsed.TotalSeconds
|
||||
|
||||
#rilevo time per log fine analisi
|
||||
$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#scrivo a video le statistiche
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Fine Esecuzione Script: $endTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Durata Esecuzione Script: $durataScript secondi"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
@@ -0,0 +1,138 @@
|
||||
###Gitlab: Rinnovamento mirrors esistenti (O CANCELLAZIONE)###
|
||||
|
||||
#Questo script viene utilizzato per cancellare e ricreare i mirror esistenti verso gitlab-nembro e gitlab-azzano. Da usare allo scadere dei token di autenticazione.
|
||||
#Una volta inseriti i token nuovi nel file ApiScriptConfig, facendo girare questo script tutti i mirror verso nembro e azzano sono ricreati con il token nuovo.
|
||||
|
||||
#importo file contenente configurazioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsConfig.ps1
|
||||
#importo file contenente funzioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsFunctions.ps1
|
||||
|
||||
#rilevo time per log inizio analisi
|
||||
$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
# avvio stopwatch
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$startProj = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$endProj = 300
|
||||
#inizializzo variabili vuote
|
||||
$mirrorId = ""
|
||||
$mirrorUrl = ""
|
||||
$body = ""
|
||||
$jsonBody = ""
|
||||
#nome file di log
|
||||
$logFile = "GitlabRebuildMirroring.log"
|
||||
#nome file di log old
|
||||
$oldLogFile = "GitlabRebuildMirroring.old"
|
||||
|
||||
#creazione folder di Log se non esiste
|
||||
CheckLogFolder
|
||||
|
||||
#rotazione vecchio logFile da .log a .old se esiste
|
||||
RotateOldLog
|
||||
|
||||
#scrivo intestazione e inizio analisi
|
||||
WriteLogOutput $logFile 0 "--------------------"
|
||||
Switch ($logLevel) {
|
||||
0 { WriteLogOutput $logFile 0 "LOG SINTETICO GITLAB MIRRORING" }
|
||||
1 { WriteLogOutput $logFile 0 "LOG ERRORI GITLAB MIRRORING" }
|
||||
2 { WriteLogOutput $logFile 0 "LOG FULL GITLAB MIRRORING" }
|
||||
3 { WriteLogOutput $logFile 0 "LOG AMPOLLOSO GITLAB MIRRORING" }
|
||||
}
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Percorso log: $logFolder"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Inizio Esecuzione Script: $startTime"
|
||||
|
||||
#ciclo principale for che cicla da startProj a endProj
|
||||
for ($projectCount = $startProj; $projectCount -le $endProj; $projectCount++){
|
||||
#chiamata api che restituisce informazioni sullo stato dei mirror
|
||||
$callUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/remote_mirrors"
|
||||
try {
|
||||
#parsing della risposta api convertita da json
|
||||
$Response = Invoke-WebRequest -URI $callUrl -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
$parsedResponse = $Response.Content | ConvertFrom-Json
|
||||
#scrivo il numero del progetto
|
||||
WriteLogOutput $logFile 1 ""
|
||||
WriteLogOutput $logFile 1 "--------------------"
|
||||
WriteLogOutput $logFile 1 "**PROGETTO $projectCount**"
|
||||
foreach ($item in $parsedResponse) {
|
||||
$doExecute = "false"
|
||||
$destinationToken = ""
|
||||
$mirrorUrl = ""
|
||||
$mirrorId = ""
|
||||
#controllo se l'url del mirror contiene azzano, riscrivo mirror
|
||||
if ($item.url.Contains("azzano")) {
|
||||
$doExecute = "true"
|
||||
$destinationToken = $tokenAzzano
|
||||
$mirrorDestination = $destinationAzzano
|
||||
}
|
||||
#controllo se l'url del mirror contiene nembro, riscrivo mirror
|
||||
#elseif ($item.url.Contains("nembro")) {
|
||||
# $doExecute = "true"
|
||||
# $destinationToken = $tokenNembro
|
||||
# $mirrorDestination = "@gitlab-nembro.steamware.net"
|
||||
#}
|
||||
#verifico se devo effettuare cancellazione e creazione nuovo mirror
|
||||
if ($doExecute -eq "true") {
|
||||
#salvo id mirror e url mirror
|
||||
$mirrorId = $($item.id)
|
||||
$mirrorUrl = $($item.url)
|
||||
#chiamata per rilevare path del repo
|
||||
$nameCall = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount
|
||||
$nameResponse = Invoke-WebRequest -URI $nameCall -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
#parsing del contenuto della risposta da gitlab
|
||||
$parsedNameResponse = $nameResponse.Content | ConvertFrom-Json
|
||||
$simplePath = "Egalware/" + $($parsedNameResponse.path) + ".git"
|
||||
#compongo URL per cancellare mirror con ID trovato
|
||||
$callUrlDeleteMirror = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/remote_mirrors/" + $mirrorId
|
||||
#chiamata api con method delete che cancella mirror con id specificato
|
||||
Invoke-WebRequest -Method Delete -URI $callUrlDeleteMirror -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
#compongo url da chiamare per creazione nuovo mirror
|
||||
$callUrlCreateMirror = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/remote_mirrors"
|
||||
#creo url del nuovo mirror con username e token relativi a gitlab
|
||||
$newMirror = "https://" + $userName + ":" + $destinationToken + $mirrorDestination + "/" + $simplePath
|
||||
#creo body da convertire in json
|
||||
$body =
|
||||
@{
|
||||
url = $newMirror
|
||||
enabled = 1
|
||||
}
|
||||
#converto body in json prima di passarlo alla chiamata POST
|
||||
$jsonBody = ConvertTo-Json -InputObject $body
|
||||
#chiamata api POST che crea mirror con url e body specificati
|
||||
$rebuildResponse = Invoke-WebRequest -Method Post -URI $callUrlCreateMirror -Headers $gitlabHead -ContentType "application/json" -Body $jsonBody -UseBasicParsing
|
||||
$parsedRebuild = $rebuildResponse.Content | ConvertFrom-Json
|
||||
foreach ($item in $parsedRebuild) {
|
||||
$mirrorId = $($item.id)
|
||||
$mirrorUrl = $($item.url)
|
||||
}
|
||||
WriteLogOutput $logFile 1 "NEW ID: $mirrorId - URL: $mirrorUrl - Mirror ricostruito con successo"
|
||||
}
|
||||
}
|
||||
}
|
||||
#scrivo se trovo un errore durante il try/catch
|
||||
catch {
|
||||
$parsedError = $_ | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 3 ""
|
||||
WriteLogOutput $logFile 3 "--------------------"
|
||||
WriteLogOutput $logFile 3 "**ERRORE NEL PROGETTO $projectCount**"
|
||||
WriteLogOutput $logFile 3 $($parsedError.message)
|
||||
}
|
||||
}
|
||||
#fine ciclo principale
|
||||
|
||||
# fermo stopwatch e calcolo durata script
|
||||
$mainStopWatch.Stop()
|
||||
$durataScript = $mainStopWatch.Elapsed.TotalSeconds
|
||||
|
||||
#rilevo time per log fine analisi
|
||||
$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#scrivo a video le statistiche
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Fine Esecuzione Script: $endTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Durata Esecuzione Script: $durataScript secondi"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
@@ -0,0 +1,100 @@
|
||||
###Gitlab: controllo i branch protetti (e eventualmente toglie la protezione) dai gitlab nembro e azzano###
|
||||
|
||||
#Questo script passa in rassegna tutti i progetti esistenti sui gitlab satellite nembro e azzano per verificare la presenza di branch protetti che potrebbero impedire il corretto funzionamento dei mirror verso tali repo. Se necessario questo script può anche rimuovere la protezione da tali branch.
|
||||
|
||||
#importo file contenente configurazioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsConfig.ps1
|
||||
#importo file contenente funzioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsFunctions.ps1
|
||||
|
||||
#rilevo time per log inizio analisi
|
||||
$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
# avvio stopwatch
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$startProj = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$endProj = 300
|
||||
#conteggio progetti trovati
|
||||
$existingProjects = 0
|
||||
#conteggio progetti trovati
|
||||
$protectedProjects = 0
|
||||
#abilita o disabilita la cancellazione della protezione (1=cancella, 0=toca negot)
|
||||
$deleteProtection = 1
|
||||
#nome file di log
|
||||
$logFile = "GitlabProtectedBranches.log"
|
||||
#nome file old log
|
||||
$oldLogFile = "GitlabProtectedBranches.old"
|
||||
|
||||
#creazione folder di Log se non già esistente
|
||||
CheckLogFolder
|
||||
|
||||
#rotazione vecchio logFile da .log a .old se esiste
|
||||
RotateOldLog
|
||||
|
||||
#scrivo intestazione e inizio analisi
|
||||
WriteLogOutput $logFile 0 "--------------------"
|
||||
Switch ($logLevel) {
|
||||
0 { WriteLogOutput $logFile 0 "LOG SINTETICO GITLAB PROTECTED_BRANCHES" }
|
||||
1 { WriteLogOutput $logFile 0 "LOG ERRORI GITLAB PROTECTED_BRANCHES" }
|
||||
2 { WriteLogOutput $logFile 0 "LOG FULL GITLAB PROTECTED_BRANCHES" }
|
||||
3 { WriteLogOutput $logFile 0 "LOG AMPOLLOSO PROTECTED_BRANCHES" }
|
||||
}
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Percorso log: $logFolder"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Inizio Esecuzione Script: $startTime"
|
||||
|
||||
$gitlabIstance = $destinationAzzano
|
||||
$head = $azzanoHead
|
||||
#ciclo principale for che cicla da startProj a endProj
|
||||
for ($projectCount = $startProj; $projectCount -le $endProj; $projectCount++) {
|
||||
#chiamata api che restituisce informazioni sullo stato dei mirror
|
||||
$callUrl = "https://" + $gitlabIstance + "/api/v4/projects/" + $projectCount + "/protected_branches"
|
||||
try {
|
||||
#parsing della risposta api convertita da json
|
||||
$Response = Invoke-WebRequest -URI $callUrl -Headers $head -ContentType "application/json" -UseBasicParsing
|
||||
$parsedResponse = $Response.Content | ConvertFrom-Json
|
||||
#scrivo il numero del progetto
|
||||
WriteLogOutput $logFile 1 ""
|
||||
WriteLogOutput $logFile 1 "--------------------"
|
||||
WriteLogOutput $logFile 1 "**PROGETTO $projectCount $gitlabIstance**"
|
||||
foreach ($item in $parsedResponse) {
|
||||
WriteLogOutput $logFile 1 "Protected Branch Name: $($item.name) - Allow Force Push: $($item.allow_force_push)"
|
||||
$protectedProjects++
|
||||
if ($deleteProtection -eq 1) {
|
||||
#nuovo URL x delete
|
||||
$callUrlDelete = "https://" + $gitlabIstance + "/api/v4/projects/" + $projectCount + "/protected_branches/" + $item.name
|
||||
#chiamo method DELETE
|
||||
Invoke-WebRequest -Method Delete -URI $callUrlDelete -Headers $head -ContentType "application/json" -UseBasicParsing
|
||||
}
|
||||
}
|
||||
$existingProjects++
|
||||
}
|
||||
#scrivo se trovo un errore durante il try/catch
|
||||
catch {
|
||||
$parsedError = $_ | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 3 ""
|
||||
WriteLogOutput $logFile 3 "--------------------"
|
||||
WriteLogOutput $logFile 3 "**ERRORE NEL PROGETTO $projectCount**"
|
||||
WriteLogOutput $logFile 3 $($parsedError.message)
|
||||
}
|
||||
#fine ciclo dei progetti
|
||||
}
|
||||
# fermo stopwatch e calcolo durata script
|
||||
$mainStopWatch.Stop()
|
||||
$durataScript = $mainStopWatch.Elapsed.TotalSeconds
|
||||
|
||||
#rilevo time per log fine analisi
|
||||
$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#scrivo a video le statistiche
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "PROGETTI ANALIZZATI: $existingProjects"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "PROGETTI CON BRANCH PROTETTI: $protectedProjects"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Fine Esecuzione Script: $endTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Durata Esecuzione Script: $durataScript secondi"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
@@ -0,0 +1,102 @@
|
||||
###Gitlab: creazione branch develop se assente###
|
||||
|
||||
#Questo script passa in rassegna tutti i progetti esistenti sul gitlab aziendale e per ognuno controlla se esiste il branch develop. Se non esiste lo crea.
|
||||
#Necessario per l'esecuzione dello script che crea i tag perchè tali tag vengono creati sul branch develop.
|
||||
|
||||
#importo file contenente configurazioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsConfig.ps1
|
||||
#importo file contenente funzioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsFunctions.ps1
|
||||
|
||||
#rilevo time per log inizio analisi
|
||||
$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
# avvio stopwatch
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$startProj = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$endProj = 250
|
||||
#nome file di log
|
||||
$logFile = "GitlabDevelopCreation.log"
|
||||
#nome file di log old
|
||||
$oldLogFile = "GitlabDevelopCreation.old"
|
||||
|
||||
#creazione folder di Log se non esiste
|
||||
CheckLogFolder
|
||||
|
||||
#rotazione vecchio logFile da .log a .old se esiste
|
||||
RotateOldLog
|
||||
|
||||
#scrivo intestazione e inizio analisi
|
||||
WriteLogOutput $logFile 0 "--------------------"
|
||||
Switch ($logLevel) {
|
||||
0 { WriteLogOutput $logFile 0 "LOG SINTETICO GITLAB DEVELOP CREATION" }
|
||||
1 { WriteLogOutput $logFile 0 "LOG ERRORI GITLAB DEVELOP CREATION" }
|
||||
2 { WriteLogOutput $logFile 0 "LOG FULL GITLAB DEVELOP CREATION" }
|
||||
3 { WriteLogOutput $logFile 0 "LOG AMPOLLOSO GITLAB DEVELOP CREATION" }
|
||||
}
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Percorso log: $logFolder"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Inizio Esecuzione Script: $startTime"
|
||||
|
||||
#ciclo principale for che cicla da startProj a endProj
|
||||
for ($projectCount = $startProj; $projectCount -le $endProj; $projectCount++){
|
||||
#compongo chiamata api per lavorare sui branch
|
||||
$branchUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/repository/branches"
|
||||
try {
|
||||
$branchesResponse = Invoke-WebRequest -URI $branchUrl -Method GET -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
#controllo se tra i branch esistenti non c'è develop, in tal caso procedo alla creazione
|
||||
WriteLogOutput $logFile 1 ""
|
||||
WriteLogOutput $logFile 1 "--------------------"
|
||||
WriteLogOutput $logFile 1 "**PROGETTO $projectCount**"
|
||||
#controllo se tra i branch esistenti c'è master
|
||||
if ($branchesResponse.Content -imatch '{"name":"master",') {
|
||||
#scrivo il body della chiamata con il nome del branch da creare e il ref di partenza
|
||||
$branchBody =
|
||||
@{
|
||||
branch = "develop";
|
||||
ref = "master";
|
||||
}
|
||||
}
|
||||
#controllo se tra i branch esistenti c'è main
|
||||
elseif ($branchesResponse.Content -imatch '{"name":"main",') {
|
||||
#scrivo il body della chiamata con il nome del branch da creare e il ref di partenza
|
||||
$branchBody =
|
||||
@{
|
||||
branch = "develop";
|
||||
ref = "main";
|
||||
}
|
||||
}
|
||||
# converto body in json
|
||||
$branchJSON = $branchBody | ConvertTo-Json
|
||||
#webrequest che effettua la creazione del branch. Serve url, head per auth, body. specificare metodo POST
|
||||
$gitResponse = Invoke-WebRequest -URI $branchUrl -Method POST -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing -Body $branchJSON
|
||||
#parsing della risposta api convertita da json
|
||||
$parsedResponse = $gitResponse.Content | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 1 "Branch Esistente: $($branchBody.ref) - Creato Branch: $($parsedResponse.name)"
|
||||
}
|
||||
#scrivo se trovo un errore durante il try/catch
|
||||
catch {
|
||||
$parsedError = $_ | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 3 ""
|
||||
WriteLogOutput $logFile 3 "--------------------"
|
||||
WriteLogOutput $logFile 3 "**ERRORE NEL PROGETTO $projectCount**"
|
||||
WriteLogOutput $logFile 3 $($parsedError.message)
|
||||
}
|
||||
}
|
||||
#fine ciclo principale
|
||||
|
||||
# fermo stopwatch e calcolo durata script
|
||||
$mainStopWatch.Stop()
|
||||
$durataScript = $mainStopWatch.Elapsed.TotalSeconds
|
||||
|
||||
#rilevo time per log fine analisi
|
||||
$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#scrivo a video le statistiche
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Fine Esecuzione Script: $endTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Durata Esecuzione Script: $durataScript secondi"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
@@ -0,0 +1,90 @@
|
||||
###Gitlab: creazione tag su branch develop###
|
||||
|
||||
#Questo script passa in rassegna tutti i progetti esistenti sul gitlab aziendale e per ognuno crea un tag contenente la data odierna nel branch develop.
|
||||
#(richiede esistenza di branch Develop)
|
||||
#Viene usato per forzare il trigger di tutti i mirror configurati, senza modificare il progetto.
|
||||
|
||||
#importo file contenente configurazioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsConfig.ps1
|
||||
#importo file contenente funzioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsFunctions.ps1
|
||||
|
||||
#rilevo time per log inizio analisi
|
||||
$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
# avvio stopwatch
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$startProj = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$endProj = 250
|
||||
#nome file di log
|
||||
$logFile = "GitlabTagCreation.log"
|
||||
#nome file di log old
|
||||
$oldLogFile = "GitlabTagCreation.old"
|
||||
|
||||
#creazione folder di Log se non esiste
|
||||
CheckLogFolder
|
||||
|
||||
#rotazione vecchio logFile da .log a .old se esiste
|
||||
RotateOldLog
|
||||
|
||||
#scrivo intestazione e inizio analisi
|
||||
WriteLogOutput $logFile 0 "--------------------"
|
||||
Switch ($logLevel) {
|
||||
0 { WriteLogOutput $logFile 0 "LOG SINTETICO GITLAB TAG CREATION" }
|
||||
1 { WriteLogOutput $logFile 0 "LOG ERRORI GITLAB TAG CREATION" }
|
||||
2 { WriteLogOutput $logFile 0 "LOG FULL GITLAB TAG CREATION" }
|
||||
3 { WriteLogOutput $logFile 0 "LOG AMPOLLOSO GITLAB TAG CREATION" }
|
||||
}
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Percorso log: $logFolder"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Inizio Esecuzione Script: $startTime"
|
||||
|
||||
#ciclo principale for che cicla da startProj a endProj
|
||||
for ($projectCount = $startProj; $projectCount -le $endProj; $projectCount++){
|
||||
#compongo chiamata api per lavorare sui tag
|
||||
$tagsUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/repository/tags"
|
||||
try {
|
||||
$date = (Get-Date).toString("yyyy/MM/dd")
|
||||
#scrivo il body della chiamata con il nome del tag da creare e il ref = develop
|
||||
$tagBody =
|
||||
@{
|
||||
tag_name = "AutoSave_" + $date
|
||||
ref = "develop";
|
||||
}
|
||||
# converto body in json
|
||||
$tagJSON = $tagBody | ConvertTo-Json
|
||||
#webrequest che effettua la creazione del tag. Serve url, head per auth, body. specificare metodo POST
|
||||
$gitResponse = Invoke-WebRequest -URI $tagsUrl -Method POST -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing -Body $tagJSON
|
||||
#parsing della risposta api convertita da json
|
||||
$parsedResponse = $gitResponse.Content | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 1 ""
|
||||
WriteLogOutput $logFile 1 "--------------------"
|
||||
WriteLogOutput $logFile 1 "**PROGETTO $projectCount**"
|
||||
WriteLogOutput $logFile 1 "Nuovo Tag: $($parsedResponse.name)"
|
||||
}
|
||||
#scrivo se trovo un errore durante il try/catch
|
||||
catch {
|
||||
$parsedError = $_ | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 3 ""
|
||||
WriteLogOutput $logFile 3 "--------------------"
|
||||
WriteLogOutput $logFile 3 "**ERRORE NEL PROGETTO $projectCount**"
|
||||
WriteLogOutput $logFile 3 $($parsedError.message)
|
||||
}
|
||||
}
|
||||
#fine ciclo principale
|
||||
|
||||
# fermo stopwatch e calcolo durata script
|
||||
$mainStopWatch.Stop()
|
||||
$durataScript = $mainStopWatch.Elapsed.TotalSeconds
|
||||
|
||||
#rilevo time per log fine analisi
|
||||
$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#scrivo a video le statistiche
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Fine Esecuzione Script: $endTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Durata Esecuzione Script: $durataScript secondi"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
@@ -0,0 +1,78 @@
|
||||
###Gitlab: modifica dei namespace dei progetti###
|
||||
|
||||
#Questo script passa in rassegna tutti i progetti esistenti sui gitlab satellite e per ognuno imposta il namespace a "19", laddove 19 è l'ID di "Egalware"
|
||||
#L'uso è una tantum, per riscrivere tutti i path con namespace corretti su gitlab nembro e azzano, per poter ricevere correttamente i mirror dal gitlab principale
|
||||
|
||||
#importo file contenente configurazioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsConfig.ps1
|
||||
#importo file contenente funzioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsFunctions.ps1
|
||||
|
||||
#rilevo time per log inizio analisi
|
||||
$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
# avvio stopwatch
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$startProj = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$endProj = 250
|
||||
#nome file di log
|
||||
$logFile = "EditReposNamespace.log"
|
||||
#nome file di log old
|
||||
$oldLogFile = "EditReposNamespace.old"
|
||||
|
||||
#creazione folder di Log se non esiste
|
||||
CheckLogFolder
|
||||
|
||||
#rotazione vecchio logFile da .log a .old se esiste
|
||||
RotateOldLog
|
||||
|
||||
#scrivo intestazione e inizio analisi
|
||||
WriteLogOutput $logFile 0 "--------------------"
|
||||
Switch ($logLevel) {
|
||||
0 { WriteLogOutput $logFile 0 "LOG SINTETICO MODIFICA REPO" }
|
||||
1 { WriteLogOutput $logFile 0 "LOG ERRORI MODIFICA REPO" }
|
||||
2 { WriteLogOutput $logFile 0 "LOG FULL MODIFICA REPO" }
|
||||
3 { WriteLogOutput $logFile 0 "LOG AMPOLLOSO MODIFICA REPO" }
|
||||
}
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Percorso log: $logFolder"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Inizio Esecuzione Script: $startTime"
|
||||
|
||||
#ciclo principale for che cicla da startProj a endProj
|
||||
for ($projectCount = $startProj; $projectCount -le $endProj; $projectCount++){
|
||||
$callGitlabUrl = "https://" + $destinationAzzano + "/api/v4/projects/" + $projectCount + "/transfer?namespace=19"
|
||||
try {
|
||||
$gitlabResponse = Invoke-WebRequest -URI $callGitlabUrl -Method PUT -Headers $azzanoHead -ContentType "application/json" -UseBasicParsing
|
||||
$parsedGitlabResponse = $gitlabResponse.Content | ConvertFrom-Json
|
||||
#scrivo il numero del progetto nel terminale e su file
|
||||
WriteLogOutput $logFile 1 ""
|
||||
WriteLogOutput $logFile 1 "--------------------"
|
||||
WriteLogOutput $logFile 1 "**PROGETTO $projectCount**"
|
||||
WriteLogOutput $logFile 1 "Nuovo path: $($parsedGitlabResponse.path_with_namespace)"
|
||||
}
|
||||
#scrivo se trovo un errore durante il try/catch
|
||||
catch {
|
||||
$parsedError = $_ | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 3 ""
|
||||
WriteLogOutput $logFile 3 "--------------------"
|
||||
WriteLogOutput $logFile 3 "**ERRORE NEL PROGETTO $projectCount**"
|
||||
WriteLogOutput $logFile 3 $($parsedError.message)
|
||||
}
|
||||
}
|
||||
#fine ciclo principale
|
||||
|
||||
# fermo stopwatch e calcolo durata script
|
||||
$mainStopWatch.Stop()
|
||||
$durataScript = $mainStopWatch.Elapsed.TotalSeconds
|
||||
|
||||
#rilevo time per log fine analisi
|
||||
$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#scrivo a video le statistiche
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Fine Esecuzione Script: $endTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Durata Esecuzione Script: $durataScript secondi"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
@@ -0,0 +1,117 @@
|
||||
###Gitlab_Azzano: controllo lo stato delle pipeline dei singoli progetti###
|
||||
|
||||
#importo file contenente configurazioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsConfig.ps1
|
||||
#importo file contenente funzioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsFunctions.ps1
|
||||
|
||||
#rilevo time per log inizio analisi
|
||||
$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
# avvio stopwatch
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$startProj = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$endProj = 250
|
||||
#conteggio progetti trovati
|
||||
$projectsWithPipeline = 0
|
||||
#conteggio pipeline in errore
|
||||
$pipelineErrorsCount = 0
|
||||
#conteggio pipeline riusciti
|
||||
$pipelineSuccessCount = 0
|
||||
#nome file di log
|
||||
$logFile = "GitlabAzzanoPipeline.log"
|
||||
#nome file di log old
|
||||
$oldLogFile = "GitlabAzzanoPipeline.old"
|
||||
|
||||
#creazione folder di Log se non esiste
|
||||
CheckLogFolder
|
||||
|
||||
#rotazione vecchio logFile da .log a .old se esiste
|
||||
RotateOldLog
|
||||
|
||||
#scrivo intestazione e inizio analisi
|
||||
WriteLogOutput $logFile 0 "--------------------"
|
||||
Switch ($logLevel) {
|
||||
0 { WriteLogOutput $logFile 0 "LOG SINTETICO GITLAB AZZANO PIPELINE" }
|
||||
1 { WriteLogOutput $logFile 0 "LOG ERRORI GITLAB AZZANO PIPELINE" }
|
||||
2 { WriteLogOutput $logFile 0 "LOG FULL GITLAB AZZANO PIPELINE" }
|
||||
3 { WriteLogOutput $logFile 0 "LOG AMPOLLOSO GITLAB AZZANO PIPELINE" }
|
||||
}
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Percorso log: $logFolder"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Inizio Esecuzione Script: $startTime"
|
||||
|
||||
#ciclo principale for che cicla da startProj a endProj
|
||||
for ($projectCount = $startProj; $projectCount -le $endProj; $projectCount++){
|
||||
$callUrl = "https://gitlab-azzano.steamware.net/api/v4/projects/" + $projectCount + "/pipelines/latest"
|
||||
try {
|
||||
$Response = Invoke-WebRequest -URI $callUrl -Headers $azzanoHead -ContentType "application/json" -UseBasicParsing
|
||||
$parsedResponse = $Response.Content | ConvertFrom-Json
|
||||
#scrivo il numero del progetto nel terminale e su file
|
||||
WriteLogOutput $logFile 1 ""
|
||||
WriteLogOutput $logFile 1 "--------------------"
|
||||
WriteLogOutput $logFile 1 "**PROGETTO $projectCount**"
|
||||
foreach ($item in $parsedResponse) {
|
||||
#verifico se i pipeline trovati per il progetto corrente hanno status "success"
|
||||
if ($item.status.Equals("success")) {
|
||||
WriteLogOutput $logFile 2 "Pipeline: $($item.web_url) - Status: $($item.status)"
|
||||
$pipelineSuccessCount++
|
||||
}
|
||||
#i pipeline che non hanno status "success" vengono loggati con relativo errore
|
||||
else {
|
||||
WriteLogOutput $logFile 1 "Pipeline: $($item.web_url) - Status: $($item.status)"
|
||||
$pipelineErrorsCount++
|
||||
}
|
||||
}
|
||||
$projectsWithPipeline++
|
||||
}
|
||||
#scrivo se trovo un errore durante il try/catch
|
||||
catch {
|
||||
$parsedError = $_ | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 3 ""
|
||||
WriteLogOutput $logFile 3 "--------------------"
|
||||
WriteLogOutput $logFile 3 "**ERRORE NEL PROGETTO $projectCount**"
|
||||
WriteLogOutput $logFile 3 $($parsedError.message)
|
||||
}
|
||||
}
|
||||
#fine ciclo principale
|
||||
|
||||
#somma di pipelineSuccess e pipelineErrors
|
||||
$pipelineCount = $pipelineSuccessCount + $pipelineErrorsCount
|
||||
|
||||
#percentuale di pipelineSuccess sul totale
|
||||
$pipelineSuccessPercentage = [math]::Round(($pipelineSuccessCount / $pipelineCount) * 100, 1)
|
||||
|
||||
#percentuale di pipelineErrors sul totale
|
||||
$pipelineErrorsPercentage = [math]::Round(($pipelineErrorsCount / $pipelineCount) * 100, 1)
|
||||
|
||||
# fermo stopwatch e calcolo durata script
|
||||
$mainStopWatch.Stop()
|
||||
$durataScript = $mainStopWatch.Elapsed.TotalSeconds
|
||||
|
||||
#rilevo time per log fine analisi
|
||||
$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#invio a zabbix le metriche rilevate tramite zabbix_sender.exe
|
||||
#WriteLogOutput $logFile 0 ""
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.ProjectsWithPipeline -o $projectsWithPipeline
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.TotalPipeline -o $pipelineCount
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.SuccessPipeline -o $pipelineSuccessCount
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.ErrorsPipeline -o $pipelineErrorsCount
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.SuccessPipelinePercent -o $pipelineSuccessPercentage
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.ErrorsPipelinePercent -o $pipelineErrorsPercentage
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.CheckPipelineDuration -o $durataScript
|
||||
|
||||
#scrivo a video le statistiche
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "PROGETTI CON PIPELINE ATTIVE: $projectsWithPipeline"
|
||||
WriteLogOutput $logFile 0 "PIPELINE TROVATE: $pipelineCount"
|
||||
WriteLogOutput $logFile 0 "PIPELINE RIUSCITE: $pipelineSuccessCount ($pipelineSuccessPercentage%)"
|
||||
WriteLogOutput $logFile 0 "PIPELINE FALLITE: $pipelineErrorsCount ($pipelineErrorsPercentage%)"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Fine Esecuzione Script: $endTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Durata Esecuzione Script: $durataScript secondi"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
@@ -0,0 +1,117 @@
|
||||
###Gitlab-Nembro: controllo lo stato delle pipeline dei singoli progetti###
|
||||
|
||||
#importo file contenente configurazioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsConfig.ps1
|
||||
#importo file contenente funzioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsFunctions.ps1
|
||||
|
||||
#rilevo time per log inizio analisi
|
||||
$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
# avvio stopwatch
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$startProj = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$endProj = 250
|
||||
#conteggio progetti trovati
|
||||
$projectsWithPipeline = 0
|
||||
#conteggio pipeline in errore
|
||||
$pipelineErrorsCount = 0
|
||||
#conteggio pipeline riusciti
|
||||
$pipelineSuccessCount = 0
|
||||
#nome file di log
|
||||
$logFile = "GitlabNembroPipeline.log"
|
||||
#nome file di log old
|
||||
$oldLogFile = "GitlabNembroPipeline.old"
|
||||
|
||||
#creazione folder di Log se non esiste
|
||||
CheckLogFolder
|
||||
|
||||
#rotazione vecchio logFile da .log a .old se esiste
|
||||
RotateOldLog
|
||||
|
||||
#scrivo intestazione e inizio analisi
|
||||
WriteLogOutput $logFile 0 "--------------------"
|
||||
Switch ($logLevel) {
|
||||
0 { WriteLogOutput $logFile 0 "LOG SINTETICO GITLAB NEMBRO PIPELINE" }
|
||||
1 { WriteLogOutput $logFile 0 "LOG ERRORI GITLAB NEMBRO PIPELINE" }
|
||||
2 { WriteLogOutput $logFile 0 "LOG FULL GITLAB NEMBRO PIPELINE" }
|
||||
3 { WriteLogOutput $logFile 0 "LOG AMPOLLOSO GITLAB NEMBRO PIPELINE" }
|
||||
}
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Percorso log: $logFolder"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Inizio Esecuzione Script: $startTime"
|
||||
|
||||
#ciclo principale for che cicla da startProj a endProj
|
||||
for ($projectCount = $startProj; $projectCount -le $endProj; $projectCount++){
|
||||
$callUrl = "https://gitlab-nembro.steamware.net/api/v4/projects/" + $projectCount + "/pipelines/latest"
|
||||
try {
|
||||
$Response = Invoke-WebRequest -URI $callUrl -Headers $nembroHead -ContentType "application/json" -UseBasicParsing
|
||||
$parsedResponse = $Response.Content | ConvertFrom-Json
|
||||
#scrivo il numero del progetto nel terminale e su file
|
||||
WriteLogOutput $logFile 1 ""
|
||||
WriteLogOutput $logFile 1 "--------------------"
|
||||
WriteLogOutput $logFile 1 "**PROGETTO $projectCount**"
|
||||
foreach ($item in $parsedResponse) {
|
||||
#verifico se i pipeline trovati per il progetto corrente hanno status "success"
|
||||
if ($item.status.Equals("success")) {
|
||||
WriteLogOutput $logFile 2 "Pipeline: $($item.web_url) - Status: $($item.status)"
|
||||
$pipelineSuccessCount++
|
||||
}
|
||||
#i pipeline che non hanno status "success" vengono loggati con relativo errore
|
||||
else {
|
||||
WriteLogOutput $logFile 1 "Pipeline: $($item.web_url) - Status: $($item.status)"
|
||||
$pipelineErrorsCount++
|
||||
}
|
||||
}
|
||||
$projectsWithPipeline++
|
||||
}
|
||||
#scrivo se trovo un errore durante il try/catch
|
||||
catch {
|
||||
$parsedError = $_ | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 3 ""
|
||||
WriteLogOutput $logFile 3 "--------------------"
|
||||
WriteLogOutput $logFile 3 "**ERRORE NEL PROGETTO $projectCount**"
|
||||
WriteLogOutput $logFile 3 $($parsedError.message)
|
||||
}
|
||||
}
|
||||
#fine ciclo principale
|
||||
|
||||
#somma di pipelineSuccess e pipelineErrors
|
||||
$pipelineCount = $pipelineSuccessCount + $pipelineErrorsCount
|
||||
|
||||
#percentuale di pipelineSuccess sul totale
|
||||
$pipelineSuccessPercentage = [math]::Round(($pipelineSuccessCount / $pipelineCount) * 100, 1)
|
||||
|
||||
#percentuale di pipelineErrors sul totale
|
||||
$pipelineErrorsPercentage = [math]::Round(($pipelineErrorsCount / $pipelineCount) * 100, 1)
|
||||
|
||||
# fermo stopwatch e calcolo durata script
|
||||
$mainStopWatch.Stop()
|
||||
$durataScript = $mainStopWatch.Elapsed.TotalSeconds
|
||||
|
||||
#rilevo time per log fine analisi
|
||||
$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#invio a zabbix le metriche rilevate tramite zabbix_sender.exe
|
||||
#WriteLogOutput $logFile 0 ""
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.ProjectsWithPipeline -o $projectsWithPipeline
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.TotalPipeline -o $pipelineCount
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.SuccessPipeline -o $pipelineSuccessCount
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.ErrorsPipeline -o $pipelineErrorsCount
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.SuccessPipelinePercent -o $pipelineSuccessPercentage
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.ErrorsPipelinePercent -o $pipelineErrorsPercentage
|
||||
#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.CheckPipelineDuration -o $durataScript
|
||||
|
||||
#scrivo a video le statistiche
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "PROGETTI CON PIPELINE ATTIVE: $projectsWithPipeline"
|
||||
WriteLogOutput $logFile 0 "PIPELINE TROVATE: $pipelineCount"
|
||||
WriteLogOutput $logFile 0 "PIPELINE RIUSCITE: $pipelineSuccessCount ($pipelineSuccessPercentage%)"
|
||||
WriteLogOutput $logFile 0 "PIPELINE FALLITE: $pipelineErrorsCount ($pipelineErrorsPercentage%)"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Fine Esecuzione Script: $endTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Durata Esecuzione Script: $durataScript secondi"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
@@ -0,0 +1,120 @@
|
||||
###Gitlab: controllo lo stato delle pipeline dei singoli progetti###
|
||||
|
||||
#Questo script passa in rassegna tutti i progetti esistenti sul gitlab aziendale e per ognuno verifica la presenza e lo stato delle pipeline.
|
||||
#Poi invia i dati rilevati a zabbix per avere lo storico dello stato delle pipelines.
|
||||
|
||||
#importo file contenente configurazioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsConfig.ps1
|
||||
#importo file contenente funzioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsFunctions.ps1
|
||||
|
||||
#rilevo time per log inizio analisi
|
||||
$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
# avvio stopwatch
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$startProj = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$endProj = 250
|
||||
#conteggio progetti trovati
|
||||
$projectsWithPipeline = 0
|
||||
#conteggio pipeline in errore
|
||||
$pipelineErrorsCount = 0
|
||||
#conteggio pipeline riusciti
|
||||
$pipelineSuccessCount = 0
|
||||
#nome file di log
|
||||
$logFile = "GitlabPipeline.log"
|
||||
#nome file di log old
|
||||
$oldLogFile = "GitlabPipeline.old"
|
||||
|
||||
#creazione folder di Log se non esiste
|
||||
CheckLogFolder
|
||||
|
||||
#rotazione vecchio logFile da .log a .old se esiste
|
||||
RotateOldLog
|
||||
|
||||
#scrivo intestazione e inizio analisi
|
||||
WriteLogOutput $logFile 0 "--------------------"
|
||||
Switch ($logLevel) {
|
||||
0 { WriteLogOutput $logFile 0 "LOG SINTETICO GITLAB PIPELINE" }
|
||||
1 { WriteLogOutput $logFile 0 "LOG ERRORI GITLAB PIPELINE" }
|
||||
2 { WriteLogOutput $logFile 0 "LOG FULL GITLAB PIPELINE" }
|
||||
3 { WriteLogOutput $logFile 0 "LOG AMPOLLOSO GITLAB PIPELINE" }
|
||||
}
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Percorso log: $logFolder"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Inizio Esecuzione Script: $startTime"
|
||||
|
||||
#ciclo principale for che cicla da startProj a endProj
|
||||
for ($projectCount = $startProj; $projectCount -le $endProj; $projectCount++){
|
||||
$callUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/pipelines/latest"
|
||||
try {
|
||||
$Response = Invoke-WebRequest -URI $callUrl -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
$parsedResponse = $Response.Content | ConvertFrom-Json
|
||||
#scrivo il numero del progetto nel terminale e su file
|
||||
WriteLogOutput $logFile 1 ""
|
||||
WriteLogOutput $logFile 1 "--------------------"
|
||||
WriteLogOutput $logFile 1 "**PROGETTO $projectCount**"
|
||||
foreach ($item in $parsedResponse) {
|
||||
#verifico se i pipeline trovati per il progetto corrente hanno status "success"
|
||||
if ($item.status.Equals("success")) {
|
||||
WriteLogOutput $logFile 2 "Pipeline: $($item.web_url) - Status: $($item.status)"
|
||||
$pipelineSuccessCount++
|
||||
}
|
||||
#i pipeline che non hanno status "success" vengono loggati con relativo errore
|
||||
else {
|
||||
WriteLogOutput $logFile 1 "Pipeline: $($item.web_url) - Status: $($item.status)"
|
||||
$pipelineErrorsCount++
|
||||
}
|
||||
}
|
||||
$projectsWithPipeline++
|
||||
}
|
||||
#scrivo se trovo un errore durante il try/catch
|
||||
catch {
|
||||
$parsedError = $_ | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 3 ""
|
||||
WriteLogOutput $logFile 3 "--------------------"
|
||||
WriteLogOutput $logFile 3 "**ERRORE NEL PROGETTO $projectCount**"
|
||||
WriteLogOutput $logFile 3 $($parsedError.message)
|
||||
}
|
||||
}
|
||||
#fine ciclo principale
|
||||
|
||||
#somma di pipelineSuccess e pipelineErrors
|
||||
$pipelineCount = $pipelineSuccessCount + $pipelineErrorsCount
|
||||
|
||||
#percentuale di pipelineSuccess sul totale
|
||||
$pipelineSuccessPercentage = [math]::Round(($pipelineSuccessCount / $pipelineCount) * 100, 1)
|
||||
|
||||
#percentuale di pipelineErrors sul totale
|
||||
$pipelineErrorsPercentage = [math]::Round(($pipelineErrorsCount / $pipelineCount) * 100, 1)
|
||||
|
||||
# fermo stopwatch e calcolo durata script
|
||||
$mainStopWatch.Stop()
|
||||
$durataScript = $mainStopWatch.Elapsed.TotalSeconds
|
||||
|
||||
#rilevo time per log fine analisi
|
||||
$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#invio a zabbix le metriche rilevate tramite zabbix_sender.exe
|
||||
WriteLogOutput $logFile 0 ""
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.ProjectsWithPipeline -o $projectsWithPipeline
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.TotalPipeline -o $pipelineCount
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.SuccessPipeline -o $pipelineSuccessCount
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.ErrorsPipeline -o $pipelineErrorsCount
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.SuccessPipelinePercent -o $pipelineSuccessPercentage
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.ErrorsPipelinePercent -o $pipelineErrorsPercentage
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gitlab.CheckPipelineDuration -o $durataScript
|
||||
|
||||
#scrivo a video le statistiche
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "PROGETTI CON PIPELINE ATTIVE: $projectsWithPipeline"
|
||||
WriteLogOutput $logFile 0 "PIPELINE TROVATE: $pipelineCount"
|
||||
WriteLogOutput $logFile 0 "PIPELINE RIUSCITE: $pipelineSuccessCount ($pipelineSuccessPercentage%)"
|
||||
WriteLogOutput $logFile 0 "PIPELINE FALLITE: $pipelineErrorsCount ($pipelineErrorsPercentage%)"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Fine Esecuzione Script: $endTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Durata Esecuzione Script: $durataScript secondi"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
@@ -0,0 +1,103 @@
|
||||
###Gitlab: Creazione repository su azzano e nembro###
|
||||
|
||||
#Questo script passa in rassegna tutti i progetti esistenti sul gitlab aziendale e per ognuno crea un repository con indirizzo semplice /egalware/nomeProgetto.git
|
||||
#su gitlab azzano e gitlab nembro. Serve a creare i contenitori "vuoti" verso cui poi va creato il mirror da gitlab aziendale.
|
||||
|
||||
#importo file contenente configurazioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsConfig.ps1
|
||||
#importo file contenente funzioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsFunctions.ps1
|
||||
|
||||
#rilevo time per log inizio analisi
|
||||
$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
# avvio stopwatch
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$startProj = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$endProj = 300
|
||||
#nome file di log
|
||||
$logFile = "AzzanoNembroReposCreation.log"
|
||||
#nome file di log old
|
||||
$oldLogFile = "AzzanoNembroReposCreation.old"
|
||||
|
||||
#creazione folder di Log se non esiste
|
||||
CheckLogFolder
|
||||
|
||||
#rotazione vecchio logFile da .log a .old se esiste
|
||||
RotateOldLog
|
||||
|
||||
#specifica quale installazione di gitlab va controllata
|
||||
#$remote = "Nembro"
|
||||
$remote = "Azzano"
|
||||
|
||||
if ($remote -eq "Nembro"){
|
||||
$gitlabIstance = $destinationNembro
|
||||
$destinationHead = $nembroHead
|
||||
}
|
||||
if ($remote -eq "Azzano"){
|
||||
$gitlabIstance = $destinationAzzano
|
||||
$destinationHead = $azzanoHead
|
||||
}
|
||||
|
||||
#scrivo intestazione e inizio analisi
|
||||
WriteLogOutput $logFile 0 "--------------------"
|
||||
Switch ($logLevel) {
|
||||
0 { WriteLogOutput $logFile 0 "LOG SINTETICO CREAZIONE REPO" }
|
||||
1 { WriteLogOutput $logFile 0 "LOG ERRORI CREAZIONE REPO" }
|
||||
2 { WriteLogOutput $logFile 0 "LOG FULL CREAZIONE REPO" }
|
||||
3 { WriteLogOutput $logFile 0 "LOG AMPOLLOSO CREAZIONE REPO" }
|
||||
}
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Percorso log: $logFolder"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Inizio Esecuzione Script: $startTime"
|
||||
|
||||
#ciclo principale for che cicla da startProj a endProj
|
||||
for ($projectCount = $startProj; $projectCount -le $endProj; $projectCount++){
|
||||
$callGitlabUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount
|
||||
try {
|
||||
#scrivo il numero del progetto nel terminale e su file
|
||||
WriteLogOutput $logFile 1 ""
|
||||
WriteLogOutput $logFile 1 "--------------------"
|
||||
WriteLogOutput $logFile 1 "**PROGETTO $projectCount**"
|
||||
$gitlabResponse = Invoke-WebRequest -URI $callGitlabUrl -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
$parsedGitlabResponse = $gitlabResponse.Content | ConvertFrom-Json
|
||||
#dichiaro un body da convertire in JSON con il nome del repo da creare
|
||||
$body =
|
||||
@{
|
||||
name = $($parsedGitlabResponse.path);
|
||||
#name = $($parsedGitlabResponse.name);
|
||||
#namespace_id 19 è il gruppo Egalware
|
||||
namespace_id = 19
|
||||
}
|
||||
#scrivo il nome del progetto nel terminale e su file
|
||||
WriteLogOutput $logFile 1 "Gitlab Project Name: $($parsedGitlabResponse.path)"
|
||||
$bodyJSON = $body | ConvertTo-Json
|
||||
#chiamata creazione
|
||||
$callUrl = "https://" + $gitlabIstance + "/api/v4/projects/"
|
||||
$Response = Invoke-WebRequest -URI $callUrl -Method POST -Headers $destinationHead -ContentType "application/json" -Body $bodyJSON
|
||||
$parsedResponse = $Response.Content | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 1 "Progetto creato su $callUrl : $($parsedResponse.path_with_namespace)"
|
||||
}
|
||||
#scrivo se trovo un errore durante il try/catch
|
||||
catch {
|
||||
$parsedError = $_ | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 3 "Errore: $($parsedError.message)"
|
||||
}
|
||||
}
|
||||
#fine ciclo principale
|
||||
|
||||
# fermo stopwatch e calcolo durata script
|
||||
$mainStopWatch.Stop()
|
||||
$durataScript = $mainStopWatch.Elapsed.TotalSeconds
|
||||
|
||||
#rilevo time per log fine analisi
|
||||
$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#scrivo a video le statistiche
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Fine Esecuzione Script: $endTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Durata Esecuzione Script: $durataScript secondi"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
@@ -0,0 +1,137 @@
|
||||
###Gitlab: Creazione repository su gitea###
|
||||
|
||||
#Questo script passa in rassegna tutti i progetti esistenti sul gitlab aziendale e per ognuno crea un repository con indirizzo semplice /egalware/nomeProgetto.git su gitea.
|
||||
|
||||
#importo file contenente configurazioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsConfig.ps1
|
||||
#importo file contenente funzioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsFunctions.ps1
|
||||
|
||||
#rilevo time per log inizio analisi
|
||||
$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
# avvio stopwatch
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$startProj = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$endProj = 300
|
||||
#nome file di log
|
||||
$logFile = "GiteaReposCreation.log"
|
||||
#nome file di log old
|
||||
$oldLogFile = "GiteaReposCreation.old"
|
||||
|
||||
#creazione folder di Log se non esiste
|
||||
CheckLogFolder
|
||||
|
||||
#rotazione vecchio logFile da .log a .old se esiste
|
||||
RotateOldLog
|
||||
|
||||
#gitea di destinazione
|
||||
#$target = "steamware"
|
||||
#$target = "nembro"
|
||||
$target = "azzano"
|
||||
|
||||
if ($target -eq "steamware"){
|
||||
#destinazione mirror per gitea Steamw
|
||||
$giteaDestination = $giteaSteamw
|
||||
#nome utente gitea Steamw che effettua i mirror push
|
||||
$giteaUser = $giteaSteamwUser
|
||||
#autenticazione replica gitea Steamw
|
||||
$giteaPass = $giteaSteamwPass
|
||||
#access token per autenticazione gitea Steamw da profilo replica
|
||||
$giteaHead = $giteaSteamwHead
|
||||
}
|
||||
if ($target -eq "nembro") {
|
||||
#destinazione mirror per gitea nembro
|
||||
$giteaDestination = $giteaNembro
|
||||
#nome utente gitea nembro che effettua i mirror push
|
||||
$giteaUser = $giteaNembroUser
|
||||
#autenticazione replica gitea nembro
|
||||
$giteaPass = $giteaNembroPass
|
||||
#access token per autenticazione gitea nembro da profilo replica
|
||||
$giteaHead = $giteaNembroHead
|
||||
}
|
||||
if ($target -eq "azzano") {
|
||||
#destinazione mirror per gitea azzano
|
||||
$giteaDestination = $giteaAzzano
|
||||
#nome utente gitea azzano che effettua i mirror push
|
||||
$giteaUser = $giteaAzzanoUser
|
||||
#autenticazione replica gitea nemazzanobro
|
||||
$giteaPass = $giteaAzzanoPass
|
||||
#access token per autenticazione gitea azzano da profilo replica
|
||||
$giteaHead = $giteaAzzanoHead
|
||||
}
|
||||
|
||||
#scrivo intestazione e inizio analisi
|
||||
WriteLogOutput $logFile 0 "--------------------"
|
||||
Switch ($logLevel) {
|
||||
0 { WriteLogOutput $logFile 0 "LOG SINTETICO GITEA" }
|
||||
1 { WriteLogOutput $logFile 0 "LOG ERRORI GITEA" }
|
||||
2 { WriteLogOutput $logFile 0 "LOG FULL GITEA" }
|
||||
3 { WriteLogOutput $logFile 0 "LOG AMPOLLOSO GITEA" }
|
||||
}
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Percorso log: $logFolder"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Inizio Esecuzione Script: $startTime"
|
||||
|
||||
#ciclo principale for che cicla da startProj a endProj
|
||||
for ($projectCount = $startProj; $projectCount -le $endProj; $projectCount++){
|
||||
$callGitlabUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount
|
||||
try {
|
||||
$gitlabResponse = Invoke-WebRequest -URI $callGitlabUrl -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
$parsedGitlabResponse = $gitlabResponse.Content | ConvertFrom-Json
|
||||
#scrivo il numero del progetto nel terminale e su file
|
||||
WriteLogOutput $logFile 1 ""
|
||||
WriteLogOutput $logFile 1 "--------------------"
|
||||
WriteLogOutput $logFile 1 "**PROGETTO $projectCount**"
|
||||
foreach ($gitlabItem in $parsedGitlabResponse) {
|
||||
WriteLogOutput $logFile 1 "Gitlab Project Name: $($gitlabItem.name)"
|
||||
$callGiteaUrl = "http://" + $giteaDestination + "/api/v1/orgs/Egalware/repos"
|
||||
#dichiaro un body da convertire in JSON con il nome del repo da creare (prendo path o name a seconda delle necessità)
|
||||
$giteaBody =
|
||||
@{
|
||||
name = $($gitlabItem.path);
|
||||
#name = $($gitlabItem.name);
|
||||
}
|
||||
# Converting my hash to json format
|
||||
$GiteaJSON = $giteaBody | ConvertTo-Json
|
||||
try {
|
||||
$giteaResponse = Invoke-WebRequest -URI $callGiteaUrl -Method POST -Headers $giteaHead -ContentType "application/json" -Body $GiteaJSON
|
||||
$parsedGiteaResponse = $giteaResponse.Content | ConvertFrom-Json
|
||||
foreach ($giteaItem in $parsedGiteaResponse) {
|
||||
WriteLogOutput $logFile 1 "Gitea New Project Name: $($giteaItem.name)"
|
||||
WriteLogOutput $logFile 1 "Status: $($giteaResponse.StatusDescription)"
|
||||
WriteLogOutput $logFile 1 "When: $($giteaItem.created_at)"
|
||||
}
|
||||
}
|
||||
catch {
|
||||
$parsedError = $_ | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 3 $($parsedError.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
#scrivo se trovo un errore durante il try/catch
|
||||
catch {
|
||||
$parsedError = $_ | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 3 ""
|
||||
WriteLogOutput $logFile 3 "--------------------"
|
||||
WriteLogOutput $logFile 3 "**ERRORE NEL PROGETTO $projectCount**"
|
||||
WriteLogOutput $logFile 3 $($parsedError.message)
|
||||
}
|
||||
}
|
||||
#fine ciclo principale
|
||||
|
||||
# fermo stopwatch e calcolo durata script
|
||||
$mainStopWatch.Stop()
|
||||
$durataScript = $mainStopWatch.Elapsed.TotalSeconds
|
||||
|
||||
#rilevo time per log fine analisi
|
||||
$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#scrivo a video le statistiche
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Fine Esecuzione Script: $endTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Durata Esecuzione Script: $durataScript secondi"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
@@ -0,0 +1,99 @@
|
||||
###Gitlab: Creazione repository su gitea###
|
||||
|
||||
#Questo script passa in rassegna tutti i progetti esistenti sul gitlab aziendale e per ognuno crea un repository con indirizzo semplice /egalware/nomeProgetto.git su gogs.
|
||||
|
||||
#importo file contenente configurazioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsConfig.ps1
|
||||
#importo file contenente funzioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsFunctions.ps1
|
||||
|
||||
#rilevo time per log inizio analisi
|
||||
$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
# avvio stopwatch
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
#contatore ciclo do while
|
||||
$startProj = 1
|
||||
#numero massimo di progetti da analizzare
|
||||
$endProj = 300
|
||||
#nome file di log
|
||||
$logFile = "GogsReposCreation.log"
|
||||
#nome file di log old
|
||||
$oldLogFile = "GogsReposCreation.old"
|
||||
|
||||
#creazione folder di Log se non esiste
|
||||
CheckLogFolder
|
||||
|
||||
#rotazione vecchio logFile da .log a .old se esiste
|
||||
RotateOldLog
|
||||
|
||||
#scrivo intestazione e inizio analisi
|
||||
WriteLogOutput $logFile 0 "--------------------"
|
||||
Switch ($logLevel) {
|
||||
0 { WriteLogOutput $logFile 0 "LOG SINTETICO GOGS" }
|
||||
1 { WriteLogOutput $logFile 0 "LOG ERRORI GOGS" }
|
||||
2 { WriteLogOutput $logFile 0 "LOG FULL GOGS" }
|
||||
3 { WriteLogOutput $logFile 0 "LOG AMPOLLOSO GOGS" }
|
||||
}
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Percorso log: $logFolder"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Inizio Esecuzione Script: $startTime"
|
||||
|
||||
#ciclo principale for che cicla da startProj a endProj
|
||||
for ($projectCount = $startProj; $projectCount -le $endProj; $projectCount++){
|
||||
$callGitlabUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount
|
||||
try {
|
||||
$gitlabResponse = Invoke-WebRequest -URI $callGitlabUrl -Headers $gitlabHead -ContentType "application/json" -UseBasicParsing
|
||||
$parsedGitlabResponse = $gitlabResponse.Content | ConvertFrom-Json
|
||||
#scrivo il numero del progetto nel terminale e su file
|
||||
WriteLogOutput $logFile 1 ""
|
||||
WriteLogOutput $logFile 1 "--------------------"
|
||||
WriteLogOutput $logFile 1 "**PROGETTO $projectCount**"
|
||||
foreach ($gitlabItem in $parsedGitlabResponse) {
|
||||
WriteLogOutput $logFile 1 "Gitlab Project Name: $($gitlabItem.name)"
|
||||
$callGogsUrl = "https://gogs.steamware.net/api/v1/admin/users/Egalware/repos"
|
||||
#dichiaro un body da convertire in JSON con il nome del repo da creare
|
||||
$gogsBody =
|
||||
@{
|
||||
name = $($gitlabItem.path);
|
||||
#name = $($gitlabItem.name);
|
||||
}
|
||||
# Converting my hash to json format
|
||||
$gogsJSON = $gogsBody | ConvertTo-Json
|
||||
try {
|
||||
$gogsResponse = Invoke-WebRequest -URI $callGogsUrl -Method POST -Headers $gogsHead -ContentType "application/json" -Body $gogsJSON
|
||||
$parsedGogsResponse = $GogsResponse.Content | ConvertFrom-Json
|
||||
foreach ($GogsItem in $parsedGogsResponse) {
|
||||
WriteLogOutput $logFile 1 "Gogs New Project Name: $($gogsItem.name)"
|
||||
}
|
||||
}
|
||||
catch {
|
||||
$parsedError = $_ | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 3 $($parsedError.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
#scrivo se trovo un errore durante il try/catch
|
||||
catch {
|
||||
$parsedError = $_ | ConvertFrom-Json
|
||||
WriteLogOutput $logFile 3 ""
|
||||
WriteLogOutput $logFile 3 "--------------------"
|
||||
WriteLogOutput $logFile 3 "**ERRORE NEL PROGETTO $projectCount**"
|
||||
WriteLogOutput $logFile 3 $($parsedError.message)
|
||||
}
|
||||
}
|
||||
#fine ciclo principale
|
||||
|
||||
# fermo stopwatch e calcolo durata script
|
||||
$mainStopWatch.Stop()
|
||||
$durataScript = $mainStopWatch.Elapsed.TotalSeconds
|
||||
|
||||
#rilevo time per log fine analisi
|
||||
$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#scrivo a video le statistiche
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Fine Esecuzione Script: $endTime"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
WriteLogOutput $logFile 0 "Durata Esecuzione Script: $durataScript secondi"
|
||||
WriteLogOutput $logFile 0 ""
|
||||
@@ -0,0 +1,77 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Aggiorna il livello di notifica GitLab per un range di utenti
|
||||
e logga tutto in C:\Steamware\Logs\Gitlab\notificationLevelChange.log
|
||||
#>
|
||||
|
||||
# importa configurazioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsConfig.ps1
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsFunctions.ps1
|
||||
|
||||
$GitlabUrl = "https://gitlab.steamware.net"
|
||||
$PrivateToken = $tokenGitlab
|
||||
|
||||
# Range utenti da aggiornare (modificabile)
|
||||
$StartId = 1
|
||||
$EndId = 50
|
||||
|
||||
# Livello notifiche da impostare (modificabile)
|
||||
$NewLevel = "mention" # altri valori: disabled, participating, watch, global, custom
|
||||
|
||||
# Percorso log
|
||||
$LogDir = "C:\Steamware\Logs\Gitlab"
|
||||
$LogFile = Join-Path $LogDir "notificationLevelChange.log"
|
||||
|
||||
# Crea cartella log se non esiste
|
||||
if (-not (Test-Path $LogDir)) {
|
||||
New-Item -Path $LogDir -ItemType Directory -Force | Out-Null
|
||||
}
|
||||
|
||||
# Header base
|
||||
$baseHeaders = @{
|
||||
"PRIVATE-TOKEN" = $PrivateToken
|
||||
"Content-Type" = "application/json"
|
||||
}
|
||||
|
||||
# Corpo JSON della richiesta
|
||||
$body = @{ level = $NewLevel } | ConvertTo-Json
|
||||
|
||||
# Inizializza log
|
||||
"INFO [$((Get-Date).ToString('o'))] Starting notification level update for IDs $StartId-$EndId (level=$NewLevel)" |
|
||||
Out-File -FilePath $LogFile -Encoding UTF8
|
||||
|
||||
# Ciclo utenti
|
||||
for ($id = $StartId; $id -le $EndId; $id++) {
|
||||
|
||||
$separator = "----- USER $id -----"
|
||||
$url = "$GitlabUrl/api/v4/notification_settings"
|
||||
|
||||
# Clona headers e aggiunge Sudo per modificare altri utenti
|
||||
$headers = @{}
|
||||
foreach ($k in $baseHeaders.Keys) { $headers[$k] = $baseHeaders[$k] }
|
||||
$headers["Sudo"] = "$id"
|
||||
|
||||
try {
|
||||
$response = Invoke-WebRequest `
|
||||
-Method PUT `
|
||||
-Uri $url `
|
||||
-Headers $headers `
|
||||
-Body $body `
|
||||
-ErrorAction Stop
|
||||
|
||||
"$separator`nINFO [$((Get-Date).ToString('o'))] UPDATED id=$id level=$NewLevel status=$($response.StatusCode)" |
|
||||
Out-File -FilePath $LogFile -Encoding UTF8 -Append
|
||||
}
|
||||
catch {
|
||||
$msg = $_.Exception.Message -replace "`r?`n"," "
|
||||
"$separator`nERROR [$((Get-Date).ToString('o'))] FAILED id=$id message=$msg" |
|
||||
Out-File -FilePath $LogFile -Encoding UTF8 -Append
|
||||
}
|
||||
|
||||
Start-Sleep -Milliseconds 150
|
||||
}
|
||||
|
||||
"INFO [$((Get-Date).ToString('o'))] Completed." |
|
||||
Out-File -FilePath $LogFile -Encoding UTF8 -Append
|
||||
|
||||
Write-Host "Fatto. Log salvato in $LogFile"
|
||||
@@ -0,0 +1,85 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Recupera utenti GitLab per ID 1-100 e scrive output in C:\Steamware\Logs\Gitlab\gitlab_users_1-100.log
|
||||
#>
|
||||
|
||||
#importo file contenente configurazioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsConfig.ps1
|
||||
#importo file contenente funzioni
|
||||
. .\ApiGit\ApiGitResources\ApiScriptsFunctions.ps1
|
||||
|
||||
$GitlabUrl = "gitlab.steamware.net"
|
||||
$PrivateToken = $tokenGitlab
|
||||
|
||||
# Configurazione
|
||||
$StartId = 1
|
||||
$EndId = 50
|
||||
$LogDir = "C:\Steamware\Logs\Gitlab"
|
||||
$LogFile = Join-Path -Path $LogDir -ChildPath "GitlabUsers.log"
|
||||
|
||||
# Crea cartella log se non esiste
|
||||
try {
|
||||
if (-not (Test-Path -Path $LogDir)) {
|
||||
New-Item -Path $LogDir -ItemType Directory -Force | Out-Null
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Error "Impossibile creare la cartella di log $LogDir. Errore: $($_.Exception.Message)"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Header autenticazione
|
||||
$baseUrl = $GitlabUrl.TrimEnd('/')
|
||||
$headers = @{ "PRIVATE-TOKEN" = $PrivateToken }
|
||||
|
||||
# Inizializza file di log (sovrascrive se esiste)
|
||||
$startLine = "INFO [{0}] Starting GitLab users retrieval for IDs {1}-{2}" -f (Get-Date -Format o), $StartId, $EndId
|
||||
$startLine | Out-File -FilePath $LogFile -Encoding UTF8
|
||||
|
||||
$retrieved = 0
|
||||
$errors = 0
|
||||
|
||||
# inizializza contatore per numeratore
|
||||
$counter = 1
|
||||
$total = $EndId - $StartId + 1
|
||||
|
||||
for ($id = $StartId; $id -le $EndId; $id++) {
|
||||
$url = "$baseUrl/api/v4/users/$id"
|
||||
# crea prefisso numerato e separatore (es. --- 001/100 ---)
|
||||
$num = "{0:D3}" -f $counter
|
||||
$separator = "----- $num/$total -----"
|
||||
|
||||
try {
|
||||
$user = Invoke-RestMethod -Uri $url -Headers $headers -Method Get -ErrorAction Stop
|
||||
$json = $user | ConvertTo-Json -Depth 10 -Compress
|
||||
$line = "{0} `nINFO [{1}] USER_FOUND id={2} data={3}" -f $separator, (Get-Date -Format o), $id, $json
|
||||
$line | Out-File -FilePath $LogFile -Encoding UTF8 -Append
|
||||
$retrieved++
|
||||
}
|
||||
catch {
|
||||
$status = "unknown"
|
||||
try {
|
||||
if ($_.Exception.Response -ne $null) {
|
||||
$status = $_.Exception.Response.StatusCode.value__
|
||||
}
|
||||
} catch { $status = "unknown" }
|
||||
|
||||
if ($status -eq 404) {
|
||||
$line = "{0} `nWARN [{1}] USER_NOT_FOUND id={2} status=404 message=Not Found" -f $separator, (Get-Date -Format o), $id
|
||||
}
|
||||
else {
|
||||
$msg = $_.Exception.Message -replace "`r?`n", " "
|
||||
$line = "{0} `nERROR [{1}] USER_ERROR id={2} status={3} message={4}" -f $separator, (Get-Date -Format o), $id, $status, $msg
|
||||
}
|
||||
$line | Out-File -FilePath $LogFile -Encoding UTF8 -Append
|
||||
$errors++
|
||||
}
|
||||
|
||||
$counter++
|
||||
Start-Sleep -Milliseconds 200
|
||||
}
|
||||
|
||||
$endLine = "INFO [{0}] Completed. Retrieved={1} Errors={2}" -f (Get-Date -Format o), $retrieved, $errors
|
||||
$endLine | Out-File -FilePath $LogFile -Encoding UTF8 -Append
|
||||
|
||||
Write-Host "Fatto. Log salvato in $LogFile. Utenti recuperati: $retrieved. Errori: $errors."
|
||||
@@ -0,0 +1,175 @@
|
||||
### Esegue setup di BeamWall da repo Artifacts ###
|
||||
|
||||
#inizializzo variabili vuote
|
||||
$ChosenBit = ""
|
||||
$ChosenDll = ""
|
||||
$ChosenDllD = ""
|
||||
$SelBranch = ""
|
||||
$SelArch = ""
|
||||
|
||||
#Definisco path truenas di origine
|
||||
$Artifacts = '\\truenas\Artifacts'
|
||||
|
||||
#Definisco path test sottocartelle EgtBEAMWALL
|
||||
$TestProgBWFolder = 'c:\EgtTestProg\EgtBEAMWALL'
|
||||
$TestDataBWFolder = 'c:\EgtTestData\EgtBEAMWALL'
|
||||
|
||||
#Chiedo all'utente che branch desidera installare
|
||||
function Show-MenuA
|
||||
{
|
||||
param (
|
||||
[string]$Title = 'Seleziona Branch BeamWall'
|
||||
)
|
||||
Clear-Host
|
||||
Write-Host ""
|
||||
Write-Host "============= $Title ============="
|
||||
Write-Host ""
|
||||
Write-Host "1: Premi '1' per branch Develop"
|
||||
Write-Host "2: Premi '2' per branch Master"
|
||||
Write-Host "q: Premi 'q' tornare al menù principale"
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
Show-MenuA
|
||||
|
||||
#Salvo la selezione dell'utente
|
||||
$MachineSelect = Read-Host 'Seleziona Branch BeamWall'
|
||||
switch ($MachineSelect)
|
||||
{
|
||||
'1' {
|
||||
$SelBranch = 'develop'
|
||||
}
|
||||
'2' {
|
||||
$SelBranch = 'master'
|
||||
}
|
||||
'q' {
|
||||
Powershell.exe -executionpolicy remotesigned -File .\CLI\EgtScriptsManager.ps1
|
||||
}
|
||||
}
|
||||
|
||||
#Chiedo all'utente se vuole 32 bit o 64 bit
|
||||
function Show-MenuB
|
||||
{
|
||||
param (
|
||||
[string]$Title = 'Seleziona architettura BeamWall'
|
||||
)
|
||||
Clear-Host
|
||||
Write-Host ""
|
||||
Write-Host "============= $Title ============="
|
||||
Write-Host ""
|
||||
Write-Host "1: Premi '1' per x86"
|
||||
Write-Host "2: Premi '2' per x64"
|
||||
Write-Host "q: Premi 'q' tornare al menù principale"
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
Show-MenuB
|
||||
|
||||
#Salvo la selezione dell'utente 32 bit o 64 bit
|
||||
$BitSelect = Read-Host "Seleziona architettura BeamWall"
|
||||
switch ($BitSelect)
|
||||
{
|
||||
'1' {
|
||||
$SelArch = 'x86'
|
||||
}
|
||||
'2' {
|
||||
$SelArch = 'x64'
|
||||
}
|
||||
'q' {
|
||||
Powershell.exe -executionpolicy remotesigned -File .\CLI\EgtScriptsManager.ps1
|
||||
}
|
||||
}
|
||||
|
||||
#Switch fra 32 bit o 64 bit in base alla richiesta dell'utente
|
||||
if($SelArch -eq 'x86'){
|
||||
$ChosenBit = '32'
|
||||
$ChosenDll = 'Dll32'
|
||||
$ChosenDllD = 'DllD32'
|
||||
}
|
||||
else {
|
||||
$ChosenBit = '64'
|
||||
$ChosenDll = 'Dll64'
|
||||
$ChosenDllD = 'DllD64'
|
||||
}
|
||||
|
||||
Write-Output ""
|
||||
Write-Output "Installing Test EgtBeamWall. Branch: $SelBranch Architecture: $ChosenBit bit"
|
||||
Write-Output ""
|
||||
Start-Sleep -seconds 5
|
||||
|
||||
#Pulisco cartella EgtTestProg\EgtBEAMWALL se già esistente, poi la creo
|
||||
if (Test-Path -Path $TestProgBWFolder) {
|
||||
"Prog esiste!"
|
||||
Remove-Item -Recurse $TestProgBWFolder\*.*
|
||||
} else {
|
||||
new-item $TestProgBWFolder -itemtype directory
|
||||
}
|
||||
|
||||
#Pulisco cartella EgtTestData\EgtBEAMWALL se già esistente, poi la creo
|
||||
if (Test-Path -Path $TestDataBWFolder) {
|
||||
"Data esiste!"
|
||||
Remove-Item -Recurse $TestDataBWFolder\*.*
|
||||
} else {
|
||||
new-item $TestDataBWFolder -itemtype directory
|
||||
}
|
||||
|
||||
#Pulisco cartella EgtTestData\EgtBEAMWALL\Temp se già esistente, poi la creo
|
||||
if (Test-Path -Path $TestDataBWFolder\Temp) {
|
||||
"Temp esiste!"
|
||||
Remove-Item -Recurse $TestDataBWFolder\Temp\*.*
|
||||
} else {
|
||||
new-item $TestDataBWFolder\Temp -itemtype directory
|
||||
}
|
||||
|
||||
#Pulisco cartella EgtTestData\EgtBEAMWALL\Macro se già esistente, poi la creo
|
||||
if (Test-Path -Path $TestDataBWFolder\Macro) {
|
||||
"Macro esiste!"
|
||||
Remove-Item -Recurse $TestDataBWFolder\Macro\*.*
|
||||
} else {
|
||||
new-item $TestDataBWFolder\Macro -itemtype directory
|
||||
}
|
||||
|
||||
#Pulisco cartella EgtTestData\EgtBEAMWALL\Config se già esistente, poi la creo
|
||||
if (Test-Path -Path $TestDataBWFolder\Config) {
|
||||
"Config esiste!"
|
||||
Remove-Item -Recurse $TestDataBWFolder\Config\*.*
|
||||
} else {
|
||||
new-item $TestDataBWFolder\Config -itemtype directory
|
||||
}
|
||||
|
||||
#Copio la cartella Config
|
||||
ROBOCOPY /E $Artifacts\EgtProg\EgtBEAMWALL_Config\Config\ $TestDataBWFolder\Config
|
||||
|
||||
#Copio la cartella Messages
|
||||
ROBOCOPY /E $Artifacts\EGT_SRV\EgtTech\EgtData\Messages $TestDataBWFolder\Config
|
||||
|
||||
#Copio la cartella Fonts
|
||||
ROBOCOPY /E $Artifacts\EGT_SRV\EgtTech\EgtProg\Fonts\ $TestDataBWFolder\Fonts
|
||||
|
||||
#Copio DataRoot.ini custom in c:\EgtTestProg\EgtBEAMWALL
|
||||
ROBOCOPY /E $Artifacts\EgtProg\EgtBEAMWALL_Config\ $TestProgBWFolder DataRoot.ini
|
||||
|
||||
#Copio il file Medium.ini in \Warehouse
|
||||
ROBOCOPY /E $Artifacts\EGT_SRV\EgtTech\EgtData\EgtBEAMWALL\Warehouse\ $TestDataBWFolder\Warehouse Medium.ini
|
||||
|
||||
#Copio Resources
|
||||
ROBOCOPY /E $Artifacts\EGT_SRV\EgtTech\EgtData\EgtBEAMWALL\Resources\ $TestDataBWFolder\Resources
|
||||
|
||||
#Copio la sottocartella 32 o 64 bit di Lualibs a seconda della richiesta
|
||||
ROBOCOPY /E $Artifacts\EGT_SRV\EgtTech\EgtProg\LuaLibs\$ChosenBit $TestDataBWFolder\Lualibs
|
||||
|
||||
#Copio la cartella Dll32 o Dll64 a seconda della richiesta
|
||||
ROBOCOPY /E $Artifacts\EGT_SRV\EgtTech\EgtProg\$ChosenDll $TestProgBWFolder
|
||||
|
||||
#Copio la cartella DllD32 o DllD64 a seconda della richiesta
|
||||
ROBOCOPY /E $Artifacts\EGT_SRV\EgtTech\EgtProg\$ChosenDllD $TestProgBWFolder
|
||||
|
||||
#Copio Versione + Architettura di BEAMWALL richieste
|
||||
ROBOCOPY /E $Artifacts\EgtProg\EgtBEAMWALL\$SelBranch\$SelArch $TestProgBWFolder
|
||||
|
||||
#Cancello tutti i .exe.config e .dll.config perchè problematici in area Test
|
||||
Remove-Item -Recurse $TestProgBWFolder\*.exe.config
|
||||
Remove-Item -Recurse $TestProgBWFolder\*.dll.config
|
||||
|
||||
#Chiudo lanciando lo Script Manager per altre operazioni
|
||||
Powershell.exe -executionpolicy remotesigned -File .\CLI\EgtScriptsManager.ps1
|
||||
@@ -0,0 +1,118 @@
|
||||
### Esegue setup di EgtCAM5 da repo Artifacts ###
|
||||
|
||||
#inizializzo variabili vuote
|
||||
$BitSelect = ""
|
||||
$BitChoice = ""
|
||||
$ChosenBit = ""
|
||||
$ChosenDll = ""
|
||||
|
||||
#Definisco path truenas di origine
|
||||
$Artifacts = '\\truenas\Artifacts'
|
||||
$SrvEgtTech = '\\truenas\Artifacts\EGT_SRV\EgtTech'
|
||||
|
||||
#Definisco path test cartelle Egt
|
||||
$TestProgFolder = 'c:\EgtTestProg'
|
||||
$TestDataFolder = 'c:\EgtTestData'
|
||||
|
||||
#Definisco path test sottocartelle EgtCAM5
|
||||
$TestProgCam5Folder = 'c:\EgtTestProg\EgtCAM5'
|
||||
$TestDataCam5Folder = 'c:\EgtTestData\EgtCAM5'
|
||||
|
||||
#Chiedo all'utente se vuole 32 bit o 64 bit
|
||||
function Show-MenuA
|
||||
{
|
||||
param (
|
||||
[string]$Title = 'Seleziona architettura EgtCAM5'
|
||||
)
|
||||
Clear-Host
|
||||
Write-Host ""
|
||||
Write-Host "============= $Title ============="
|
||||
Write-Host ""
|
||||
Write-Host "1: Premi '1' per x86"
|
||||
Write-Host "2: Premi '2' per x64"
|
||||
Write-Host "q: Premi 'q' tornare al menù principale"
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
Show-MenuA
|
||||
|
||||
#Salvo la selezione dell'utente 32 bit o 64 bit
|
||||
$BitSelect = Read-Host "Seleziona architettura EgTCAM5"
|
||||
switch ($BitSelect)
|
||||
{
|
||||
'1' {
|
||||
$BitChoice = 'x86'
|
||||
}
|
||||
'2' {
|
||||
$BitChoice = 'x64'
|
||||
}
|
||||
'q' {
|
||||
Powershell.exe -executionpolicy remotesigned -File .\CLI\EgtScriptsManager.ps1
|
||||
}
|
||||
}
|
||||
|
||||
if($BitChoice -eq 'x86'){
|
||||
$ChosenBit = '32'
|
||||
$ChosenDll = 'Dll32'
|
||||
}
|
||||
else {
|
||||
$ChosenBit = '64'
|
||||
$ChosenDll = 'Dll64'
|
||||
}
|
||||
|
||||
Write-Output ""
|
||||
Write-Output "Installing Test EgtCAM5 Architecture: $ChosenBit bit"
|
||||
Write-Output ""
|
||||
Start-Sleep -seconds 5
|
||||
|
||||
#Pulisco cartella c:\EgtTestProg\EgtCAM5 se già esistente, poi la creo
|
||||
if (Test-Path -Path $TestProgCam5Folder) {
|
||||
"EgtTestProg\EgtCAM5 esiste!"
|
||||
Remove-Item -Recurse $TestProgCam5Folder\*.*
|
||||
} else {
|
||||
new-item $TestProgCam5Folder -itemtype directory
|
||||
}
|
||||
|
||||
#Pulisco cartella c:\EgtTestData\EgtCAM5 se già esistente, poi la creo
|
||||
if (Test-Path -Path $TestDataCam5Folder) {
|
||||
"EgtTestData\EgtCAM5 esiste!"
|
||||
Remove-Item -Recurse $TestDataCam5Folder\*.*
|
||||
} else {
|
||||
new-item $TestDataCam5Folder -itemtype directory
|
||||
}
|
||||
|
||||
#Copio la cartella EgtCAM5
|
||||
ROBOCOPY /E $SrvEgtTech\EgtProg\EgtCAM5\ $TestProgCam5Folder
|
||||
|
||||
#Copio la cartella Dll desiderata
|
||||
ROBOCOPY /E $SrvEgtTech\EgtProg\$ChosenDll\ $TestProgCam5Folder
|
||||
|
||||
#Copio EgtCAM5.ini custom in C:\EgtTestProg\EgtCAM5\Config
|
||||
ROBOCOPY /E $Artifacts\EgtProg\EgtCAM5\Config\ $TestDataCam5Folder\Config EgtCAM5.ini
|
||||
|
||||
#Copio DataRoot.ini custom in C:\EgtTestProg\EgtCAM5
|
||||
ROBOCOPY /E $Artifacts\EgtProg\EgtCAM5\Config\ $TestProgCam5Folder DataRoot.ini
|
||||
|
||||
#Copio la cartella Lualibs
|
||||
ROBOCOPY /E $SrvEgtTech\EgtProg\LuaLibs\ $TestProgFolder\LuaLibs
|
||||
|
||||
#Copio la cartella Fonts
|
||||
ROBOCOPY /E $SrvEgtTech\EgtProg\Fonts\ $TestProgFolder\Fonts
|
||||
|
||||
#Copio la cartella Messages
|
||||
ROBOCOPY /E $SrvEgtTech\EgtData\Messages\ $TestDataFolder\Messages
|
||||
|
||||
#Copio cartella 3dPrinting
|
||||
ROBOCOPY /E $Artifacts\EgtData\3dPrinting\$ChosenBit\ $TestDataCam5Folder\3dPrinting
|
||||
|
||||
#Copio cartella Beam
|
||||
ROBOCOPY /E $Artifacts\EgtData\Beam\$ChosenBit\ $TestDataCam5Folder\Beam
|
||||
|
||||
#Copio cartella Wall
|
||||
ROBOCOPY /E $Artifacts\EgtData\Wall\$ChosenBit\ $TestDataCam5Folder\Wall
|
||||
|
||||
#Copio cartella BeamWall
|
||||
ROBOCOPY /E $Artifacts\EgtData\BeamWall\$ChosenBit\ $TestDataCam5Folder\BeamWall
|
||||
|
||||
#Chiudo lanciando lo Script Manager per altre operazioni
|
||||
Powershell.exe -executionpolicy remotesigned -File .\CLI\EgtScriptsManager.ps1
|
||||
@@ -0,0 +1,42 @@
|
||||
### TESTER SCRIPTS MANAGER ###
|
||||
|
||||
#inizializzo variabili vuote
|
||||
$ScriptSelect=""
|
||||
|
||||
#Chiedo all'utente quale script eseguire
|
||||
function Show-MenuA
|
||||
{
|
||||
param (
|
||||
[string]$Title = 'Seleziona Operazione Desiderata'
|
||||
)
|
||||
Clear-Host
|
||||
Write-Host ""
|
||||
Write-Host "============== $Title =============="
|
||||
Write-Host ""
|
||||
Write-Host "1: Premi '1' per installare EgtCAM5 Test"
|
||||
Write-Host "2: Premi '2' per installare EgtBEAMWALL Test"
|
||||
Write-Host "3: Premi '3' per eseguire Machines Grabber"
|
||||
Write-Host "q: Premi 'q' per uscire dal programma."
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
Show-MenuA
|
||||
|
||||
#Salvo la selezione dell'utente
|
||||
$ScriptSelect = Read-Host 'Seleziona Operazione Desiderata'
|
||||
Write-Host ""
|
||||
switch ($ScriptSelect)
|
||||
{
|
||||
'1' {
|
||||
Powershell.exe -executionpolicy remotesigned -File .\CLI\EgtCAM5Test.ps1
|
||||
}
|
||||
'2' {
|
||||
Powershell.exe -executionpolicy remotesigned -File .\CLI\EgtBeamWallTest.ps1
|
||||
}
|
||||
'3' {
|
||||
Powershell.exe -executionpolicy remotesigned -File .\CLI\MachinesGrabber.ps1
|
||||
}
|
||||
'q' {
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
### Copia le macchine desiderate da Artifacts alla cartella desiderata ###
|
||||
|
||||
#inizializzo variabili vuote
|
||||
$SelDir=""
|
||||
$SelMach=""
|
||||
$FolderType=""
|
||||
|
||||
#Definisco path truenas di origine
|
||||
$Artifacts = '\\truenas\Artifacts'
|
||||
|
||||
#Chiedo all'utente che macchine vuole copiare
|
||||
function Show-MenuA
|
||||
{
|
||||
param (
|
||||
[string]$Title = 'Seleziona Macchine da copiare'
|
||||
)
|
||||
Clear-Host
|
||||
Write-Host ""
|
||||
Write-Host "================ $Title ================"
|
||||
Write-Host "1: Premi '1' per macchine Belotti"
|
||||
Write-Host "2: Premi '2' per macchine CMS"
|
||||
Write-Host "3: Premi '3' per macchine Essetre"
|
||||
Write-Host "4: Premi '4' per macchine Multiax"
|
||||
Write-Host "5: Premi '5' per macchine Omag"
|
||||
Write-Host "q: Premi 'q' tornare al menù principale"
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
Show-MenuA
|
||||
|
||||
#Salvo la selezione dell'utente
|
||||
$MachineSelect = Read-Host 'Seleziona Macchine da copiare'
|
||||
switch ($MachineSelect)
|
||||
{
|
||||
'1' {
|
||||
$SelMach = 'Belotti'
|
||||
}
|
||||
'2' {
|
||||
$SelMach = 'CMS'
|
||||
}
|
||||
'3' {
|
||||
$SelMach = 'Essetre'
|
||||
}
|
||||
'4' {
|
||||
$SelMach = 'Multiax'
|
||||
}
|
||||
'5' {
|
||||
$SelMach = 'Omag'
|
||||
}
|
||||
'q' {
|
||||
Powershell.exe -executionpolicy remotesigned -File .\CLI\EgtScriptsManager.ps1
|
||||
}
|
||||
}
|
||||
|
||||
#Chiedo all'utente in che directory copiare
|
||||
function Show-MenuB
|
||||
{
|
||||
param (
|
||||
[string]$Title = 'Seleziona directory di destinazione'
|
||||
)
|
||||
Clear-Host
|
||||
Write-Host "================ $Title ================"
|
||||
Write-Host ""
|
||||
Write-Host "1: Premi '1' per directory TEST - C:\EgtTestData\EgtCAM5\Machines"
|
||||
Write-Host "2: Premi '2' per directory STABLE - C:\ProgramData\EgalTech\EgtCAM5\Machines"
|
||||
Write-Host "q: Premi 'q' per uscire dal programma."
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
Show-MenuB
|
||||
|
||||
#Salvo la selezione dell'utente
|
||||
$DirectorySelect = Read-Host 'Seleziona directory di destinazione'
|
||||
switch ($DirectorySelect)
|
||||
{
|
||||
'1' {
|
||||
$SelDir = 'C:\EgtTestData\EgtCAM5\Machines'
|
||||
$FolderType = 'Test'
|
||||
}
|
||||
'2' {
|
||||
$SelDir = 'C:\ProgramData\EgalTech\EgtCAM5\Machines'
|
||||
$FolderType = 'Stable'
|
||||
}
|
||||
'q' {
|
||||
Powershell.exe -executionpolicy remotesigned -File .\CLI\EgtScriptsManager.ps1
|
||||
}
|
||||
}
|
||||
|
||||
Write-Output ""
|
||||
Write-Output "Copying machines $SelMach in folder $FolderType"
|
||||
Write-Output ""
|
||||
Start-Sleep -seconds 5
|
||||
|
||||
#Cerco le cartelle delle macchine richieste
|
||||
$MachinesList = Get-ChildItem -Path $Artifacts\EGT_SRV\EgtTech\EgtData\Machines\ -Directory | Select-String -Pattern $SelMach
|
||||
|
||||
#Per ogni macchina richiesta trovata procedo a copiarla in EgtTestData\EgtCAM5\Machines
|
||||
foreach($Machine in $MachinesList)
|
||||
{
|
||||
ROBOCOPY $Artifacts\EGT_SRV\EgtTech\EgtData\Machines\$Machine $SelDir\$Machine /MIR /FFT
|
||||
}
|
||||
|
||||
#Chiudo lanciando lo Script Manager per altre operazioni
|
||||
Powershell.exe -executionpolicy remotesigned -File .\CLI\EgtScriptsManager.ps1
|
||||
@@ -0,0 +1,5 @@
|
||||
$client = new-object System.Net.WebClient
|
||||
$client.DownloadFile("http://mapocrt.egalware.com:8085/maposrv.pfx","C:\Windows\Temp\maposrv.pfx")
|
||||
|
||||
$secureString = convertto-securestring "viadante16" -asplaintext -force
|
||||
Import-PfxCertificate -FilePath C:\Windows\Temp\maposrv.pfx -CertStoreLocation Cert:\LocalMachine\My -Password $secureString
|
||||
@@ -0,0 +1,262 @@
|
||||
### GRAPHIC USER INTERFACE PER TEST BeamWall ###
|
||||
|
||||
#Caricamento classi di .NET Framework
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
Add-Type -AssemblyName PresentationFramework
|
||||
|
||||
#inizializzo variabili vuote
|
||||
$ChosenBit = ""
|
||||
$ChosenDll = ""
|
||||
$ChosenDllD = ""
|
||||
$SelBranch = ""
|
||||
$SelArch = ""
|
||||
|
||||
#Definisco path truenas di origine
|
||||
$Artifacts = '\\truenas\Artifacts'
|
||||
|
||||
#Definisco path test sottocartelle EgtBEAMWALL
|
||||
$TestProgBWFolder = 'c:\EgtTestProg\EgtBEAMWALL'
|
||||
$TestDataBWFolder = 'c:\EgtTestData\EgtBEAMWALL'
|
||||
|
||||
#numero di copie da effettuare
|
||||
$CopyCount = 11
|
||||
#assegno il range di valori min max della barra di progresso in base al numero delle macchine trovate
|
||||
$MinMax = 0..$CopyCount | Measure-Object -Minimum -Maximum
|
||||
|
||||
function ProgressBarAndPercentageLabel{
|
||||
# avanti uno step nella progress bar
|
||||
$CopyProgressBar.PerformStep()
|
||||
# calcolo il progresso in %
|
||||
$ProgressFactor = ($CopyProgressBar.Value/$CopyProgressBar.Maximum)*100
|
||||
$RoundedPercentage = [math]::Round($ProgressFactor)
|
||||
#scrivo nel label dedicato la percentuale di avanzamento e faccio refresh progressbar
|
||||
$PercentageLabel.Text = "$RoundedPercentage %"
|
||||
$CopyProgressBar.Refresh()
|
||||
}
|
||||
|
||||
#Definisco funzione che pulisce il contenuto delle cartelle prima di copiare i file da Truenas
|
||||
function ClearFolders($TestProgBWFolder, $TestDataBWFolder){
|
||||
#Pulisco cartella EgtTestProg\EgtBEAMWALL se già esistente, poi la creo
|
||||
if (Test-Path -Path $TestProgBWFolder) {
|
||||
"Prog esiste!"
|
||||
Remove-Item -Recurse $TestProgBWFolder\*.*
|
||||
} else {
|
||||
new-item $TestProgBWFolder -itemtype directory
|
||||
}
|
||||
|
||||
#Pulisco cartella EgtTestData\EgtBEAMWALL se già esistente, poi la creo
|
||||
if (Test-Path -Path $TestDataBWFolder) {
|
||||
"Data esiste!"
|
||||
Remove-Item -Recurse $TestDataBWFolder\*.*
|
||||
} else {
|
||||
new-item $TestDataBWFolder -itemtype directory
|
||||
}
|
||||
|
||||
#Pulisco cartella EgtTestData\EgtBEAMWALL\Temp se già esistente, poi la creo
|
||||
if (Test-Path -Path $TestDataBWFolder\Temp) {
|
||||
"Temp esiste!"
|
||||
Remove-Item -Recurse $TestDataBWFolder\Temp\*.*
|
||||
} else {
|
||||
new-item $TestDataBWFolder\Temp -itemtype directory
|
||||
}
|
||||
|
||||
#Pulisco cartella EgtTestData\EgtBEAMWALL\Macro se già esistente, poi la creo
|
||||
if (Test-Path -Path $TestDataBWFolder\Macro) {
|
||||
"Macro esiste!"
|
||||
Remove-Item -Recurse $TestDataBWFolder\Macro\*.*
|
||||
} else {
|
||||
new-item $TestDataBWFolder\Macro -itemtype directory
|
||||
}
|
||||
|
||||
#Pulisco cartella EgtTestData\EgtBEAMWALL\Config se già esistente, poi la creo
|
||||
if (Test-Path -Path $TestDataBWFolder\Config) {
|
||||
"Config esiste!"
|
||||
Remove-Item -Recurse $TestDataBWFolder\Config\*.*
|
||||
} else {
|
||||
new-item $TestDataBWFolder\Config -itemtype directory
|
||||
}
|
||||
}
|
||||
|
||||
#Definisco funzione che installa il beamwall richiesto, gli passo i parametri per l'architettura e il branch desiderato
|
||||
function InstallRequiredBeamWall($ChosenBit, $ChosenDll, $ChosenDllD, $SelBranch, $SelArch){
|
||||
#Copio la cartella Config
|
||||
ROBOCOPY /E $Artifacts\EgtProg\EgtBEAMWALL_Config\Config\ $TestDataBWFolder\Config
|
||||
ProgressBarAndPercentageLabel
|
||||
|
||||
#Copio la cartella Messages
|
||||
ROBOCOPY /E $Artifacts\EGT_SRV\EgtTech\EgtData\Messages $TestDataBWFolder\Config
|
||||
ProgressBarAndPercentageLabel
|
||||
|
||||
#Copio la cartella Fonts
|
||||
ROBOCOPY /E $Artifacts\EGT_SRV\EgtTech\EgtProg\Fonts\ $TestDataBWFolder\Fonts
|
||||
ProgressBarAndPercentageLabel
|
||||
|
||||
#Copio DataRoot.ini custom in c:\EgtTestProg\EgtBEAMWALL
|
||||
ROBOCOPY /E $Artifacts\EgtProg\EgtBEAMWALL_Config\ $TestProgBWFolder DataRoot.ini
|
||||
ProgressBarAndPercentageLabel
|
||||
|
||||
#Copio il file Medium.ini in \Warehouse
|
||||
ROBOCOPY /E $Artifacts\EGT_SRV\EgtTech\EgtData\EgtBEAMWALL\Warehouse\ $TestDataBWFolder\Warehouse Medium.ini
|
||||
ProgressBarAndPercentageLabel
|
||||
|
||||
#Copio Resources
|
||||
ROBOCOPY /E $Artifacts\EGT_SRV\EgtTech\EgtData\EgtBEAMWALL\Resources\ $TestDataBWFolder\Resources
|
||||
ProgressBarAndPercentageLabel
|
||||
|
||||
#Copio la sottocartella 32 o 64 bit di Lualibs a seconda della richiesta
|
||||
ROBOCOPY /E $Artifacts\EGT_SRV\EgtTech\EgtProg\LuaLibs\$ChosenBit $TestDataBWFolder\Lualibs
|
||||
ProgressBarAndPercentageLabel
|
||||
|
||||
#Copio la cartella Dll32 o Dll64 a seconda della richiesta
|
||||
ROBOCOPY /E $Artifacts\EGT_SRV\EgtTech\EgtProg\$ChosenDll $TestProgBWFolder
|
||||
ProgressBarAndPercentageLabel
|
||||
|
||||
#Copio la cartella DllD32 o DllD64 a seconda della richiesta
|
||||
ROBOCOPY /E $Artifacts\EGT_SRV\EgtTech\EgtProg\$ChosenDllD $TestProgBWFolder
|
||||
ProgressBarAndPercentageLabel
|
||||
|
||||
#Copio Versione + Architettura di BEAMWALL richieste
|
||||
ROBOCOPY /E $Artifacts\EgtProg\EgtBEAMWALL\$SelBranch\$SelArch $TestProgBWFolder
|
||||
ProgressBarAndPercentageLabel
|
||||
|
||||
#Cancello tutti i .exe.config e .dll.config perchè problematici in area Test
|
||||
Remove-Item -Recurse $TestProgBWFolder\*.exe.config
|
||||
Remove-Item -Recurse $TestProgBWFolder\*.dll.config
|
||||
ProgressBarAndPercentageLabel
|
||||
}
|
||||
|
||||
#Definisco una finestra in cui è possibile aggiungere controlli.
|
||||
$BWForm = New-Object System.Windows.Forms.Form
|
||||
$BWForm.Text = 'BeamWall Tester'
|
||||
$BWForm.Size = New-Object System.Drawing.Size(400,420)
|
||||
$BWForm.StartPosition = 'CenterScreen'
|
||||
|
||||
#Definisco una groupbox per la scelta dell'architettura
|
||||
$ArchGroupBox = New-Object System.Windows.Forms.GroupBox
|
||||
$ArchGroupBox.Location = New-Object System.Drawing.Size(20,20)
|
||||
$ArchGroupBox.size = New-Object System.Drawing.Size(340,80)
|
||||
$ArchGroupBox.text = "Seleziona architettura BeamWall da testare:"
|
||||
$BWForm.Controls.Add($ArchGroupBox)
|
||||
|
||||
#Definisco il bottone per selezionare architettura x86
|
||||
$x86Button = New-Object System.Windows.Forms.RadioButton
|
||||
$x86Button.Location = New-Object System.Drawing.Point(20,20)
|
||||
$x86Button.Size = New-Object System.Drawing.Size(100,23)
|
||||
$x86Button.Text = 'x86'
|
||||
$x86Button.Checked = $true
|
||||
$BWForm.Controls.Add($x86Button)
|
||||
$ArchGroupBox.Controls.Add($x86Button)
|
||||
|
||||
#Definisco il bottone per selezionare architettura x64
|
||||
$x64Button = New-Object System.Windows.Forms.RadioButton
|
||||
$x64Button.Location = New-Object System.Drawing.Point(20,40)
|
||||
$x64Button.Size = New-Object System.Drawing.Size(100,23)
|
||||
$x64Button.Text = 'x64'
|
||||
$BWForm.Controls.Add($x64Button)
|
||||
$ArchGroupBox.Controls.Add($x64Button)
|
||||
|
||||
#Definisco una groupbox per la scelta del branch
|
||||
$BranchGroupBox = New-Object System.Windows.Forms.GroupBox
|
||||
$BranchGroupBox.Location = New-Object System.Drawing.Size(20,120)
|
||||
$BranchGroupBox.size = New-Object System.Drawing.Size(340,80)
|
||||
$BranchGroupBox.text = "Seleziona branch BeamWall da testare:"
|
||||
$BWForm.Controls.Add($BranchGroupBox)
|
||||
|
||||
#Definisco il bottone per selezionare develop
|
||||
$DevelopButton = New-Object System.Windows.Forms.RadioButton
|
||||
$DevelopButton.Location = New-Object System.Drawing.Point(20,20)
|
||||
$DevelopButton.Size = New-Object System.Drawing.Size(100,23)
|
||||
$DevelopButton.Text = 'Develop'
|
||||
$DevelopButton.Checked = $true
|
||||
$BWForm.Controls.Add($DevelopButton)
|
||||
$BranchGroupBox.Controls.Add($DevelopButton)
|
||||
|
||||
#Definisco il bottone per selezionare master
|
||||
$MasterButton = New-Object System.Windows.Forms.RadioButton
|
||||
$MasterButton.Location = New-Object System.Drawing.Point(20,40)
|
||||
$MasterButton.Size = New-Object System.Drawing.Size(100,23)
|
||||
$MasterButton.Text = 'Master'
|
||||
$BWForm.Controls.Add($MasterButton)
|
||||
$BranchGroupBox.Controls.Add($MasterButton)
|
||||
|
||||
#Definisco un label per mostrare l'avanzamento dell'operazione in corso
|
||||
$PercentageLabel = New-Object System.Windows.Forms.Label
|
||||
$PercentageLabel.Location = New-Object System.Drawing.Point(180,220)
|
||||
$PercentageLabel.Size = New-Object System.Drawing.Size(280,20)
|
||||
$PercentageLabel.Text = ""
|
||||
$PercentageLabel.Visible = $True
|
||||
$BWForm.Controls.Add($PercentageLabel)
|
||||
|
||||
#Definisco la barra di avanzamento per mostrare il progresso della copia
|
||||
$CopyProgressBar = New-Object System.Windows.Forms.ProgressBar
|
||||
$CopyProgressBar.Width = 340
|
||||
$CopyProgressBar.Height = 20
|
||||
$CopyProgressBar.Location = New-Object System.Drawing.Point(20,240)
|
||||
#assegno i valori minimi e massimi della barra progresso in base al range definito precedentemente
|
||||
$CopyProgressBar.Minimum = $MinMax.Minimum
|
||||
$CopyProgressBar.Maximum = $MinMax.Maximum
|
||||
#inizializzo il value della progress bar al minimo
|
||||
$CopyProgressBar.Value = $MinMax.Minimum
|
||||
#definisco lo step della progress bar a 1 (1 step=1 cartella copiata)
|
||||
$CopyProgressBar.Step = 1
|
||||
$CopyProgressBar.Style = 'Continuous'
|
||||
$CopyProgressBar.Visible = $True
|
||||
$BWForm.Controls.Add($CopyProgressBar)
|
||||
|
||||
#Definisco il bottone per lanciare installazione di BEAMWALL
|
||||
$InstallBWButton = New-Object System.Windows.Forms.Button
|
||||
$InstallBWButton.Location = New-Object System.Drawing.Point(20,280)
|
||||
$InstallBWButton.Size = New-Object System.Drawing.Size(120,23)
|
||||
$InstallBWButton.Text = 'Installa BeamWall'
|
||||
$InstallBWButton.Add_Click({
|
||||
if ($x86Button.Checked -eq $true) {
|
||||
$ChosenBit = '32'
|
||||
$ChosenDll = 'Dll32'
|
||||
$ChosenDllD = 'DllD32'
|
||||
$SelArch = 'x86'
|
||||
}
|
||||
if ($x64Button.Checked -eq $true) {
|
||||
$ChosenBit = '64'
|
||||
$ChosenDll = 'Dll64'
|
||||
$ChosenDllD = 'DllD64'
|
||||
$SelArch = 'x64'
|
||||
}
|
||||
if ($DevelopButton.Checked -eq $true) {
|
||||
$SelBranch = 'develop'
|
||||
}
|
||||
if ($MasterButton.Checked -eq $true) {
|
||||
$SelBranch = 'master'
|
||||
}
|
||||
$UserConfirmation = [System.Windows.MessageBox]::Show("Install BeamWall $SelArch branch $SelBranch ?",'Conferma Installazione','YesNo','Info')
|
||||
switch ($UserConfirmation){
|
||||
'Yes' {
|
||||
ClearFolders $TestProgBWFolder $TestDataBWFolder
|
||||
InstallRequiredBeamWall $ChosenBit $ChosenDll $ChosenDllD $SelBranch $SelArch
|
||||
[System.Windows.MessageBox]::Show("Beamwall $SelArch branch $SelBranch installato!",'Operazione terminata')
|
||||
$BWForm.Close()
|
||||
$BWForm.Dispose()
|
||||
Powershell.exe -executionpolicy remotesigned -File .\GUI\EgtScriptsGUI.ps1
|
||||
}
|
||||
'No' {}
|
||||
}
|
||||
})
|
||||
$BWForm.Controls.Add($InstallBWButton)
|
||||
|
||||
#Definisco il bottone per navigazione al menu precedente
|
||||
$MenuReturn = New-Object System.Windows.Forms.Button
|
||||
$MenuReturn.Location = New-Object System.Drawing.Point(260,280)
|
||||
$MenuReturn.Size = New-Object System.Drawing.Size(100,23)
|
||||
$MenuReturn.Text = 'Torna alla home'
|
||||
$MenuReturn.Add_Click({
|
||||
$BWForm.Close()
|
||||
$BWForm.Dispose()
|
||||
Powershell.exe -executionpolicy remotesigned -File .\GUI\EgtScriptsGUI.ps1
|
||||
})
|
||||
$BWForm.Controls.Add($MenuReturn)
|
||||
|
||||
#Proprietà Topmost su $true per forzare l'apertura della finestra sopra altre finestre e finestre di dialogo aperte.
|
||||
$BWForm.Topmost = $true
|
||||
|
||||
#Visualizzo il modulo:
|
||||
$BWForm.ShowDialog()
|
||||
@@ -0,0 +1,211 @@
|
||||
### GRAPHIC USER INTERFACE PER TEST EGTCAM5 ###
|
||||
|
||||
#Caricamento classi di .NET Framework
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
Add-Type -AssemblyName PresentationFramework
|
||||
|
||||
#Inizializzo variabili vuote
|
||||
$BitChoice = ""
|
||||
$ChosenBit = ""
|
||||
$ChosenDll = ""
|
||||
|
||||
#Definisco path truenas di origine
|
||||
$Artifacts = '\\truenas\Artifacts'
|
||||
$SrvEgtTech = '\\truenas\Artifacts\EGT_SRV\EgtTech'
|
||||
|
||||
#Definisco path test cartelle Egt
|
||||
$TestProgFolder = 'c:\EgtTestProg'
|
||||
$TestDataFolder = 'c:\EgtTestData'
|
||||
|
||||
#Definisco path test sottocartelle EgtCAM5
|
||||
$TestProgCam5Folder = 'c:\EgtTestProg\EgtCAM5'
|
||||
$TestDataCam5Folder = 'c:\EgtTestData\EgtCAM5'
|
||||
|
||||
#numero di copie da effettuare
|
||||
$CopyCount = 12
|
||||
#assegno il range di valori min max della barra di progresso in base al numero delle macchine trovate
|
||||
$MinMax = 0..$CopyCount | Measure-Object -Minimum -Maximum
|
||||
|
||||
function ProgressBarAndPercentageLabel{
|
||||
# avanti uno step nella progress bar
|
||||
$CopyProgressBar.PerformStep()
|
||||
# calcolo il progresso in %
|
||||
$ProgressFactor = ($CopyProgressBar.Value/$CopyProgressBar.Maximum)*100
|
||||
$RoundedPercentage = [math]::Round($ProgressFactor)
|
||||
#scrivo nel label dedicato la percentuale di avanzamento e faccio refresh progressbar
|
||||
$PercentageLabel.Text = "$RoundedPercentage %"
|
||||
$CopyProgressBar.Refresh()
|
||||
}
|
||||
|
||||
function ClearFolders($TestProgCam5Folder, $TestDataCam5Folder){
|
||||
#Pulisco cartella c:\EgtTestProg\EgtCAM5 se già esistente, poi la creo
|
||||
if (Test-Path -Path $TestProgCam5Folder) {
|
||||
"EgtTestProg\EgtCAM5 esiste!"
|
||||
Remove-Item -Recurse $TestProgCam5Folder\*.*
|
||||
} else {
|
||||
new-item $TestProgCam5Folder -itemtype directory
|
||||
}
|
||||
|
||||
#Pulisco cartella c:\EgtTestData\EgtCAM5 se già esistente, poi la creo
|
||||
if (Test-Path -Path $TestDataCam5Folder) {
|
||||
"EgtTestData\EgtCAM5 esiste!"
|
||||
Remove-Item -Recurse $TestDataCam5Folder\*.*
|
||||
} else {
|
||||
new-item $TestDataCam5Folder -itemtype directory
|
||||
}
|
||||
}
|
||||
|
||||
#Definisco funzione che installa il CAM5 richiesto, gli passo i parametri per l'architettura desiderata
|
||||
function InstallRequiredCAM5($BitChoice, $ChosenBit, $ChosenDll){
|
||||
#Copio la cartella EgtCAM5
|
||||
ROBOCOPY /E $SrvEgtTech\EgtProg\EgtCAM5\ $TestProgCam5Folder
|
||||
ProgressBarAndPercentageLabel
|
||||
|
||||
#Copio la cartella Dll desiderata
|
||||
ROBOCOPY /E $SrvEgtTech\EgtProg\$ChosenDll\ $TestProgCam5Folder
|
||||
ProgressBarAndPercentageLabel
|
||||
|
||||
#Copio EgtCAM5.ini custom in C:\EgtTestProg\EgtCAM5\Config
|
||||
ROBOCOPY /E $Artifacts\EgtProg\EgtCAM5\Config\ $TestDataCam5Folder\Config EgtCAM5.ini
|
||||
ProgressBarAndPercentageLabel
|
||||
|
||||
#Copio DataRoot.ini custom in C:\EgtTestProg\EgtCAM5
|
||||
ROBOCOPY /E $Artifacts\EgtProg\EgtCAM5\Config\ $TestProgCam5Folder DataRoot.ini
|
||||
ProgressBarAndPercentageLabel
|
||||
|
||||
#Copio la cartella Lualibs
|
||||
ROBOCOPY /E $SrvEgtTech\EgtProg\LuaLibs\ $TestProgFolder\LuaLibs
|
||||
ProgressBarAndPercentageLabel
|
||||
|
||||
#Copio la cartella Fonts
|
||||
ROBOCOPY /E $SrvEgtTech\EgtProg\Fonts\ $TestProgFolder\Fonts
|
||||
ProgressBarAndPercentageLabel
|
||||
|
||||
#Copio la cartella Messages
|
||||
ROBOCOPY /E $SrvEgtTech\EgtData\Messages\ $TestDataFolder\Messages
|
||||
ProgressBarAndPercentageLabel
|
||||
|
||||
#Copio la cartella ToolMakers
|
||||
ROBOCOPY /E $SrvEgtTech\EgtData\ToolMakers\ $TestDataCam5Folder\ToolMakers
|
||||
ProgressBarAndPercentageLabel
|
||||
|
||||
#Copio cartella 3dPrinting
|
||||
ROBOCOPY /E $Artifacts\EgtData\3dPrinting\$ChosenBit\ $TestDataCam5Folder\3dPrinting
|
||||
ProgressBarAndPercentageLabel
|
||||
|
||||
#Copio cartella Beam
|
||||
ROBOCOPY /E $Artifacts\EgtData\Beam\$ChosenBit\ $TestDataCam5Folder\Beam
|
||||
ProgressBarAndPercentageLabel
|
||||
|
||||
#Copio cartella Wall
|
||||
ROBOCOPY /E $Artifacts\EgtData\Wall\$ChosenBit\ $TestDataCam5Folder\Wall
|
||||
ProgressBarAndPercentageLabel
|
||||
|
||||
#Copio cartella BeamWall
|
||||
ROBOCOPY /E $Artifacts\EgtData\BeamWall\$ChosenBit\ $TestDataCam5Folder\BeamWall
|
||||
ProgressBarAndPercentageLabel
|
||||
}
|
||||
|
||||
#Definisco una finestra in cui è possibile aggiungere controlli.
|
||||
$Cam5Form = New-Object System.Windows.Forms.Form
|
||||
$Cam5Form.Text = 'EgtCAM5 Tester'
|
||||
$Cam5Form.Size = New-Object System.Drawing.Size(400,300)
|
||||
$Cam5Form.StartPosition = 'CenterScreen'
|
||||
|
||||
#Definisco una groupbox per la scelta dell'architettura
|
||||
$ArchGroupBox = New-Object System.Windows.Forms.GroupBox
|
||||
$ArchGroupBox.Location = New-Object System.Drawing.Size(20,20)
|
||||
$ArchGroupBox.size = New-Object System.Drawing.Size(340,80)
|
||||
$ArchGroupBox.text = "Seleziona architettura EgtCAM5 da testare:"
|
||||
$Cam5Form.Controls.Add($ArchGroupBox)
|
||||
|
||||
#Definisco il bottone per selezionare architettura x86
|
||||
$x86Button = New-Object System.Windows.Forms.RadioButton
|
||||
$x86Button.Location = New-Object System.Drawing.Point(20,20)
|
||||
$x86Button.Size = New-Object System.Drawing.Size(100,23)
|
||||
$x86Button.Text = 'x86'
|
||||
$x86Button.Checked = $true
|
||||
$Cam5Form.Controls.Add($x86Button)
|
||||
$ArchGroupBox.Controls.Add($x86Button)
|
||||
|
||||
#Definisco il bottone per selezionare architettura x64
|
||||
$x64Button = New-Object System.Windows.Forms.RadioButton
|
||||
$x64Button.Location = New-Object System.Drawing.Point(20,40)
|
||||
$x64Button.Size = New-Object System.Drawing.Size(100,23)
|
||||
$x64Button.Text = 'x64'
|
||||
$Cam5Form.Controls.Add($x64Button)
|
||||
$ArchGroupBox.Controls.Add($x64Button)
|
||||
|
||||
#Definisco un label per mostrare l'avanzamento dell'operazione in corso
|
||||
$PercentageLabel = New-Object System.Windows.Forms.Label
|
||||
$PercentageLabel.Location = New-Object System.Drawing.Point(180,120)
|
||||
$PercentageLabel.Size = New-Object System.Drawing.Size(280,20)
|
||||
$PercentageLabel.Text = ""
|
||||
$PercentageLabel.Visible = $True
|
||||
$Cam5Form.Controls.Add($PercentageLabel)
|
||||
|
||||
#Definisco la barra di avanzamento per mostrare il progresso della copia
|
||||
$CopyProgressBar = New-Object System.Windows.Forms.ProgressBar
|
||||
$CopyProgressBar.Width = 320
|
||||
$CopyProgressBar.Height = 20
|
||||
$CopyProgressBar.Location = New-Object System.Drawing.Point(20,160)
|
||||
#assegno i valori minimi e massimi della barra progresso in base al range definito precedentemente
|
||||
$CopyProgressBar.Minimum = $MinMax.Minimum
|
||||
$CopyProgressBar.Maximum = $MinMax.Maximum
|
||||
#inizializzo il value della progress bar al minimo
|
||||
$CopyProgressBar.Value = $MinMax.Minimum
|
||||
#definisco lo step della progress bar a 1 (1 step=1 cartella copiata)
|
||||
$CopyProgressBar.Step = 1
|
||||
$CopyProgressBar.Style = 'Continuous'
|
||||
$CopyProgressBar.Visible = $True
|
||||
$Cam5Form.Controls.Add($CopyProgressBar)
|
||||
|
||||
#Definisco il bottone per lanciare installazione richiesta di EgtCAM5
|
||||
$InstallCAM5Button = New-Object System.Windows.Forms.Button
|
||||
$InstallCAM5Button.Location = New-Object System.Drawing.Point(20,220)
|
||||
$InstallCAM5Button.Size = New-Object System.Drawing.Size(100,23)
|
||||
$InstallCAM5Button.Text = 'Installa EgtCAM5'
|
||||
$InstallCAM5Button.Add_Click({
|
||||
if ($x86Button.Checked -eq $true) {
|
||||
$BitChoice = 'x86'
|
||||
$ChosenBit = '32'
|
||||
$ChosenDll = 'Dll32'
|
||||
}
|
||||
if ($x64Button.Checked -eq $true) {
|
||||
$BitChoice = 'x64'
|
||||
$ChosenBit = '64'
|
||||
$ChosenDll = 'Dll64'
|
||||
}
|
||||
$UserConfirmation = [System.Windows.MessageBox]::Show("Install EgtCAM5 $BitChoice ?",'Conferma Architettura','YesNo','Info')
|
||||
switch ($UserConfirmation){
|
||||
'Yes' {
|
||||
ClearFolders $TestProgCam5Folder $TestDataCam5Folder
|
||||
InstallRequiredCAM5 $BitChoice $ChosenBit $ChosenDll
|
||||
[System.Windows.MessageBox]::Show("EgtCAM5 $BitChoice installato!",'Operazione terminata')
|
||||
$Cam5Form.Close()
|
||||
$Cam5Form.Dispose()
|
||||
Powershell.exe -executionpolicy remotesigned -File .\GUI\EgtScriptsGUI.ps1
|
||||
}
|
||||
'No'{}
|
||||
}
|
||||
})
|
||||
$Cam5Form.Controls.Add($InstallCAM5Button)
|
||||
|
||||
#Definisco il bottone per navigazione al menu precedente
|
||||
$MenuReturn = New-Object System.Windows.Forms.Button
|
||||
$MenuReturn.Location = New-Object System.Drawing.Point(260,220)
|
||||
$MenuReturn.Size = New-Object System.Drawing.Size(100,23)
|
||||
$MenuReturn.Text = 'Torna alla home'
|
||||
$MenuReturn.Add_Click({
|
||||
$Cam5Form.Close()
|
||||
$Cam5Form.Dispose()
|
||||
Powershell.exe -executionpolicy remotesigned -File .\GUI\EgtScriptsGUI.ps1
|
||||
})
|
||||
$Cam5Form.Controls.Add($MenuReturn)
|
||||
|
||||
#Proprietà Topmost su $true per forzare l'apertura della finestra sopra altre finestre e finestre di dialogo aperte.
|
||||
$Cam5Form.Topmost = $true
|
||||
|
||||
#Visualizzo il modulo:
|
||||
$Cam5Form.ShowDialog()
|
||||
@@ -0,0 +1,68 @@
|
||||
### GRAPHIC USER INTERFACE PER TEST SCRIPTS ###
|
||||
|
||||
#Caricamento classi di .NET Framework
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
Add-Type -AssemblyName PresentationFramework
|
||||
|
||||
#Definisco una finestra in cui è possibile aggiungere controlli.
|
||||
$MainForm = New-Object System.Windows.Forms.Form
|
||||
$MainForm.Text = 'Egt Version Tester'
|
||||
$MainForm.Size = New-Object System.Drawing.Size(400,300)
|
||||
$MainForm.StartPosition = 'CenterScreen'
|
||||
|
||||
#Definisco un testo per chiedere all'utente che programma vuole installare
|
||||
$InstLabel = New-Object System.Windows.Forms.Label
|
||||
$InstLabel.Location = New-Object System.Drawing.Point(20,20)
|
||||
$InstLabel.Size = New-Object System.Drawing.Size(280,20)
|
||||
$InstLabel.Text = 'Seleziona il programma da testare:'
|
||||
$MainForm.Controls.Add($InstLabel)
|
||||
|
||||
#Definisco il bottone per lanciare installazione di EgtCAM5
|
||||
$CAM5Button = New-Object System.Windows.Forms.Button
|
||||
$CAM5Button.Location = New-Object System.Drawing.Point(40,40)
|
||||
$CAM5Button.Size = New-Object System.Drawing.Size(100,23)
|
||||
$CAM5Button.Text = 'EgtCAM5'
|
||||
$CAM5Button.Add_Click({
|
||||
$MainForm.Close()
|
||||
$MainForm.Dispose()
|
||||
Powershell.exe -executionpolicy remotesigned -File .\GUI\EgtCAM5TestGUI.ps1
|
||||
})
|
||||
$MainForm.Controls.Add($CAM5Button)
|
||||
|
||||
#Definisco il bottone per lanciare installazione di BeamWall
|
||||
$BWButton = New-Object System.Windows.Forms.Button
|
||||
$BWButton.Location = New-Object System.Drawing.Point(40,70)
|
||||
$BWButton.Size = New-Object System.Drawing.Size(100,23)
|
||||
$BWButton.Text = 'BeamWall'
|
||||
$BWButton.Add_Click({
|
||||
$MainForm.Close()
|
||||
$MainForm.Dispose()
|
||||
Powershell.exe -executionpolicy remotesigned -File .\GUI\EgtBeamWallTestGUI.ps1
|
||||
})
|
||||
$MainForm.Controls.Add($BWButton)
|
||||
|
||||
#Definisco un testo per chiedere all'utente se vuole copiare macchine dal server
|
||||
$MachLabel = New-Object System.Windows.Forms.Label
|
||||
$MachLabel.Location = New-Object System.Drawing.Point(20,110)
|
||||
$MachLabel.Size = New-Object System.Drawing.Size(280,20)
|
||||
$MachLabel.Text = 'Copia macchine dal server:'
|
||||
$MainForm.Controls.Add($MachLabel)
|
||||
|
||||
#Definisco il bottone per copiare macchine dal server
|
||||
$MachButton = New-Object System.Windows.Forms.Button
|
||||
$MachButton.Location = New-Object System.Drawing.Point(40,130)
|
||||
$MachButton.Size = New-Object System.Drawing.Size(100,23)
|
||||
$MachButton.Text = 'Copia Macchine'
|
||||
$MachButton.Add_Click({
|
||||
$MainForm.Close()
|
||||
$MainForm.Dispose()
|
||||
Powershell.exe -executionpolicy remotesigned -File .\GUI\MachGrabberGUI.ps1
|
||||
})
|
||||
$MainForm.Controls.Add($MachButton)
|
||||
|
||||
#Proprietà Topmost su $true per forzare l'apertura della finestra sopra altre finestre e finestre di dialogo aperte.
|
||||
$MainForm.Topmost = $true
|
||||
|
||||
#Visualizzo il modulo:
|
||||
$MainForm.ShowDialog()
|
||||
@@ -0,0 +1,57 @@
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
|
||||
# Range to count through
|
||||
$Range = 1..100
|
||||
# Determine minimum & maximum values of range
|
||||
$MinMax = $Range | Measure-Object -Minimum -Maximum
|
||||
#inizializzo counter a zero
|
||||
$Counter = 0
|
||||
|
||||
# Function to run on button click
|
||||
Function Start-Counting {
|
||||
# On button click we set progress bar to start (minimum) value and refresh
|
||||
$ProgressBar.Value = $MinMax.Minimum
|
||||
$ProgressBar.Refresh()
|
||||
$Button.Refresh()
|
||||
Foreach ($Number in $Range) {
|
||||
$Counter++
|
||||
# Perform single step on progress bar and refresh
|
||||
$ProgressBar.PerformStep()
|
||||
$ProgressBar.Refresh()
|
||||
# Step interval
|
||||
Start-Sleep -Milliseconds 50
|
||||
}
|
||||
$Counter = 0
|
||||
}
|
||||
|
||||
$ProgressForm = New-Object System.Windows.Forms.Form
|
||||
$ProgressForm.Text = "Operation in progress..."
|
||||
$ProgressForm.SizeGripStyle = "Hide"
|
||||
$ProgressForm.StartPosition = "CenterScreen"
|
||||
$ProgressForm.FormBorderStyle = "FixedDialog"
|
||||
$ProgressForm.MaximizeBox = $False
|
||||
$ProgressForm.Width = 400
|
||||
$ProgressForm.Height = 200
|
||||
|
||||
$ProgressBar = New-Object System.Windows.Forms.ProgressBar
|
||||
$ProgressBar.Width = 340
|
||||
$ProgressBar.Height = 25
|
||||
$ProgressBar.Visible = $True
|
||||
$ProgressBar.Minimum = $MinMax.Minimum
|
||||
$ProgressBar.Maximum = $MinMax.Maximum
|
||||
$ProgressBar.Value = $MinMax.Minimum
|
||||
$ProgressBar.Step = 1
|
||||
$ProgressBar.Location = New-Object System.Drawing.Point(20,60)
|
||||
$ProgressForm.Controls.Add($ProgressBar)
|
||||
|
||||
$Button = New-Object System.Windows.Forms.Button
|
||||
$Button.Text = "Test Progress"
|
||||
$Button.Width = 200
|
||||
$Button.Height = 40
|
||||
$Button.Add_Click({Start-Counting})
|
||||
$Button.Location = New-Object System.Drawing.Point(20,90)
|
||||
$Button.Font = "Microsoft Sans Serif,10"
|
||||
$ProgressForm.Controls.Add($Button)
|
||||
|
||||
$ProgressForm.ShowDialog()
|
||||
$ProgressForm.TopMost = $True
|
||||
@@ -0,0 +1,232 @@
|
||||
### GRAPHIC USER INTERFACE PER MACHINE GRABBER ###
|
||||
|
||||
#Caricamento classi di .NET Framework
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
Add-Type -AssemblyName System.Runtime
|
||||
Add-Type -AssemblyName PresentationFramework
|
||||
|
||||
#inizializzo variabili vuote
|
||||
$SelDir=""
|
||||
$SelMach=""
|
||||
$TestDirectory="C:\EgtTestData\EgtCAM5\Machines"
|
||||
$StableDirectory="C:\ProgramData\EgalTech\EgtCAM5\Machines"
|
||||
|
||||
#Definisco path truenas di origine
|
||||
$Artifacts = '\\truenas\Artifacts'
|
||||
|
||||
#funzione MachineCopy: date le macchine da copiare e la folder di destinazione, fa la copia da truenas al pc locale e mostra l'avanzamento nella progress bar
|
||||
function MachineCopy($SelMach, $SelDir){
|
||||
#inizializzo counter a zero per avanzamento barra progresso
|
||||
$Counter = 0
|
||||
#Cerco le cartelle delle macchine richieste
|
||||
$MachinesList = Get-ChildItem -Path $Artifacts\EGT_SRV\EgtTech\EgtData\Machines\ -Directory | Select-String -Pattern $SelMach
|
||||
#ricavo il numero delle macchine richieste trovate
|
||||
$MachinesCount = $MachinesList.Count
|
||||
#assegno il range di valori min max della barra di progresso in base al numero delle macchine trovate
|
||||
$MinMax = 0..$MachinesCount | Measure-Object -Minimum -Maximum
|
||||
#assegno i valori minimi e massimi della barra progresso in base al range definito precedentemente
|
||||
$CopyProgressBar.Minimum = $MinMax.Minimum
|
||||
$CopyProgressBar.Maximum = $MinMax.Maximum
|
||||
#inizializzo il value della progress bar al minimo
|
||||
$CopyProgressBar.Value = $MinMax.Minimum
|
||||
#definisco lo step della progress bar a 1 (1 step=1 cartella copiata)
|
||||
$CopyProgressBar.Step = 1
|
||||
#Per ogni macchina richiesta trovata procedo a copiarla in EgtTestData\EgtCAM5\Machines
|
||||
foreach($Machine in $MachinesList){
|
||||
ROBOCOPY $Artifacts\EGT_SRV\EgtTech\EgtData\Machines\$Machine $SelDir\$Machine /MIR /FFT
|
||||
$Counter++
|
||||
# avanti uno step nella progress bar
|
||||
$CopyProgressBar.PerformStep()
|
||||
# calcolo il progresso in %
|
||||
$ProgressFactor = ($CopyProgressBar.Value/$CopyProgressBar.Maximum)*100
|
||||
$RoundedPercentage = [math]::Round($ProgressFactor)
|
||||
#scrivo nel label dedicato la percentuale di avanzamento e faccio refresh progressbar
|
||||
$PercentageLabel.Text = "$RoundedPercentage %"
|
||||
$CopyProgressBar.Refresh()
|
||||
}
|
||||
}
|
||||
|
||||
#Definisco una finestra in cui è possibile aggiungere controlli.
|
||||
$MachGrabForm = New-Object System.Windows.Forms.Form
|
||||
$MachGrabForm.Text = 'Machine Grabber'
|
||||
$MachGrabForm.Size = New-Object System.Drawing.Size(500,500)
|
||||
$MachGrabForm.StartPosition = 'CenterScreen'
|
||||
|
||||
#Definisco una groupbox per la scelta delle macchine
|
||||
$MachGroupBox = New-Object System.Windows.Forms.GroupBox
|
||||
$MachGroupBox.Location = New-Object System.Drawing.Size(20,20)
|
||||
$MachGroupBox.size = New-Object System.Drawing.Size(440,140)
|
||||
$MachGroupBox.text = "Seleziona macchine da copiare:"
|
||||
$MachGrabForm.Controls.Add($MachGroupBox)
|
||||
|
||||
#Definisco il bottone per selezionare macchine Belotti
|
||||
$BelottiButton = New-Object System.Windows.Forms.RadioButton
|
||||
$BelottiButton.Location = New-Object System.Drawing.Point(20,20)
|
||||
$BelottiButton.Size = New-Object System.Drawing.Size(100,23)
|
||||
$BelottiButton.Text = 'Belotti'
|
||||
$BelottiButton.Checked = $true
|
||||
$MachGrabForm.Controls.Add($BelottiButton)
|
||||
$MachGroupBox.Controls.Add($BelottiButton)
|
||||
|
||||
#Definisco il bottone per selezionare macchine Cms
|
||||
$CmsButton = New-Object System.Windows.Forms.RadioButton
|
||||
$CmsButton.Location = New-Object System.Drawing.Point(20,40)
|
||||
$CmsButton.Size = New-Object System.Drawing.Size(100,23)
|
||||
$CmsButton.Text = 'Cms'
|
||||
$MachGrabForm.Controls.Add($CmsButton)
|
||||
$MachGroupBox.Controls.Add($CmsButton)
|
||||
|
||||
#Definisco il bottone per selezionare macchine Essetre
|
||||
$EssetreButton = New-Object System.Windows.Forms.RadioButton
|
||||
$EssetreButton.Location = New-Object System.Drawing.Point(20,60)
|
||||
$EssetreButton.Size = New-Object System.Drawing.Size(100,23)
|
||||
$EssetreButton.Text = 'Essetre'
|
||||
$MachGrabForm.Controls.Add($EssetreButton)
|
||||
$MachGroupBox.Controls.Add($EssetreButton)
|
||||
|
||||
#Definisco il bottone per selezionare macchine Multiax
|
||||
$MultiaxButton = New-Object System.Windows.Forms.RadioButton
|
||||
$MultiaxButton.Location = New-Object System.Drawing.Point(20,80)
|
||||
$MultiaxButton.Size = New-Object System.Drawing.Size(100,23)
|
||||
$MultiaxButton.Text = 'Multiax'
|
||||
$MachGrabForm.Controls.Add($MultiaxButton)
|
||||
$MachGroupBox.Controls.Add($MultiaxButton)
|
||||
|
||||
#Definisco il bottone per selezionare macchine Omag
|
||||
$OmagButton = New-Object System.Windows.Forms.RadioButton
|
||||
$OmagButton.Location = New-Object System.Drawing.Point(20,100)
|
||||
$OmagButton.Size = New-Object System.Drawing.Size(100,23)
|
||||
$OmagButton.Text = 'Omag'
|
||||
$MachGrabForm.Controls.Add($OmagButton)
|
||||
$MachGroupBox.Controls.Add($OmagButton)
|
||||
|
||||
#Definisco una groupbox per la scelta della cartella di destinazione
|
||||
$FolderGroupBox = New-Object System.Windows.Forms.GroupBox
|
||||
$FolderGroupBox.Location = New-Object System.Drawing.Size(20,180)
|
||||
$FolderGroupBox.size = New-Object System.Drawing.Size(440,120)
|
||||
$FolderGroupBox.text = "Seleziona directory di destinazione:"
|
||||
$MachGrabForm.Controls.Add($FolderGroupBox)
|
||||
|
||||
#Definisco il bottone per selezionare folder Test
|
||||
$TestFolderButton = New-Object System.Windows.Forms.RadioButton
|
||||
$TestFolderButton.Location = New-Object System.Drawing.Point(20,20)
|
||||
$TestFolderButton.Size = New-Object System.Drawing.Size(400,23)
|
||||
$TestFolderButton.Text = "Test $TestDirectory"
|
||||
$TestFolderButton.Checked = $true
|
||||
$FolderGroupBox.Controls.Add($TestFolderButton)
|
||||
|
||||
#Definisco il bottone per selezionare folder Stable
|
||||
$StableFolderButton = New-Object System.Windows.Forms.RadioButton
|
||||
$StableFolderButton.Location = New-Object System.Drawing.Point(20,50)
|
||||
$StableFolderButton.Size = New-Object System.Drawing.Size(400,23)
|
||||
$StableFolderButton.Text = "Stable $StableDirectory"
|
||||
$FolderGroupBox.Controls.Add($StableFolderButton)
|
||||
|
||||
#Definisco il bottone per selezionare folder Custom
|
||||
$CustomFolderButton = New-Object System.Windows.Forms.RadioButton
|
||||
$CustomFolderButton.Location = New-Object System.Drawing.Point(20,80)
|
||||
$CustomFolderButton.Size = New-Object System.Drawing.Size(80,23)
|
||||
$CustomFolderButton.Text = 'Custom'
|
||||
$CustomFolderButton.Add_Click({
|
||||
$FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog
|
||||
$FolderBrowser.SelectedPath = "C:\"
|
||||
[void]$FolderBrowser.ShowDialog()
|
||||
$FolderBrowser.SelectedPath
|
||||
$CustomFolderText.Text = $FolderBrowser.SelectedPath
|
||||
})
|
||||
$FolderGroupBox.Controls.Add($CustomFolderButton)
|
||||
|
||||
#Definisco il textbox che mostra la folder custom
|
||||
$CustomFolderText = New-Object System.Windows.Forms.TextBox
|
||||
$CustomFolderText.Location = New-Object System.Drawing.Point(100,80)
|
||||
$CustomFolderText.Size = New-Object System.Drawing.Size(280,23)
|
||||
$CustomFolderText.Text = ''
|
||||
$CustomFolderText.Add_Click({
|
||||
$FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog
|
||||
$FolderBrowser.SelectedPath = "C:\"
|
||||
[void]$FolderBrowser.ShowDialog()
|
||||
$FolderBrowser.SelectedPath
|
||||
$CustomFolderText.Text = $FolderBrowser.SelectedPath
|
||||
})
|
||||
$FolderGroupBox.Controls.Add($CustomFolderText)
|
||||
|
||||
#Definisco un label per mostrare l'avanzamento dell'operazione in corso
|
||||
$PercentageLabel = New-Object System.Windows.Forms.Label
|
||||
$PercentageLabel.Location = New-Object System.Drawing.Point(220,340)
|
||||
$PercentageLabel.Size = New-Object System.Drawing.Size(280,20)
|
||||
$PercentageLabel.Text = ""
|
||||
$MachGrabForm.Controls.Add($PercentageLabel)
|
||||
|
||||
#Definisco la barra di avanzamento per mostrare il progresso della copia
|
||||
$CopyProgressBar = New-Object System.Windows.Forms.ProgressBar
|
||||
$CopyProgressBar.Width = 440
|
||||
$CopyProgressBar.Height = 20
|
||||
$CopyProgressBar.Location = New-Object System.Drawing.Point(20,360)
|
||||
$CopyProgressBar.Style = 'Continuous'
|
||||
$CopyProgressBar.Visible = $True
|
||||
$MachGrabForm.Controls.Add($CopyProgressBar)
|
||||
|
||||
#Definisco il bottone per lanciare la copia delle macchine richieste
|
||||
$GrabMachButton = New-Object System.Windows.Forms.Button
|
||||
$GrabMachButton.Location = New-Object System.Drawing.Point(20,400)
|
||||
$GrabMachButton.Size = New-Object System.Drawing.Size(100,23)
|
||||
$GrabMachButton.Text = 'Copia Macchine'
|
||||
#Quando l'utente clicca il copia macchine verifico la selezione richiesta e la cartella di destinazione
|
||||
$GrabMachButton.Add_Click({
|
||||
if ($BelottiButton.Checked -eq $true) {
|
||||
$SelMach = 'Belotti'
|
||||
}
|
||||
if ($CmsButton.Checked -eq $true) {
|
||||
$SelMach = 'CMS'
|
||||
}
|
||||
if ($EssetreButton.Checked -eq $true) {
|
||||
$SelMach = 'Essetre'
|
||||
}
|
||||
if ($MultiaxButton.Checked -eq $true) {
|
||||
$SelMach = 'Multiax'
|
||||
}
|
||||
if ($OmagButton.Checked -eq $true) {
|
||||
$SelMach = 'Omag'
|
||||
}
|
||||
if ($TestFolderButton.Checked -eq $true) {
|
||||
$SelDir = $TestDirectory
|
||||
}
|
||||
if ($StableFolderButton.Checked -eq $true) {
|
||||
$SelDir = $StableDirectory
|
||||
}
|
||||
if ($CustomFolderButton.Checked -eq $true) {
|
||||
$SelDir = $CustomFolderText.Text
|
||||
}
|
||||
#chiedo all'utente conferma della copia richiesta
|
||||
$UserConfirmation = [System.Windows.MessageBox]::Show("Copia macchine $SelMach in folder $SelDir ?",'Conferma copia','YesNo','Info')
|
||||
switch ($UserConfirmation){
|
||||
'Yes' {
|
||||
#chiamo funzione MachineCopy che fa il robocopy e mostra la barra di avanzamento in base al numero di cartelle da copiare
|
||||
MachineCopy $SelMach $SelDir
|
||||
[System.Windows.MessageBox]::Show("Macchine $SelMach copiate in $SelDir",'Operazione terminata')
|
||||
$CopyProgressBar.Value = $CopyProgressBar.Minimum
|
||||
$PercentageLabel.Text = ""
|
||||
}
|
||||
'No'{}
|
||||
}
|
||||
})
|
||||
$MachGrabForm.Controls.Add($GrabMachButton)
|
||||
|
||||
#Definisco il bottone per navigazione al menu precedente
|
||||
$MenuReturn = New-Object System.Windows.Forms.Button
|
||||
$MenuReturn.Location = New-Object System.Drawing.Point(360,400)
|
||||
$MenuReturn.Size = New-Object System.Drawing.Size(100,23)
|
||||
$MenuReturn.Text = 'Torna alla home'
|
||||
$MenuReturn.Add_Click({
|
||||
$MachGrabForm.Close()
|
||||
$MachGrabForm.Dispose()
|
||||
Powershell.exe -executionpolicy remotesigned -File .\GUI\EgtScriptsGUI.ps1
|
||||
})
|
||||
$MachGrabForm.Controls.Add($MenuReturn)
|
||||
|
||||
#Proprietà Topmost su $true per forzare l'apertura della finestra sopra altre finestre e finestre di dialogo aperte.
|
||||
$MachGrabForm.Topmost = $true
|
||||
|
||||
#Visualizzo il modulo:
|
||||
$MachGrabForm.ShowDialog()
|
||||
@@ -0,0 +1,155 @@
|
||||
# Esegue setup di BeamWall da repo Artifacts
|
||||
|
||||
Write-Output ""
|
||||
Write-Output "---------------------------------"
|
||||
Write-Output "| EgtBEAMWALL Last Release Test |"
|
||||
Write-Output "---------------------------------"
|
||||
Write-Output ""
|
||||
|
||||
#inizializzo variabili vuote
|
||||
$SelBranch = ""
|
||||
$SelArch = ""
|
||||
$ChosenBit = ""
|
||||
$ChosenDll = ""
|
||||
$ChosenDllD = ""
|
||||
|
||||
#Definisco path truenas di origine
|
||||
$Artifacts = '\\truenas\Artifacts'
|
||||
$BWSourceFolder = '\\truenas\Artifacts\EgtProg\EgtBEAMWALL'
|
||||
|
||||
#Definisco path test sottocartelle EgtBEAMWALL
|
||||
$TestProgBWFolder = 'c:\EgtTestProg\EgtBEAMWALL'
|
||||
$TestDataBWFolder = 'c:\EgtTestData\EgtBEAMWALL'
|
||||
|
||||
#Cerco le cartelle dei branch in \\truenas\Artifacts\EgtProg\EgtBEAMWALL
|
||||
Write-Output ""
|
||||
$BranchSelection = $false
|
||||
$Branches = Get-ChildItem -Path $BWSourceFolder -Directory
|
||||
$BranchCount = $Branches.Count
|
||||
|
||||
#Chiedo all'utente che branch desidera installare
|
||||
do{
|
||||
$idx = 1
|
||||
Write-Output "-----------------------------"
|
||||
foreach($item in $Branches)
|
||||
{
|
||||
Write-Output("$idx - $item")
|
||||
$idx++
|
||||
}
|
||||
Write-Output "-----------------------------"
|
||||
Write-Output ""
|
||||
Write-Output ""
|
||||
$SelBranch = @(Get-ChildItem $BWSourceFolder -Directory | Out-GridView -Title 'Scegli il branch EgtBeamWall da testare' -PassThru)
|
||||
$BranchSelection = ($numSel -le $BranchCount)
|
||||
} while(!$BranchSelection)
|
||||
|
||||
#Chiedo all'utente che architettura desidera installare
|
||||
Write-Output ""
|
||||
$ArchSelection = $false
|
||||
$Architectures = 'x86','x64'
|
||||
$ArchCount = $Architectures.Count
|
||||
|
||||
do{
|
||||
$idx = 1
|
||||
Write-Output "-----------------------------"
|
||||
foreach($item in $Architectures)
|
||||
{
|
||||
Write-Output("$idx - $item")
|
||||
$idx++
|
||||
}
|
||||
Write-Output "-----------------------------"
|
||||
Write-Output ""
|
||||
Write-Output ""
|
||||
$SelArch = @($Architectures | Out-GridView -Title 'Scegli architettura EgtBeamWall da testare' -PassThru)
|
||||
$ArchSelection = ($numSel -le $ArchCount)
|
||||
Write-Output $SelArch
|
||||
} while(!$ArchSelection)
|
||||
|
||||
#Switch fra 32 bit o 64 bit in base alla richiesta dell'utente
|
||||
if($SelArch -eq 'x86'){
|
||||
$ChosenBit = '32'
|
||||
$ChosenDll = 'Dll32'
|
||||
$ChosenDllD = 'DllD32'
|
||||
}
|
||||
else {
|
||||
$ChosenBit = '64'
|
||||
$ChosenDll = 'Dll64'
|
||||
$ChosenDllD = 'DllD64'
|
||||
}
|
||||
|
||||
#Pulisco cartella EgtTestProg\EgtBEAMWALL se già esistente, poi la creo
|
||||
if (Test-Path -Path $TestProgBWFolder) {
|
||||
"Prog esiste!"
|
||||
Remove-Item -Recurse $TestProgBWFolder\*.*
|
||||
} else {
|
||||
new-item $TestProgBWFolder -itemtype directory
|
||||
}
|
||||
|
||||
#Pulisco cartella EgtTestData\EgtBEAMWALL se già esistente, poi la creo
|
||||
if (Test-Path -Path $TestDataBWFolder) {
|
||||
"Data esiste!"
|
||||
Remove-Item -Recurse $TestDataBWFolder\*.*
|
||||
} else {
|
||||
new-item $TestDataBWFolder -itemtype directory
|
||||
}
|
||||
|
||||
#Pulisco cartella EgtTestData\EgtBEAMWALL\Temp se già esistente, poi la creo
|
||||
if (Test-Path -Path $TestDataBWFolder\Temp) {
|
||||
"Temp esiste!"
|
||||
Remove-Item -Recurse $TestDataBWFolder\Temp\*.*
|
||||
} else {
|
||||
new-item $TestDataBWFolder\Temp -itemtype directory
|
||||
}
|
||||
|
||||
#Pulisco cartella EgtTestData\EgtBEAMWALL\Macro se già esistente, poi la creo
|
||||
if (Test-Path -Path $TestDataBWFolder\Macro) {
|
||||
"Macro esiste!"
|
||||
Remove-Item -Recurse $TestDataBWFolder\Macro\*.*
|
||||
} else {
|
||||
new-item $TestDataBWFolder\Macro -itemtype directory
|
||||
}
|
||||
|
||||
#Pulisco cartella EgtTestData\EgtBEAMWALL\Config se già esistente, poi la creo
|
||||
if (Test-Path -Path $TestDataBWFolder\Config) {
|
||||
"Config esiste!"
|
||||
Remove-Item -Recurse $TestDataBWFolder\Config\*.*
|
||||
} else {
|
||||
new-item $TestDataBWFolder\Config -itemtype directory
|
||||
}
|
||||
|
||||
#Copio la cartella Config
|
||||
ROBOCOPY /E $Artifacts\EgtProg\EgtBEAMWALL_Config\Config\ $TestDataBWFolder\Config
|
||||
|
||||
#Copio la cartella Messages
|
||||
ROBOCOPY /E $Artifacts\EGT_SRV\EgtTech\EgtData\Messages $TestDataBWFolder\Config
|
||||
|
||||
#Copio la cartella Fonts
|
||||
ROBOCOPY /E $Artifacts\EGT_SRV\EgtTech\EgtProg\Fonts\ $TestDataBWFolder\Fonts
|
||||
|
||||
#Copio DataRoot.ini custom in c:\EgtTestProg\EgtBEAMWALL
|
||||
ROBOCOPY /E $Artifacts\EgtProg\EgtBEAMWALL_Config\ $TestProgBWFolder DataRoot.ini
|
||||
|
||||
#Copio il file Medium.ini in \Warehouse
|
||||
ROBOCOPY /E $Artifacts\EGT_SRV\EgtTech\EgtData\EgtBEAMWALL\Warehouse\ $TestDataBWFolder\Warehouse Medium.ini
|
||||
|
||||
#Copio Resources
|
||||
ROBOCOPY /E $Artifacts\EGT_SRV\EgtTech\EgtData\EgtBEAMWALL\Resources\ $TestDataBWFolder\Resources
|
||||
|
||||
#Copio la sottocartella 32 o 64 bit di Lualibs a seconda della richiesta
|
||||
ROBOCOPY /E $Artifacts\EGT_SRV\EgtTech\EgtProg\LuaLibs\$ChosenBit $TestDataBWFolder\Lualibs
|
||||
|
||||
#Copio la cartella Dll32 o Dll64 a seconda della richiesta
|
||||
ROBOCOPY /E $Artifacts\EGT_SRV\EgtTech\EgtProg\$ChosenDll $TestProgBWFolder
|
||||
|
||||
#Copio la cartella DllD32 o DllD64 a seconda della richiesta
|
||||
ROBOCOPY /E $Artifacts\EGT_SRV\EgtTech\EgtProg\$ChosenDllD $TestProgBWFolder
|
||||
|
||||
#Copio Versione + Architettura di BEAMWALL richieste
|
||||
ROBOCOPY /E $Artifacts\EgtProg\EgtBEAMWALL\$SelBranch\$SelArch $TestProgBWFolder
|
||||
|
||||
#Cancello tutti i .exe.config e .dll.config perchè problematici in area Test
|
||||
Remove-Item -Recurse $TestProgBWFolder\*.exe.config
|
||||
Remove-Item -Recurse $TestProgBWFolder\*.dll.config
|
||||
|
||||
#Chiudo lanciando lo Script Manager per altre operazioni
|
||||
Powershell.exe -executionpolicy remotesigned -File .\EgtScriptsManager.ps1
|
||||
@@ -0,0 +1,246 @@
|
||||
# Esegue setup versione richiesta di BeamWall da repo Artifacts
|
||||
|
||||
Write-Output "-----------------------------"
|
||||
Write-Output "- EgtBeamWall "
|
||||
Write-Output "-----------------------------"
|
||||
Write-Output ""
|
||||
Write-Output ""
|
||||
|
||||
$rPath = "\\10.74.82.50\EgtTech\"
|
||||
$rUser = "10.74.82.50\Server"
|
||||
$rPwd = "Dossena"
|
||||
$zPath = "\\truenas\Artifacts\EgtProg\EgtBEAMWALL"
|
||||
$zPathC = "\\truenas\Artifacts\EgtProg\EgtBEAMWALL_Config"
|
||||
$progPath = "C:\EgtTestProg\EgtBEAMWALL"
|
||||
$dataPath = "C:\EgtTestData"
|
||||
$arch64 =""
|
||||
$branch =""
|
||||
$APP_NAME = "c:\EgtTestProg\EgtCAM5"
|
||||
|
||||
$Folder1 = 'c:\EgtTestProg'
|
||||
$Folder2 = 'c:\EgtTestData'
|
||||
|
||||
"Test to see if folder [$Folder1] exists"
|
||||
if (Test-Path -Path $Folder1) {
|
||||
"Prog esiste!"
|
||||
#rm -Recurse $Folder1\*.*
|
||||
} else {
|
||||
new-item c:\EgtTestProg\EgtBEAMWALL -itemtype directory
|
||||
}
|
||||
|
||||
if (Test-Path -Path $Folder2) {
|
||||
"Data esiste!"
|
||||
#rm -Recurse $Folder2\*.*
|
||||
} else {
|
||||
new-item c:\EgtTestData\EgtBEAMWALL -itemtype directory
|
||||
}
|
||||
|
||||
|
||||
if ([System.IO.Directory]::Exists('V:\')) {
|
||||
"Path exists!"
|
||||
} else {
|
||||
$secpasswd = ConvertTo-SecureString "Dossena" -AsPlainText -Force
|
||||
$mycreds = New-Object System.Management.Automation.PSCredential ("10.74.82.50\Server", $secpasswd)
|
||||
New-SmbMapping -LocalPath 'V:' -RemotePath '\\10.74.82.50\EgtTech' -Username '10.74.82.50\Server' -Password 'Dossena'
|
||||
}
|
||||
|
||||
if ([System.IO.Directory]::Exists('U:\')) {
|
||||
"Path exists!"
|
||||
} else {
|
||||
$secpasswd = ConvertTo-SecureString "Egalware_24068!" -AsPlainText -Force
|
||||
$mycreds = New-Object System.Management.Automation.PSCredential ("steamw\egalware", $secpasswd)
|
||||
New-SmbMapping -LocalPath 'U:' -RemotePath '\\10.74.82.201\Artifacts' -Username 'steamw\egalware' -Password 'Egalware_24068!'
|
||||
}
|
||||
|
||||
$Folder5 = 'c:\EgtTestData\EgtBEAMWALL\Fonts'
|
||||
if (Test-Path -Path $Folder5) {
|
||||
"Font esiste!"
|
||||
rm -Recurse $Folder5\*.*
|
||||
} else {
|
||||
new-item c:\EgtTestData\EgtBEAMWALL\Fonts -itemtype directory
|
||||
}
|
||||
|
||||
$Folder6 = 'c:\EgtTestData\EgtBEAMWALL\Temp'
|
||||
if (Test-Path -Path $Folder6) {
|
||||
"Temp esiste!"
|
||||
rm -Recurse $Folder6\*.*
|
||||
} else {
|
||||
new-item c:\EgtTestData\EgtBEAMWALL\Temp -itemtype directory
|
||||
}
|
||||
|
||||
$Folder7 = 'c:\EgtTestData\EgtBEAMWALL\Config'
|
||||
if (Test-Path -Path $Folder7) {
|
||||
"Config esiste!"
|
||||
rm -Recurse $Folder7\*.*
|
||||
} else {
|
||||
new-item c:\EgtTestData\Fonts -itemtype directory
|
||||
}
|
||||
|
||||
# ora chiedo quale branch scegliere
|
||||
Write-Output ""
|
||||
$valOk = $false
|
||||
$altern = Get-ChildItem -Path $zPath -Directory
|
||||
$numFolder = $altern.Count
|
||||
|
||||
do{
|
||||
$idx = 1
|
||||
Write-Output "-----------------------------"
|
||||
foreach($item in $altern)
|
||||
{
|
||||
Write-Output("$idx - $item")
|
||||
$idx++
|
||||
}
|
||||
Write-Output "-----------------------------"
|
||||
Write-Output ""
|
||||
Write-Output ""
|
||||
$branch = @(Get-ChildItem $zPath -Directory | Out-GridView -Title 'Scegli il branch' -PassThru)
|
||||
$valOk = ($numSel -le $numFolder)
|
||||
|
||||
} while(!$valOk)
|
||||
|
||||
|
||||
|
||||
#$valOk = $false
|
||||
#do{
|
||||
# $arch64 = Read-Host "Vuoi Architettura 64 bit (s/n)"
|
||||
# $valOk = ($arch64.ToUpper() -eq "N" -or $arch64.ToUpper() -eq "S")
|
||||
#} while(!$valOk)
|
||||
|
||||
#Write-Output "64 bit: $arch64"
|
||||
|
||||
# ora chiedo quale variante vuole
|
||||
Write-Output ""
|
||||
$valOk = $false
|
||||
$altern = Get-ChildItem -Path $zPath -Directory
|
||||
$numFolder = $altern.Count
|
||||
|
||||
#do{
|
||||
# $idx = 1
|
||||
# Write-Output "-----------------------------"
|
||||
# foreach($item in $altern)
|
||||
# {
|
||||
# Write-Output("$idx - $item")
|
||||
# $idx++
|
||||
# }
|
||||
# Write-Output "-----------------------------"
|
||||
# Write-Output ""
|
||||
# Write-Output ""
|
||||
# $choice = @(Get-ChildItem $zPath\$branch | Out-GridView -Title 'Scegli architettura x64 o x32' -PassThru)
|
||||
# Write-Output "$choice"
|
||||
# $valOk = ($numSel -le $numFolder)
|
||||
#
|
||||
#} while(!$valOk)
|
||||
|
||||
function Show-MenuA
|
||||
{
|
||||
param (
|
||||
[string]$Title = 'Seleziona Architettura da testare'
|
||||
)
|
||||
Clear-Host
|
||||
Write-Host "================ $Title ================"
|
||||
|
||||
Write-Host "1: Premi '1' per x86"
|
||||
Write-Host "2: Premi '2' per x64"
|
||||
Write-Host "q: Premi 'q' per uscire dal programma."
|
||||
}
|
||||
|
||||
Show-MenuA –Title 'Seleziona Architettura da testare'
|
||||
|
||||
$selection = Read-Host "Seleziona"
|
||||
switch ($selection)
|
||||
{
|
||||
'1' {
|
||||
$choice = 'x86'
|
||||
'Hai scelto 32'
|
||||
} '2' {
|
||||
$choice = 'x64'
|
||||
'Hai scelto 64'
|
||||
} 'q' {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
#function Show-Menu
|
||||
#{
|
||||
# param (
|
||||
# [string]$Title = 'Seleziona Architettura Lualibs'
|
||||
# )
|
||||
# Clear-Host
|
||||
# Write-Host "================ $Title ================"
|
||||
#
|
||||
# Write-Host "1: Premi '1' per 32"
|
||||
# Write-Host "2: Premi '2' per 64"
|
||||
# Write-Host "q: Premi 'q' per uscire dal programma."
|
||||
#}
|
||||
#
|
||||
#Show-Menu –Title 'Seleziona Architettura Lualibs'
|
||||
#
|
||||
#$selection = Read-Host "Seleziona"
|
||||
# switch ($selection)
|
||||
# {
|
||||
# '1' {
|
||||
# $choiceL = '32'
|
||||
# 'Hai scelto 32'
|
||||
# } '2' {
|
||||
# $choiceL = '64'
|
||||
# 'Hai scelto 64'
|
||||
# } 'q' {
|
||||
# return
|
||||
# }
|
||||
# }
|
||||
|
||||
# function Show-MenuC
|
||||
#{
|
||||
# param (
|
||||
# [string]$Title = 'Seleziona Architettura Librerie C'
|
||||
# )
|
||||
# Clear-Host
|
||||
# Write-Host "================ $Title ================"
|
||||
#
|
||||
# Write-Host "1: Premi '1' per 32"
|
||||
# Write-Host "2: Premi '2' per 64"
|
||||
# Write-Host "q: Premi 'q' per uscire dal programma."
|
||||
#}
|
||||
#
|
||||
#Show-MenuC –Title 'Seleziona Architettura Librerie C'
|
||||
#
|
||||
#$selection2 = Read-Host "Seleziona"
|
||||
# switch ($selection2)
|
||||
# {
|
||||
# '1' {
|
||||
# $choiceC = 'Dll32'
|
||||
# 'Hai scelto 32'
|
||||
# } '2' {
|
||||
# $choiceC = 'Dll64'
|
||||
# 'Hai scelto 64'
|
||||
# } 'q' {
|
||||
# return
|
||||
# }
|
||||
# }
|
||||
|
||||
if($choice -eq 'x86'){
|
||||
$choiceL = '32'
|
||||
$choiceC = 'Dll32'
|
||||
}else {
|
||||
$choiceL = '64'
|
||||
$choiceC = 'Dll64'
|
||||
}
|
||||
|
||||
|
||||
#$choiceL = @(Get-ChildItem V:\EgtProg\LuaLibs\ | Out-GridView -Title 'Scegli architettura Lualibs' -PassThru)
|
||||
|
||||
#$choiceC = @(Get-ChildItem V:\EgtProg\ | Out-GridView -Title 'Scegli architettura Librerie C' -PassThru)
|
||||
|
||||
ROBOCOPY /E U:\EgtProg\EgtBEAMWALL\$branch\$choice $progPath
|
||||
|
||||
ROBOCOPY /E U:\EgtProg\EgtBEAMWALL_Config\Config $dataPath\EgtBEAMWALL\Config
|
||||
|
||||
ROBOCOPY /E V:\EgtProg\LuaLibs\$choiceL $dataPath\Lualibs
|
||||
|
||||
ROBOCOPY /E U:\EgtProg\EgtBEAMWALL_Config $progPath DataRoot.ini
|
||||
|
||||
ROBOCOPY /E V:\EgtProg\$choiceC $progPath
|
||||
|
||||
#ROBOCOPY /E Z:\EgtData\Messages $dataPath\EgtBEAMWALL\Config
|
||||
|
||||
ROBOCOPY /E V:\EgtProg\Fonts $Folder5
|
||||
@@ -0,0 +1,177 @@
|
||||
# Esegue setup versione richiesta di BeamWall da repo Artifacts
|
||||
|
||||
Write-Output "-----------------------------"
|
||||
Write-Output "- EgtBeamWall "
|
||||
Write-Output "-----------------------------"
|
||||
Write-Output ""
|
||||
Write-Output ""
|
||||
|
||||
$rPath = "\\10.74.82.50\EgtTech\"
|
||||
$rUser = "10.74.82.50\Server"
|
||||
$rPwd = "Dossena"
|
||||
$zPath = "\\truenas\Artifacts\EgtProg\EgtBEAMWALL"
|
||||
$zPathC = "\\truenas\Artifacts\EgtProg\EgtBEAMWALL_Config"
|
||||
$zPathS = "\\truenas\Artifacts\EgtCAM5"
|
||||
$zPathD = "\\truenas\Artifacts\EgtData"
|
||||
$zPath5 = "\\truenas\Artifacts\EgtProg\EgtCAM5\Config"
|
||||
$progPath = "C:\EgtTestProg\EgtBEAMWALL"
|
||||
$dataPath = "C:\EgtTestData"
|
||||
$arch64 =""
|
||||
$branch =""
|
||||
$APP_NAME = "c:\EgtTestProg\EgtCAM5"
|
||||
|
||||
$Folder1 = 'c:\EgtTestProg'
|
||||
$Folder2 = 'c:\EgtTestData'
|
||||
|
||||
"Test to see if folder [$Folder1] exists"
|
||||
if (Test-Path -Path $Folder1) {
|
||||
"Prog esiste!"
|
||||
rm -Recurse $Folder1\*.*
|
||||
} else {
|
||||
new-item c:\EgtTestProg\EgtBEAMWALL -itemtype directory
|
||||
}
|
||||
|
||||
if (Test-Path -Path $Folder2) {
|
||||
"Data esiste!"
|
||||
rm -Recurse $Folder2\*.*
|
||||
} else {
|
||||
new-item c:\EgtTestData\EgtBEAMWALL -itemtype directory
|
||||
}
|
||||
|
||||
|
||||
if ([System.IO.Directory]::Exists('V:\')) {
|
||||
"Path exists!"
|
||||
} else {
|
||||
$secpasswd = ConvertTo-SecureString "Dossena" -AsPlainText -Force
|
||||
$mycreds = New-Object System.Management.Automation.PSCredential ("10.74.82.50\Server", $secpasswd)
|
||||
New-SmbMapping -LocalPath 'V:' -RemotePath '\\10.74.82.50\EgtTech' -Username '10.74.82.50\Server' -Password 'Dossena'
|
||||
}
|
||||
|
||||
if ([System.IO.Directory]::Exists('U:\')) {
|
||||
"Path exists!"
|
||||
} else {
|
||||
$secpasswd = ConvertTo-SecureString "Egalware_24068!" -AsPlainText -Force
|
||||
$mycreds = New-Object System.Management.Automation.PSCredential ("steamw\egalware", $secpasswd)
|
||||
New-SmbMapping -LocalPath 'U:' -RemotePath '\\10.74.82.201\Artifacts' -Username 'steamw\egalware' -Password 'Egalware_24068!'
|
||||
}
|
||||
|
||||
$Folder4 = 'c:\EgtTestProg\EgtCAM5'
|
||||
if (Test-Path -Path $Folder4) {
|
||||
"EgtCAM5 esiste!"
|
||||
rm -Recurse $Folder4\*.*
|
||||
} else {
|
||||
new-item c:\EgtTestProg\EgtCAM5 -itemtype directory
|
||||
}
|
||||
|
||||
$Folder4v2 = 'c:\EgtTestData\EgtCAM5'
|
||||
if (Test-Path -Path $Folder4v2) {
|
||||
"EgtCAM5 esiste!"
|
||||
rm -Recurse $Folder4v2\*.*
|
||||
} else {
|
||||
new-item c:\EgtTestData\EgtCAM5 -itemtype directory
|
||||
}
|
||||
|
||||
function Show-Menu
|
||||
{
|
||||
param (
|
||||
[string]$Title = 'Seleziona Architettura da testare'
|
||||
)
|
||||
Clear-Host
|
||||
Write-Host "================ $Title ================"
|
||||
|
||||
Write-Host "1: Premi '1' per 32"
|
||||
Write-Host "2: Premi '2' per 64"
|
||||
Write-Host "q: Premi 'q' per uscire dal programma."
|
||||
}
|
||||
|
||||
Show-Menu –Title 'Seleziona Architettura da testare'
|
||||
|
||||
$selection = Read-Host "Seleziona"
|
||||
switch ($selection)
|
||||
{
|
||||
'1' {
|
||||
$choiceD = '32'
|
||||
'Hai scelto 32'
|
||||
} '2' {
|
||||
$choiceD = '64'
|
||||
'Hai scelto 64'
|
||||
} 'q' {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
# function Show-MenuC
|
||||
#{
|
||||
# param (
|
||||
# [string]$Title = 'Seleziona Architettura Librerie C'
|
||||
# )
|
||||
# Clear-Host
|
||||
# Write-Host "================ $Title ================"
|
||||
#
|
||||
# Write-Host "1: Premi '1' per 32"
|
||||
# Write-Host "2: Premi '2' per 64"
|
||||
# Write-Host "q: Premi 'q' per uscire dal programma."
|
||||
#}
|
||||
#
|
||||
#Show-MenuC –Title 'Seleziona Architettura Librerie C'
|
||||
#
|
||||
#$selection2 = Read-Host "Seleziona"
|
||||
# switch ($selection2)
|
||||
# {
|
||||
# '1' {
|
||||
# $choiceC = 'Dll32'
|
||||
# 'Hai scelto 32'
|
||||
# } '2' {
|
||||
# $choiceC = 'Dll64'
|
||||
# 'Hai scelto 64'
|
||||
# } 'q' {
|
||||
# return
|
||||
# }
|
||||
# }
|
||||
|
||||
if($choiceD -eq '32'){
|
||||
$choiceC = 'Dll32'
|
||||
}else {
|
||||
$choiceC = 'Dll64'
|
||||
}
|
||||
|
||||
#$choiceL = @(Get-ChildItem Z:\EgtProg\LuaLibs\ | Out-GridView -Title 'Scegli architettura Lualibs' -PassThru)
|
||||
|
||||
#$choiceC = @(Get-ChildItem Z:\EgtProg\ | Out-GridView -Title 'Scegli architettura Librerie C' -PassThru)
|
||||
|
||||
#$choiceD = @(Get-ChildItem U:\EgtData\Beam | Out-GridView -Title 'Scegli architettura Librerie Beam\Wall\BEamWall' -PassThru)
|
||||
|
||||
ROBOCOPY /E V:\EgtProg\LuaLibs\$choiceD $dataPath\Lualibs
|
||||
|
||||
ROBOCOPY /E V:\EgtProg\$choiceC $APP_NAME
|
||||
|
||||
#ROBOCOPY /E Z:\EgtData\Messages $dataPath\EgtBEAMWALL\Config
|
||||
|
||||
ROBOCOPY /E V:\EgtProg\EgtCAM5 $Folder4
|
||||
|
||||
ROBOCOPY /E U:\EgtCAM5 $Folder4v2
|
||||
|
||||
ROBOCOPY /E U:\EgtProg\EgtCAM5\Config $Folder4 DataRoot.ini
|
||||
|
||||
ROBOCOPY /E V:\EgtProg\Fonts $Folder4v2\Fonts
|
||||
|
||||
ROBOCOPY /E V:\EgtProg\LuaLibs\$choiceD $Folder4v2\Lualibs
|
||||
|
||||
#ROBOCOPY /E \\EGALTECHSERVER\EgtTech\EgtData\Machines $dataPath\EgtCAM5\Machines Essetre-*
|
||||
|
||||
$altern = Get-ChildItem -Path V:\EgtData\Machines -Directory | Select-String -Pattern "Essetre"
|
||||
|
||||
foreach($item in $altern)
|
||||
{
|
||||
ROBOCOPY V:\EgtData\Machines\$item $dataPath\EgtCAM5\Machines\$item /MIR /FFT
|
||||
}
|
||||
|
||||
#ROBOCOPY \\EGALTECHSERVER\EgtTech\EgtData\Machines $dataPath\EgtCAM5\Machines /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XD \\EGALTECHSERVER\EgtTech\EgtData\Machines\Multiax*
|
||||
|
||||
ROBOCOPY /E V:\EgtData\ToolMakers $Folder4v2\ToolMakers
|
||||
|
||||
ROBOCOPY /E U:\EgtData\Beam\$choiceD $Folder4v2\Beam
|
||||
|
||||
ROBOCOPY /E U:\EgtData\Wall\$choiceD $Folder4v2\Wall
|
||||
|
||||
ROBOCOPY /E U:\EgtData\BeamWall\$choiceD $Folder4v2\BeamWall
|
||||
@@ -104,6 +104,6 @@ else {
|
||||
# fermo stopwatch e conteggio...
|
||||
$stopwatch.Stop()
|
||||
$durata = $stopwatch.Elapsed.TotalSeconds
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gpw.Proj -o $durata
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gpw.Proj -o $durata
|
||||
LogWrite("Durata esecuzione: $durata")
|
||||
}
|
||||
@@ -65,5 +65,5 @@ finally
|
||||
# fermo stopwatch e conteggio...
|
||||
$stopwatch.Stop()
|
||||
$durata = $stopwatch.Elapsed.TotalSeconds
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k LiMan.Lic -o $durata
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k LiMan.Lic -o $durata
|
||||
LogWrite("Durata esecuzione: $durata")
|
||||
@@ -104,5 +104,5 @@ finally
|
||||
# fermo stopwatch e conteggio...
|
||||
$stopwatch.Stop()
|
||||
$durata = $stopwatch.Elapsed.TotalSeconds
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gpw.Timb -o $durata
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gpw.Timb -o $durata
|
||||
LogWrite("Durata esecuzione: $durata")
|
||||
@@ -80,5 +80,5 @@ finally
|
||||
# fermo stopwatch e conteggio...
|
||||
$stopwatch.Stop()
|
||||
$durata = $stopwatch.Elapsed.TotalSeconds
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gpw.Core -o $durata
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "W2022-IIS04" -k Gpw.Core -o $durata
|
||||
LogWrite("Durata esecuzione: $durata")
|
||||
@@ -0,0 +1,52 @@
|
||||
#######PREDISPOSIZIONE FILE, FOLDER E FUNZIONE DI LOG#######
|
||||
|
||||
#definisco cartella file di log
|
||||
$logFolder = "c:\EgwLogs\"
|
||||
#definisco nome file di log
|
||||
$logFile = "ExampleLog1.log"
|
||||
|
||||
#verifico se esiste la cartella di log
|
||||
if (Test-Path $logFolder) {
|
||||
}
|
||||
#se non esiste la cartella di log la creo
|
||||
else {
|
||||
New-Item $logFolder -ItemType Directory
|
||||
}
|
||||
|
||||
#rilevo time per log inizio analisi
|
||||
$dateTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#funzione per scrittura output & log
|
||||
Function WriteLogOutput {
|
||||
Param ($logFile, [string]$logString)
|
||||
#compongo path per file di log
|
||||
$logPath = Join-Path $logFolder $logFile
|
||||
#aggiungo il contenuto della stringa da loggare
|
||||
Add-content $logPath -value "$logString"
|
||||
#scrivo a terminale il contenuto della stringa da loggare
|
||||
Write-Output($logString)
|
||||
}
|
||||
|
||||
#compongo URL da chiamare con successivo try/catch
|
||||
######### $callUrl = "https://URL/DA/CHIAMARE" + $varieEventuiali + "/EVENTUALE URL/" + $varieEventuali
|
||||
#eseguo call url con try/catch
|
||||
try {
|
||||
######### $Response = Invoke-WebRequest -URI $callUrl -Headers $EventualeHeader -ContentType "application/json" -UseBasicParsing
|
||||
#converto da Json la risposta in caso di esito positivo del try/catch
|
||||
$parsedResponse = $Response.Content | ConvertFrom-Json
|
||||
#scrivo su log data/ora e risposta convertita dal Json
|
||||
WriteLogOutput $logFile "--------------------"
|
||||
WriteLogOutput $logFile "Date/Time: $dateTime"
|
||||
WriteLogOutput $logFile "Response:"
|
||||
WriteLogOutput $logFile $($parsedResponse.message)
|
||||
}
|
||||
#scrivo se trovo un errore durante il try/catch
|
||||
catch {
|
||||
#converto da Json l'eventuale errore in caso di esito negativo del try/catch
|
||||
$parsedError = $_ | Out-String | ConvertFrom-Json
|
||||
#scrivo su log data/ora e errore convertito dal Json
|
||||
WriteLogOutput $logFile "--------------------"
|
||||
WriteLogOutput $logFile "Date/Time: $dateTime"
|
||||
WriteLogOutput $logFile "Error:"
|
||||
WriteLogOutput $logFile $($parsedError.message)
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
$LogPath = "C:\inetpub\logs"
|
||||
$maxDaystoKeep = -90
|
||||
$outputPath = "C:\Steamware\Logs\Cleanup_Logs.log"
|
||||
|
||||
Write-Output "Start Cleanup" > $outputPath
|
||||
|
||||
$itemsToDelete = dir $LogPath -Recurse -File *.log | Where LastWriteTime -lt ((get-date).AddDays($maxDaystoKeep))
|
||||
|
||||
if ($itemsToDelete.Count -gt 0){
|
||||
ForEach ($item in $itemsToDelete){
|
||||
"$($item.BaseName) is older than $((get-date).AddDays($maxDaystoKeep)) and will be deleted" | Add-Content $outputPath
|
||||
Remove-Item $item.FullName -Verbose
|
||||
}
|
||||
}
|
||||
ELSE{
|
||||
"No items to be deleted today $($(Get-Date).DateTime)" | Add-Content $outputPath
|
||||
}
|
||||
|
||||
Write-Output "Cleanup of log files older than $((get-date).AddDays($maxDaystoKeep)) completed..."
|
||||
start-sleep -Seconds 3
|
||||
@@ -0,0 +1 @@
|
||||
net use S: \\egw-tnas-00\Scambio
|
||||
@@ -0,0 +1 @@
|
||||
net use S: /delete
|
||||
@@ -34,4 +34,4 @@ Remove-Variable * -ErrorAction SilentlyContinue # pulisco variabili x ISE
|
||||
|
||||
$durata = 5
|
||||
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabbix.ufficio -s "IIS04" -k TESTER -o $durata
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabbix.ufficio -s "W2022-IIS04" -k TESTER -o $durata
|
||||
@@ -0,0 +1,25 @@
|
||||
###SCRIPT PER MOUNT DISCO B (VHDX REMOTO)###
|
||||
|
||||
$hostname = hostname
|
||||
$date = Get-Date
|
||||
$filePath = "C:\Steamware\Log\" + $hostname + "_Mount_B.log"
|
||||
$intestazione = $hostname + " " + $date
|
||||
#diskpath varia in base alla singola macchina veeam
|
||||
$diskpath = ###SCRIVERE PATH NECESSARIO
|
||||
|
||||
#verifico se esiste file di log, se non esiste lo creo e scrivo intestazione
|
||||
if(!(Test-Path -Path $filePath)) {
|
||||
Out-File -FilePath $filePath -InputObject $intestazione
|
||||
}
|
||||
else {
|
||||
Out-File -FilePath $filePath -InputObject $intestazione -Append
|
||||
}
|
||||
|
||||
#verifico se è presente disco B:, se assente eseguo Mount-Diskimage per montarlo
|
||||
if(!(Test-Path -Path "B:")) {
|
||||
Mount-DiskImage -ImagePath $diskpath
|
||||
Out-File -FilePath $filePath -InputObject "Eseguito Mount-Diskimage per disco B:" -Append
|
||||
}
|
||||
else {
|
||||
Out-File -FilePath $filePath -InputObject "Disco B: già montato" -Append
|
||||
}
|
||||
@@ -2,60 +2,63 @@
|
||||
|
||||
####INIZIO DICHIARAZIONE VARIABILI####
|
||||
|
||||
# num gg per cui tenere i log
|
||||
$Days = "30"
|
||||
$CutoffDate = (Get-Date).AddDays(-$Days)
|
||||
|
||||
#rilevo time per log inizio analisi
|
||||
$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
# avvio stopwatch
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
$mainStopWatch = [system.diagnostics.stopwatch]::StartNew()
|
||||
|
||||
#abilitazione log: 0=disattivo, 1=abilitato
|
||||
$logEnable = 0
|
||||
|
||||
#cartella file di log
|
||||
$WdcLogFolder="c:\Steamware\Logs\WDC\"
|
||||
$WdcLogFolder = "c:\Steamware\Logs\WDC\"
|
||||
|
||||
#nome file di log
|
||||
$logFile = Join-Path $WdcLogFolder "WDC_Log.log"
|
||||
$dayName = "WDC_" + (Get-Date).toString("yyyy-MM-dd") + ".log"
|
||||
$logFile = Join-Path $WdcLogFolder $dayName
|
||||
|
||||
#folder source per robocopy
|
||||
$sourceFolder = "\\stor01\TEAM DRIVES\30_Clienti\ABH\DataImport\Compo"
|
||||
$sourceFolder = "U:\NextCloud\ABH\Compo"
|
||||
|
||||
#folder destination per robocopy
|
||||
$destFolder = "\\IIS04\WebDoorSync\NewComp\Compo"
|
||||
$destFolder = "U:\WebDoorSync\NewComp\Compo"
|
||||
|
||||
# ex W2022-IIS04
|
||||
#$sourceFolder = "\\stor01\TEAM DRIVES\30_Clienti\ABH\DataImport\Compo"
|
||||
#$destFolder = "\\W2022-IIS04\WebDoorSync\NewComp\Compo"
|
||||
|
||||
####FINE DICHIARAZIONE VARIABILI####
|
||||
|
||||
#dichiaro funzione per scrittura output
|
||||
Function WriteLogOutput
|
||||
{
|
||||
Function WriteLogOutput {
|
||||
Param ([string]$logString)
|
||||
#scrivo su file la stringa
|
||||
Add-content $logFile -value "$logString"
|
||||
#scrivo su terminale la stringa se $logEnable=1
|
||||
if($logEnable -eq 1){
|
||||
if ($logEnable -eq 1) {
|
||||
Write-Output($logString)
|
||||
}
|
||||
}
|
||||
|
||||
#creazione folder di Log se non già esistente
|
||||
if (Test-Path $WdcLogFolder)
|
||||
{
|
||||
if (Test-Path $WdcLogFolder) {
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
New-Item $WdcLogFolder -ItemType Directory
|
||||
}
|
||||
|
||||
#effettuo robocopy
|
||||
try
|
||||
{
|
||||
try {
|
||||
WriteLogOutput "------WDC SYNC------"
|
||||
if ($logEnable -eq 1)
|
||||
{
|
||||
if ($logEnable -eq 1) {
|
||||
robocopy $sourceFolder $destFolder /mir /log+:$logFile
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
WriteLogOutput ""
|
||||
WriteLogOutput "Started: $startTime"
|
||||
WriteLogOutput "Source: $sourceFolder"
|
||||
@@ -64,11 +67,14 @@ try
|
||||
}
|
||||
WriteLogOutput "Robocopy OK"
|
||||
}
|
||||
catch
|
||||
{
|
||||
catch {
|
||||
WriteLogOutput "An error occurred"
|
||||
}
|
||||
|
||||
# elimino file log troppo vecchi
|
||||
Get-ChildItem -Path $WdcLogFolder -Recurse -File | Where-Object { $_.LastWriteTime -lt $CutoffDate } | Remove-Item -Force
|
||||
WriteLogOutput "Log Cleanup complete!"
|
||||
|
||||
# fermo stopwatch e calcolo durata script
|
||||
$mainStopWatch.Stop()
|
||||
$durataScript = $mainStopWatch.Elapsed.TotalSeconds
|
||||
@@ -0,0 +1,130 @@
|
||||
# CheckLocalGitStatus
|
||||
#
|
||||
# Verifica di un set di repo GIT locali rispetto al server origin remoto
|
||||
# per stabilire quali necessitino di aggiornamento
|
||||
#
|
||||
# esempio chiamata:
|
||||
|
||||
# parametri in ingresso
|
||||
param (
|
||||
[string]$RootPath = "C:\Users\samuele.steamw\source", # Default alla cartella dei sorgenti, da passare invocando il comando
|
||||
[switch]$SwitchToMain,
|
||||
[string]$OutputFile = "$PSScriptRoot\outdated_repos.txt",
|
||||
[switch]$Help
|
||||
)
|
||||
|
||||
$branchesToCheck = @("main", "master")
|
||||
$outdatedRepos = @()
|
||||
|
||||
# Mostra help message se --help or -h passato come argomento
|
||||
if ($Help -or $args -contains "--help" -or $args -contains "-h") {
|
||||
Write-Host @"
|
||||
Usage: .\Check-GitRepos.ps1 [-RootPath <path>] [-SwitchToMain] [-OutputFile <file>] [--help]
|
||||
|
||||
Checks all Git repositories under the specified folder and compares their main/master branch
|
||||
with the remote origin. Optionally switches to main/master to perform the check.
|
||||
|
||||
Parameters:
|
||||
-RootPath Path to the root folder containing Git repositories (default: current script path)
|
||||
-SwitchToMain Temporarily switch to main/master branch to perform the check
|
||||
-OutputFile Path to the output file listing outdated repositories
|
||||
--help, -h Show this help message
|
||||
|
||||
Examples:
|
||||
.\Check-GitRepos.ps1 -RootPath "D:\Dev\Projects"
|
||||
.\Check-GitRepos.ps1 -SwitchToMain
|
||||
.\Check-GitRepos.ps1 -RootPath "C:\Code" -SwitchToMain -OutputFile "C:\outdated.txt"
|
||||
"@ -ForegroundColor Cyan
|
||||
exit
|
||||
}
|
||||
|
||||
|
||||
# Function to check Git status
|
||||
function Check-GitStatus {
|
||||
param (
|
||||
[string]$repoPath,
|
||||
[string]$OutputFile
|
||||
)
|
||||
|
||||
Write-Host "`nChecking repository at: $repoPath" -ForegroundColor Cyan
|
||||
Push-Location $repoPath
|
||||
|
||||
if (-not (Test-Path ".git")) {
|
||||
Write-Host "Not a Git repository." -ForegroundColor Yellow
|
||||
"$((Get-Date).ToString('yyyy-MM-dd HH:mm:ss')) - Not a Git repository." | Out-File -FilePath $OutputFile -Append -Encoding UTF8
|
||||
Pop-Location
|
||||
return
|
||||
}
|
||||
|
||||
git fetch origin *> $null 2>&1
|
||||
|
||||
$originalBranch = git rev-parse --abbrev-ref HEAD 2>$null
|
||||
|
||||
$remoteBranches = git ls-remote --heads origin | ForEach-Object {
|
||||
($_ -split "\s+")[1] -replace "refs/heads/", ""
|
||||
}
|
||||
|
||||
$targetBranch = $branchesToCheck | Where-Object { $remoteBranches -contains $_ } | Select-Object -First 1
|
||||
|
||||
if (-not $targetBranch) {
|
||||
$message = "$((Get-Date).ToString('yyyy-MM-dd HH:mm:ss')) - MISSING | $repoPath No 'main' or 'master' branch found on remote."
|
||||
Write-Host $message -ForegroundColor Red
|
||||
$message | Out-File -FilePath $OutputFile -Append -Encoding UTF8
|
||||
Pop-Location
|
||||
return
|
||||
}
|
||||
|
||||
if ($SwitchToMain -and $originalBranch -ne $targetBranch) {
|
||||
git stash push -u -m "Temp stash before switching branches" *> $null 2>&1
|
||||
git checkout $targetBranch *> $null 2>&1
|
||||
}
|
||||
|
||||
$status = git status -sb 2>$null
|
||||
$aheadBehind = git rev-list --left-right --count origin/$targetBranch...HEAD 2>$null
|
||||
|
||||
if ($aheadBehind) {
|
||||
$parts = $aheadBehind -split "`t"
|
||||
$behind = [int]$parts[0]
|
||||
$ahead = [int]$parts[1]
|
||||
|
||||
if ($ahead -gt 0 -or $behind -gt 0) {
|
||||
$message = "$((Get-Date).ToString('yyyy-MM-dd HH:mm:ss')) - UPDATE | $repoPath is not up to date with origin/$targetBranch (ahead: $ahead, behind: $behind)"
|
||||
Write-Host $message -ForegroundColor Yellow
|
||||
$message | Out-File -FilePath $OutputFile -Append -Encoding UTF8
|
||||
$script:hasOutdated = $true
|
||||
} else {
|
||||
Write-Host "✅ Repo is up to date with origin/$targetBranch" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
|
||||
if ($SwitchToMain -and $originalBranch -ne $targetBranch) {
|
||||
git checkout $originalBranch *> $null 2>&1
|
||||
git stash pop *> $null 2>&1
|
||||
}
|
||||
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
# Get all subdirectories containing .git folders
|
||||
$repos = Get-ChildItem -Path $RootPath -Recurse -Directory | Where-Object {
|
||||
Test-Path "$($_.FullName)\.git"
|
||||
}
|
||||
|
||||
# Clear or create output file
|
||||
"" | Out-File -FilePath $OutputFile -Encoding UTF8
|
||||
$script:hasOutdated = $false
|
||||
|
||||
# Check each repository
|
||||
foreach ($repo in $repos) {
|
||||
Check-GitStatus -repoPath $repo.FullName -OutputFile $OutputFile
|
||||
}
|
||||
|
||||
# Final summary
|
||||
if ($script:hasOutdated) {
|
||||
Write-Host "`n📄 Outdated repositories saved to: $OutputFile" -ForegroundColor Cyan
|
||||
} else {
|
||||
$msg = "🎉 All repositories are up to date!"
|
||||
Write-Host "`n$msg" -ForegroundColor Green
|
||||
$msg = "$((Get-Date).ToString('yyyy-MM-dd HH:mm:ss')) - 🎉 All repositories are up to date!"
|
||||
$msg | Out-File -FilePath $OutputFile -Append -Encoding UTF8
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#SCRIPT POWERSHELL PER UPLOAD NUGET.nupkg SU REPOSITORY NEXUS.STEAMWARE.NET
|
||||
|
||||
#percorso dell'eseguibile nuget.exe che fa l'upload
|
||||
$pathNugetExe = 'C:\Users\marco.locatelli\Documents\Emgu.CV\nuget.exe'
|
||||
#chiave API per autenticazione su nexus.steamware.net
|
||||
$apiKey = #SI TROVA IN GITLAB, ADMIN, CREDENZIALI SALVATE, NEXUS API
|
||||
#indirizzo del repository online su cui uploadare il pacchetto
|
||||
$repoUrl = 'http://nexus.steamware.net/repository/nuget-hosted'
|
||||
#path del pacchetto nupkg da uploadare
|
||||
$nupkgToUpload = 'C:\Users\marco.locatelli\Documents\Emgu.CV\Emgu.runtime.windows.cuda.dnn.cnn.infer.8.8.0.nupkg'
|
||||
|
||||
& $pathNugetExe setapikey $apiKey -source $repoUrl
|
||||
& $pathNugetExe push $nupkgToUpload -Source $repoUrl
|
||||
Binary file not shown.
@@ -1,92 +1,25 @@
|
||||
# IIS-Jobs
|
||||
# Powershell Scripts
|
||||
|
||||
Raccolta di script Steamware / Egalware suddivisi per aree tematiche.
|
||||
|
||||
## ApiGit
|
||||
|
||||
## Getting started
|
||||
Script per interazioni con Gitlab, Gogs e Gitea.
|
||||
|
||||
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
||||
Funzionalità: Controllo dello stato dei mirror, delle pipelines, dei commit. Creazione nuovi repo sui gitlab nembro, azzano, gogs e gitea. Creazione e abilitazione mirroring sul gitlab principale. Modifica dei repo: protected branches, namespace, creazione tag.
|
||||
|
||||
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
||||
## GPW
|
||||
|
||||
## Add your files
|
||||
Script per controllo funzionalità GPW: Check scadenze licenze, check timbrature.
|
||||
|
||||
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
||||
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
||||
## WDC
|
||||
|
||||
```
|
||||
cd existing_repo
|
||||
git remote add origin https://gitlab.steamware.net/egalware-web/other/iis-jobs.git
|
||||
git branch -M main
|
||||
git push -uf origin main
|
||||
```
|
||||
Script per sincronizzare cartelle di lavoro per progetto WDC
|
||||
|
||||
## Integrate with your tools
|
||||
## EgtDeploy & EgtTest
|
||||
|
||||
- [ ] [Set up project integrations](https://gitlab.steamware.net/egalware-web/other/iis-jobs/-/settings/integrations)
|
||||
Script per deploy e testing rapido ultime versioni applicazioni Egw
|
||||
|
||||
## Collaborate with your team
|
||||
## Generic
|
||||
|
||||
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
||||
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
||||
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
||||
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
||||
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
||||
|
||||
## Test and Deploy
|
||||
|
||||
Use the built-in continuous integration in GitLab.
|
||||
|
||||
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
||||
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
||||
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
||||
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
||||
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
||||
|
||||
***
|
||||
|
||||
# Editing this README
|
||||
|
||||
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
||||
|
||||
## Suggestions for a good README
|
||||
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
||||
|
||||
## Name
|
||||
Choose a self-explaining name for your project.
|
||||
|
||||
## Description
|
||||
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
||||
|
||||
## Badges
|
||||
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
||||
|
||||
## Visuals
|
||||
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
||||
|
||||
## Installation
|
||||
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
||||
|
||||
## Usage
|
||||
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
||||
|
||||
## Support
|
||||
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
||||
|
||||
## Roadmap
|
||||
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
||||
|
||||
## Contributing
|
||||
State if you are open to contributions and what your requirements are for accepting them.
|
||||
|
||||
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
||||
|
||||
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
||||
|
||||
## Authors and acknowledgment
|
||||
Show your appreciation to those who have contributed to the project.
|
||||
|
||||
## License
|
||||
For open source projects, say how it is licensed.
|
||||
|
||||
## Project status
|
||||
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
||||
Altri script powershell per vari usi o test.
|
||||
@@ -0,0 +1,16 @@
|
||||
######### FUNZIONI COMUNI #########
|
||||
|
||||
#scrittura output & log
|
||||
Function WriteLogOutput {
|
||||
Param ($logFile, $logType, [string]$logString)
|
||||
#compongo path per file di log
|
||||
$logPath = Join-Path $logFolder $logFile
|
||||
#scrivo su file la stringa se il tipo di log è > o uguale al livello richiesto
|
||||
if ($logType -le $logLevel) {
|
||||
Add-content $logPath -value "$logString"
|
||||
#scrivo su terminale la stringa se $terminalOutput=1
|
||||
if ($terminalOutput -eq 1) {
|
||||
Write-Output($logString)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
###ROBOCOPY VHDX VEEAM OVH VERSO TNAS UFFICIO###
|
||||
|
||||
$hostname = hostname
|
||||
$logFile = "C:\Steamware\Log\" + $hostname + "_VeeamVhdxRobocopy.log"
|
||||
|
||||
#cartella di origine
|
||||
$sourceFolder = "W:\ISO\Win\"
|
||||
|
||||
#file da copiare
|
||||
$file = "Windows10_EN_x64.iso"
|
||||
|
||||
#cartella di destinazione
|
||||
$destFolder = "\\10.74.82.201\veeam-ovh-vhdx"
|
||||
|
||||
robocopy $sourceFolder $destFolder $file /mt /tee /log:$logFile
|
||||
@@ -0,0 +1,36 @@
|
||||
###ROBOCOPY VHDX VEEAM OVH VERSO TNAS UFFICIO###
|
||||
|
||||
net use Z: /delete
|
||||
|
||||
Start-Sleep -Seconds 5
|
||||
|
||||
net use Z: \\10.74.82.201\veeam-ovh-storage $env:ZPass /user:egw-tscale-01\veeamovh
|
||||
|
||||
Start-Sleep -Seconds 5
|
||||
|
||||
#definisco file di log tramite hostname locale
|
||||
$hostname = hostname
|
||||
$logFile1 = "C:\Steamware\Logs\VeeamBackupRobocopy" + $hostname + ".log"
|
||||
$logFile2 = "C:\Steamware\Logs\VeeamConfigRobocopy" + $hostname + ".log"
|
||||
|
||||
#cartella1 di origine
|
||||
$sourceFolder1 = "B:\Backups\Backup Job WDC"
|
||||
|
||||
#cartella2 di origine
|
||||
$sourceFolder2 = "B:\Backups\VeeamConfigBackup"
|
||||
|
||||
#cartella1 di destinazione
|
||||
$destFolder1 = "Z:\VEEAM-WDC\Backup Job WDC"
|
||||
|
||||
#cartella2 di destinazione
|
||||
$destFolder2 = "Z:\VEEAM-WDC\VeeamConfigBackup"
|
||||
|
||||
#eseguo copia cartella 1
|
||||
robocopy $sourceFolder1 $destFolder1 /mir /mt /tee /log:$logFile1
|
||||
|
||||
#eseguo copia cartella 2
|
||||
robocopy $sourceFolder2 $destFolder2 /mir /mt /tee /log:$logFile2
|
||||
|
||||
Start-Sleep -Seconds 5
|
||||
|
||||
net use Z: /delete
|
||||
@@ -0,0 +1,21 @@
|
||||
###ESEMPIO COMANDO ROBOCOPY###
|
||||
|
||||
#path cartella di origine
|
||||
$sourceFolder = "C:\Users\YYY"
|
||||
|
||||
#nomi dei file da copiare
|
||||
$file1 = "nome1.txt"
|
||||
$file2 = "nome2.txt"
|
||||
$file3 = "nome3.txt"
|
||||
|
||||
#path delle cartelle di destinazione
|
||||
$destFolder1 = "C:\Users\XXX1"
|
||||
$destFolder2 = "C:\Users\XXX2"
|
||||
$destFolder3 = "C:\Users\XXX3"
|
||||
|
||||
#copio primo file
|
||||
robocopy $sourceFolder $destFolder1 $file1
|
||||
#copio secondo file
|
||||
robocopy $sourceFolder $destFolder2 $file2
|
||||
#copio terzo file
|
||||
robocopy $sourceFolder $destFolder3 $file3
|
||||
@@ -1,14 +0,0 @@
|
||||
|
||||
|
||||
|
||||
#$head = @{"PRIVATE-TOKEN"="glpat-dQsUhS-GxNomkh1GnjHZ"}
|
||||
#$projectCount=1
|
||||
#$callUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/remote_mirrors"
|
||||
#$callUrl = "https://gitlab.steamware.net/"
|
||||
#$Response = Invoke-WebRequest -URI $callUrl -Headers $head -ContentType "application/json" -UseBasicParsing
|
||||
#Write-Output($Response)
|
||||
|
||||
$url = "https://*****:*****@gitlab-nembro.steamware.net/steamware/NKC.git"
|
||||
$splitUrl = $url -split '.steamware.net/'
|
||||
Write-Output $splitUrl[0]
|
||||
Write-Output $splitUrl[1]
|
||||
@@ -0,0 +1,57 @@
|
||||
####SCRIPT PER CONTROLLARE TIME DRIFT WINDOWS####
|
||||
|
||||
#nome file di log
|
||||
$logFile = "W32TimeDriftCheck.log"
|
||||
#cartella file di log
|
||||
$logFolder = "c:\Steamware\Logs\"
|
||||
#opzione log su file: scrivo se = 1, ignoro se = 0
|
||||
$logType = 1
|
||||
#opzione output in terminale: scrivo se = 1, ignoro se = 0
|
||||
$terminalOutput = 1
|
||||
#Ipv4 PDC
|
||||
$PDC = "10.74.82.251"
|
||||
#Ipv4 BDC
|
||||
$BDC = "10.74.82.250"
|
||||
#Nome host su Zabbix per invio con trapper
|
||||
$ZabbixHost = "WIN2022-SQL-DEV"
|
||||
|
||||
#creazione folder di Log se non già esistente
|
||||
if (Test-Path $logFolder) {
|
||||
}
|
||||
else {
|
||||
New-Item $logFolder -ItemType Directory
|
||||
}
|
||||
|
||||
#funzione locale per log su file e output su terminale
|
||||
Function WriteLogOutput {
|
||||
Param ([string]$logString)
|
||||
#compongo path per file di log
|
||||
$logPath = Join-Path $logFolder $logFile
|
||||
#scrivo su file la stringa se $logType=1
|
||||
if ($logType -eq 1) {
|
||||
Add-content $logPath -value "$logString"
|
||||
}
|
||||
#scrivo su terminale la stringa se $terminalOutput=1
|
||||
if ($terminalOutput -eq 1) {
|
||||
Write-Output($logString)
|
||||
}
|
||||
}
|
||||
|
||||
#rilevo tempo locale e differenza PDC, restituisco in secondi
|
||||
$localTime, $timeDifferencePDC = (& w32tm /stripchart /computer:$PDC /samples:1 /dataonly)[-1].Trim("s") -split ',\s*'
|
||||
#rilevo tempo locale e differenza BDC, restituisco in secondi
|
||||
$localTime, $timeDifferenceBDC = (& w32tm /stripchart /computer:$BDC /samples:1 /dataonly)[-1].Trim("s") -split ',\s*'
|
||||
|
||||
#scrivo log data e ora
|
||||
WriteLogOutput ""
|
||||
WriteLogOutput "Script Execution: $localTime"
|
||||
|
||||
#invio a zabbix i dati
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s $ZabbixHost -k W32.TimeDifferencePDC -o $timeDifferencePDC
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s $ZabbixHost -k W32.TimeDifferenceBDC -o $timeDifferenceBDC
|
||||
|
||||
#output differenza PDC
|
||||
WriteLogOutput "Time Difference W2022PDC: $timeDifferencePDC s"
|
||||
#output differenza BDC
|
||||
WriteLogOutput "Time Difference W2022BDC: $timeDifferenceBDC s"
|
||||
WriteLogOutput ""
|
||||
@@ -0,0 +1,11 @@
|
||||
#Eseguo Get-Service per ottenere informazioni riguardo il servizio desiderato
|
||||
$Response = Get-Service "Redis Sentinel"
|
||||
#Se il servizio ha status = stopped faccio qualcosa tipo inviare a zabbix informazioni
|
||||
if ($Response.Status -eq "Running" ) {
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ovh -s "WIN2019IIS.OVH" -k RedisSentinel.Failure -o 0
|
||||
echo 0
|
||||
}
|
||||
else {
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ovh -s "WIN2019IIS.OVH" -k RedisSentinel.Failure -o 1
|
||||
echo 1
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#Eseguo Get-Service per ottenere informazioni riguardo il servizio desiderato
|
||||
$Response = Get-Service "Redis"
|
||||
#Se il servizio ha status = stopped faccio qualcosa tipo inviare a zabbix informazioni
|
||||
if ($Response.Status -eq "Running" ) {
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ovh -s "WIN2019IIS.OVH" -k Redis.Failure -o 0
|
||||
echo 0
|
||||
}
|
||||
else {
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ovh -s "WIN2019IIS.OVH" -k Redis.Failure -o 1
|
||||
echo 1
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
###### INVIO NUMERO LICENZE XCORE A ZABBIX ######
|
||||
|
||||
#importo file contenente funzioni
|
||||
. .\Resources\CommonFunctions.ps1
|
||||
|
||||
#rilevo time inizio analisi
|
||||
$checkTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#cartella file di log
|
||||
$logFolder = "c:\Steamware\Logs\Xcore\"
|
||||
#livello di log: 0=log sintetico, 1=log errori, 2=log full, 3=log ampolloso
|
||||
$logLevel = 3
|
||||
#output a terminale: 0=disattivo, 1=abilitato
|
||||
$terminalOutput = 1
|
||||
|
||||
#nome file di log
|
||||
$logFile = "Xcore01Licenses.log"
|
||||
|
||||
#creazione folder di Log se non già esistente
|
||||
if (Test-Path $logFolder) {
|
||||
}
|
||||
else {
|
||||
New-Item $logFolder -ItemType Directory
|
||||
}
|
||||
|
||||
#valore da inviare a zabbix (numero licenze attive)
|
||||
$Xcore01Licenses = 0
|
||||
|
||||
#invio a zabbix il valore riguardante il numero di licenze utilizzando zabbix_sender.exe, specificando proxi, host, item e variabile da inviare.
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "xcore-rete-01.ufficio" -k Xcore01.Licenses -o $Xcore01Licenses
|
||||
|
||||
#scrivo le statistiche
|
||||
WriteLogOutput $logFile 0 "$checkTime - LICENZE ATTIVE XCORE: $Xcore01Licenses"
|
||||
@@ -0,0 +1,33 @@
|
||||
###### INVIO STATUS XCORE A ZABBIX ######
|
||||
|
||||
#importo file contenente funzioni
|
||||
. .\Resources\CommonFunctions.ps1
|
||||
|
||||
#rilevo time inizio analisi
|
||||
$checkTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
|
||||
#cartella file di log
|
||||
$logFolder = "c:\Steamware\Logs\Xcore\"
|
||||
#livello di log: 0=log sintetico, 1=log errori, 2=log full, 3=log ampolloso
|
||||
$logLevel = 3
|
||||
#output a terminale: 0=disattivo, 1=abilitato
|
||||
$terminalOutput = 1
|
||||
|
||||
#nome file di log
|
||||
$logFile = "Xcore01Status.log"
|
||||
|
||||
#creazione folder di Log se non già esistente
|
||||
if (Test-Path $logFolder) {
|
||||
}
|
||||
else {
|
||||
New-Item $logFolder -ItemType Directory
|
||||
}
|
||||
|
||||
#valore da inviare a zabbix (1= OK; 0=KO)
|
||||
$Xcore01Status = 1
|
||||
|
||||
#invio a zabbix il valore riguardante lo status utilizzando zabbix_sender.exe, specificando proxi, host, item e variabile da inviare.
|
||||
& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "xcore-rete-01.ufficio" -k Xcore01.Status -o $Xcore01Status
|
||||
|
||||
#scrivo le statistiche
|
||||
WriteLogOutput $logFile 0 "$checkTime - STATUS XCORE: $Xcore01Status"
|
||||
Reference in New Issue
Block a user