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

WIP: check configuration before doing any updates.

This adapts the updater to the new configuration locations (#18) and
changes the control flow so that first the script will detect if any
updates are necessary at all and then validate the configuration files
(respecting what parts will be updated), preparing for the actual update
tasks (as this is currently work-in-progress, those update tasks are
disabled for now.

Refers to #28
parent f7fdef7f
No related branches found
No related tags found
No related merge requests found
......@@ -554,8 +554,7 @@ Log-Debug "$($Me) started..."
# first check if the service is installed and running at all
$ServiceRunningBefore = ServiceIsRunning $ServiceName
$UpdPathConfig = "$($UpdateSourcePath)\Configs\$($env:COMPUTERNAME)"
$UpdPathConfigCommon = "$($UpdateSourcePath)\Configs\_COMMON_"
$UpdPathConfig = "$($UpdateSourcePath)\Configs"
$UpdPathMarkerFiles = "$($UpdateSourcePath)\Service\UpdateMarkers"
$UpdPathBinaries = "$($UpdateSourcePath)\Service\Binaries"
$UploadPathLogs = "$($UpdateSourcePath)\Logs"
......@@ -565,7 +564,6 @@ 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"
......@@ -575,17 +573,45 @@ Exit-IfDirMissing $UploadPathLogs "log file target"
# the logfiles are uploaded no matter if one of the other tasks fails and
# terminates the entire script:
Upload-LogFiles
$ConfigUpdated = Update-Configuration
$ServiceUpdated = Update-ServiceBinaries
$msg = ""
if ($ConfigUpdated) {
$msg += "The configuration files were updated.`n"
$ConfigShouldBeUpdated = NewConfig-Available $ConfigPath
$ServiceShouldBeUpdated = NewServiceBinaries-Available
if (-Not ($ConfigShouldBeUpdated -Or $ServiceShouldBeUpdated)) {
Log-Debug "No update action found to be necessary."
Exit
}
# define where the configuration is located that should be tested:
$ConfigToTest = $ConfigPath
if ($ConfigShouldBeUpdated) {
$ConfigToTest = $UpdPathConfig
}
if ($ServiceUpdated) {
$msg += "The service binaries were updated.`n"
# define which configuration checker executable should be used for testing:
$ConfigTestBinary = "$($InstallationPath)\AutoTxConfigTest.exe"
if ($ServiceShouldBeUpdated) {
$UpdPackage = Find-InstallationPackage
$ConfigTestBinary = "$($UpdPackage)\AutoTx\AutoTxConfigTest.exe"
}
# now we're all set and can run the config test:
$ConfigValid, $ConfigSummary = Config-IsValid $ConfigTestBinary $ConfigToTest
# if we don't have a valid configuration we complain and terminate the update:
if (-Not ($ConfigValid)) {
Log-Error "Configuration not valid for service, $($Me) terminating!"
Send-MailReport -Subject "Update failed, configuration invalid!" `
-Body $("An update action was found to be necessary, however the"
"configuration didn't`npass the validator.`n`nThe following summary"
"was generated by the configuration checker:`n`n$($ConfigSummary)")
Exit
}
Exit
$ServiceUpdated = Update-ServiceBinaries
if ($msg -ne "") {
if ($ServiceRunningBefore) {
Log-Debug "Update action occurred, finishing up..."
......@@ -595,8 +621,6 @@ if ($msg -ne "") {
}
Send-MailReport -Subject "Config and / or service has been updated!" `
-Body $msg
} else {
Log-Debug "No update action found to be necessary."
}
Upload-LogFiles
......
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