Skip to content
Snippets Groups Projects
Commit e2164376 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Only copy service file if target not yet existing.

In addition, this cleans up the config / status files copying using the
new structure.
parent 4944a57e
No related branches found
No related tags found
No related merge requests found
...@@ -27,32 +27,18 @@ function Start-MyService { ...@@ -27,32 +27,18 @@ function Start-MyService {
} }
function Copy-FileIfNew([string]$SourceFile, [string]$Destination) { function Copy-ServiceFiles {
# SourceFile is expected to be a FILE name if (Test-Path -Type Container $ServiceDir) {
# Destination is expected to be a PATH Write-Host "Target directory [$($ServiceDir)] exists, stopping!"
if (Test-Path "$Destination\$SourceFile") { Exit 1
return
}
try {
Copy-Item -Path $SourceFile -Destination $Destination -ErrorAction Stop
}
catch {
$ex = $_.Exception
Write-Host "Copying $($SourceFile) FAILED!" -Fore Red
Write-Host $ex.Message
Exit
} }
}
function Copy-ServiceFiles {
Write-Host -NoNewLine "Updating / installing service files: " Write-Host -NoNewLine "Updating / installing service files: "
$TargetDir = New-Item -ItemType Container -Force -Path $ServiceDir $TargetDir = New-Item -ItemType Container -Force -Path $ServiceDir
try { try {
Copy-Item -Recurse -Force -Path "$ServiceName\*" -Destination $ServiceDir -ErrorAction Stop Copy-Item -Recurse -Force -Path "$ServiceName\*" -Destination $ServiceDir
Copy-FileIfNew "configuration.xml" $ServiceDir Copy-Item -Recurse -Force -Path "conf-example" -Destination $ServiceDir
Copy-FileIfNew "status.xml" $ServiceDir Copy-Item -Force -Path "$($ServiceName).log" -Destination $ServiceLog
Copy-FileIfNew "service.log" $ServiceLog
Clear-Content $ServiceLog Clear-Content $ServiceLog
Write-Host "[OK]" -Fore Green Write-Host "[OK]" -Fore Green
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment