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 {
}
function Copy-FileIfNew([string]$SourceFile, [string]$Destination) {
# SourceFile is expected to be a FILE name
# Destination is expected to be a PATH
if (Test-Path "$Destination\$SourceFile") {
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 {
if (Test-Path -Type Container $ServiceDir) {
Write-Host "Target directory [$($ServiceDir)] exists, stopping!"
Exit 1
}
}
function Copy-ServiceFiles {
Write-Host -NoNewLine "Updating / installing service files: "
$TargetDir = New-Item -ItemType Container -Force -Path $ServiceDir
try {
Copy-Item -Recurse -Force -Path "$ServiceName\*" -Destination $ServiceDir -ErrorAction Stop
Copy-FileIfNew "configuration.xml" $ServiceDir
Copy-FileIfNew "status.xml" $ServiceDir
Copy-FileIfNew "service.log" $ServiceLog
Copy-Item -Recurse -Force -Path "$ServiceName\*" -Destination $ServiceDir
Copy-Item -Recurse -Force -Path "conf-example" -Destination $ServiceDir
Copy-Item -Force -Path "$($ServiceName).log" -Destination $ServiceLog
Clear-Content $ServiceLog
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