1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Use "" for AppParameters if it's null

This commit is contained in:
gfrank 2015-12-04 15:46:06 -05:00 committed by Matt Clay
parent 5f43afff5b
commit 9387c842a1

View file

@ -176,35 +176,44 @@ Function Nssm-Update-AppParameters
Throw "Error updating AppParameters for service ""$name""" Throw "Error updating AppParameters for service ""$name"""
} }
$appParametersHash = ParseAppParameters -appParameters $appParameters
$appParamKeys = @() $appParamKeys = @()
$appParamVals = @() $appParamVals = @()
$singleLineParams = "" $singleLineParams = ""
$appParametersHash.GetEnumerator() |
% { if ($appParameters)
$key = $($_.Name) {
$val = $($_.Value) $appParametersHash = ParseAppParameters -appParameters $appParameters
$appParametersHash.GetEnumerator() |
% {
$key = $($_.Name)
$val = $($_.Value)
$appParamKeys += $key $appParamKeys += $key
$appParamVals += $val $appParamVals += $val
if ($key -eq "_") { if ($key -eq "_") {
$singleLineParams = "$val " + $singleLineParams $singleLineParams = "$val " + $singleLineParams
} else { } else {
$singleLineParams = $singleLineParams + "$key ""$val""" $singleLineParams = $singleLineParams + "$key ""$val"""
}
} }
}
Set-Attr $result "nssm_app_parameters_parsed" $appParametersHash
Set-Attr $result "nssm_app_parameters_keys" $appParamKeys
Set-Attr $result "nssm_app_parameters_vals" $appParamVals
}
Set-Attr $result "nssm_app_parameters" $appParameters Set-Attr $result "nssm_app_parameters" $appParameters
Set-Attr $result "nssm_app_parameters_parsed" $appParametersHash
Set-Attr $result "nssm_app_parameters_keys" $appParamKeys
Set-Attr $result "nssm_app_parameters_vals" $appParamVals
Set-Attr $result "nssm_single_line_app_parameters" $singleLineParams Set-Attr $result "nssm_single_line_app_parameters" $singleLineParams
if ($results -ne $singleLineParams) if ($results -ne $singleLineParams)
{ {
$cmd = "nssm set ""$name"" AppParameters $singleLineParams" if ($appParameters)
{
$cmd = "nssm set ""$name"" AppParameters $singleLineParams"
} else {
$cmd = "nssm set ""$name"" AppParameters '""""'"
}
$results = invoke-expression $cmd $results = invoke-expression $cmd
if ($LastExitCode -ne 0) if ($LastExitCode -ne 0)