mirror of
https://github.com/ggogel/seafile-containerized.git
synced 2024-11-16 17:05:32 +00:00
win: Fixed do_if_not function.
This commit is contained in:
parent
3dde0dd076
commit
b4da59b93a
23
launcher.ps1
23
launcher.ps1
|
@ -86,25 +86,26 @@ Currently the first branch must be a subprocess call.
|
||||||
#>
|
#>
|
||||||
function do_if_not([scriptblock]$block_1, [scriptblock]$block_2) {
|
function do_if_not([scriptblock]$block_1, [scriptblock]$block_2) {
|
||||||
$failed = $false
|
$failed = $false
|
||||||
$LASTEXITCODE = 0
|
$script:LASTEXITCODE = 0
|
||||||
try {
|
try {
|
||||||
& $block_1
|
& $block_1
|
||||||
} catch [System.Management.Automation.RemoteException] {
|
} catch [System.Management.Automation.RemoteException] {
|
||||||
$failed = $true
|
$failed = $true
|
||||||
}
|
}
|
||||||
if ($failed -or !($LASTEXITCODE -eq 0)) {
|
if ($failed -or !($script:LASTEXITCODE -eq 0)) {
|
||||||
& $block_2
|
& $block_2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function do_if([scriptblock]$block_1, [scriptblock]$block_2) {
|
function do_if([scriptblock]$block_1, [scriptblock]$block_2) {
|
||||||
$failed = $false
|
$failed = $false
|
||||||
|
$script:LASTEXITCODE = 0
|
||||||
try {
|
try {
|
||||||
& $block_1
|
& $block_1
|
||||||
} catch [System.Management.Automation.RemoteException] {
|
} catch [System.Management.Automation.RemoteException] {
|
||||||
$failed = $true
|
$failed = $true
|
||||||
}
|
}
|
||||||
if (!($failed)) {
|
if (!($failed) -and ($script:LASTEXITCODE -eq 0)) {
|
||||||
& $block_2
|
& $block_2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,9 +154,14 @@ function check_call($cmd) {
|
||||||
$process = Start-Process -NoNewWindow -Wait -FilePath "$cmd" -PassThru
|
$process = Start-Process -NoNewWindow -Wait -FilePath "$cmd" -PassThru
|
||||||
}
|
}
|
||||||
if (!($process.ExitCode -eq 0)) {
|
if (!($process.ExitCode -eq 0)) {
|
||||||
|
if ($script:on_call_error) {
|
||||||
|
err_and_quit $script:on_call_error
|
||||||
|
$script:on_call_error = $null
|
||||||
|
} else {
|
||||||
err_and_quit "The command $cmd $args failed with code $LASTEXITCODE"
|
err_and_quit "The command $cmd $args failed with code $LASTEXITCODE"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function get_date_str() {
|
function get_date_str() {
|
||||||
Get-Date -format "yyyy-MM-dd hh:mm:ss"
|
Get-Date -format "yyyy-MM-dd hh:mm:ss"
|
||||||
|
@ -504,12 +510,13 @@ function _launch_for_upgrade([switch]$auto) {
|
||||||
set_envs
|
set_envs
|
||||||
set_volumes
|
set_volumes
|
||||||
|
|
||||||
do_if_not { docker run `
|
remove_container seafile-upgrade
|
||||||
-it --rm --name seafile-upgrade -h seafile `
|
|
||||||
|
$script:on_call_error = 'Failed to upgrade to latest version. You can try run it manually by "./launcher.ps1 manual-upgrade"'
|
||||||
|
check_call docker run `
|
||||||
|
-it -rm --name seafile-upgrade -h seafile `
|
||||||
@script:envs @script:volumes $local_image `
|
@script:envs @script:volumes $local_image `
|
||||||
@script:my_init -- $cmd } {
|
@script:my_init -- $cmd
|
||||||
err_and_quit 'Failed to upgrade to latest version. You can try run it manually by "./launcher.ps1 manual-upgrade"'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main @args
|
main @args
|
||||||
|
|
Loading…
Reference in a new issue