From fa6cfbecc89300e3e2d0774cb18b0140c95a2638 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Thu, 14 Dec 2017 11:52:12 +0100 Subject: [PATCH] Allow for common and host-specific config file update paths. With this commit the updater script is considered as being completed for now, so this fixes #13. --- Updater/README.md | 2 ++ Updater/Update-Service.ps1 | 25 +++++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Updater/README.md b/Updater/README.md index d3fc10e..b36e29e 100644 --- a/Updater/README.md +++ b/Updater/README.md @@ -29,6 +29,8 @@ The `$UpdateSourcePath` folder structure is expected to be like this: ``` ├─── Configs +│ ├─── _COMMON_ +│ │ └─── common_config.xml │ └─── <HOSTNAME> │ └─── configuration.xml └─── Service diff --git a/Updater/Update-Service.ps1 b/Updater/Update-Service.ps1 index cf835c2..4cf7d0a 100644 --- a/Updater/Update-Service.ps1 +++ b/Updater/Update-Service.ps1 @@ -233,14 +233,21 @@ function Update-File { function Update-Configuration { - $NewConfig = "$($UpdateConfigPath)\configuration.xml" - if (Test-Path -PathType Leaf $NewConfig) { - $ret = Update-File $NewConfig $ConfigPath - } else { - $ret = $False - Log-Debug "No configuration file found at '$($NewConfig)'." - } - Return $ret + $RetOr = $False + # common config files first: + ForEach ($NewConfig in Get-ChildItem $UpdPathConfigCommon) { + $ret = Update-File $NewConfig.FullName $ConfigPath + $RetOr = $RetOr -Or $ret + } + # then host specific config files: + ForEach ($NewConfig in Get-ChildItem $UpdPathConfig) { + $ret = Update-File $NewConfig.FullName $ConfigPath + $RetOr = $RetOr -Or $ret + } + if (-Not ($RetOr)) { + Log-Debug "No (new) configuration file(s) found." + } + Return $RetOr } @@ -408,6 +415,7 @@ Log-Debug "$($Me) started..." Ensure-ServiceRunning $ServiceName $UpdPathConfig = "$($UpdateSourcePath)\Configs\$($env:COMPUTERNAME)" +$UpdPathConfigCommon = "$($UpdateSourcePath)\Configs\_COMMON_" $UpdPathMarkerFiles = "$($UpdateSourcePath)\Service\UpdateMarkers" $UpdPathBinaries = "$($UpdateSourcePath)\Service\Binaries" $UploadPathLogs = "$($UpdateSourcePath)\Logs\$($env:COMPUTERNAME)" @@ -417,6 +425,7 @@ Exit-IfDirMissing $LogPath "log files" Exit-IfDirMissing $ConfigPath "configuration files" Exit-IfDirMissing $UpdateSourcePath "update source" Exit-IfDirMissing $UpdPathConfig "configuration update" +Exit-IfDirMissing $UpdPathConfigCommon "common configuration update" Exit-IfDirMissing $UpdPathMarkerFiles "update marker" Exit-IfDirMissing $UpdPathBinaries "service binaries update" Exit-IfDirMissing $UploadPathLogs "log file target" -- GitLab