Last change
on this file was 106061, checked in by vboxsync, 7 weeks ago |
Copyright year updates by scm.
|
-
Property svn:eol-style
set to
LF
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
1.3 KB
|
Rev | Line | |
---|
[98105] | 1 | #!/usr/bin/env kmk_ash
|
---|
[59430] | 2 | # $Id: retry.sh 106061 2024-09-16 14:03:52Z vboxsync $
|
---|
| 3 | ## @file
|
---|
| 4 | # Script for retrying a command 5 times.
|
---|
| 5 | #
|
---|
| 6 |
|
---|
| 7 | #
|
---|
[106061] | 8 | # Copyright (C) 2009-2024 Oracle and/or its affiliates.
|
---|
[59430] | 9 | #
|
---|
[96407] | 10 | # This file is part of VirtualBox base platform packages, as
|
---|
| 11 | # available from https://www.virtualbox.org.
|
---|
[59430] | 12 | #
|
---|
[96407] | 13 | # This program is free software; you can redistribute it and/or
|
---|
| 14 | # modify it under the terms of the GNU General Public License
|
---|
| 15 | # as published by the Free Software Foundation, in version 3 of the
|
---|
| 16 | # License.
|
---|
| 17 | #
|
---|
| 18 | # This program is distributed in the hope that it will be useful, but
|
---|
| 19 | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 21 | # General Public License for more details.
|
---|
| 22 | #
|
---|
| 23 | # You should have received a copy of the GNU General Public License
|
---|
| 24 | # along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 25 | #
|
---|
| 26 | # SPDX-License-Identifier: GPL-3.0-only
|
---|
| 27 | #
|
---|
[59430] | 28 |
|
---|
| 29 | # First try (quiet).
|
---|
| 30 | "$@"
|
---|
| 31 | EXITCODE=$?
|
---|
| 32 | if [ "${EXITCODE}" = "0" ]; then
|
---|
| 33 | exit 0;
|
---|
| 34 | fi
|
---|
| 35 |
|
---|
| 36 | # Retries.
|
---|
| 37 | for RETRY in 2 3 4 5;
|
---|
| 38 | do
|
---|
| 39 | echo "retry.sh: retry$((${RETRY} - 1)): exitcode=${EXITCODE}; retrying: $*"
|
---|
| 40 | "$@"
|
---|
| 41 | EXITCODE=$?
|
---|
| 42 | if [ "${EXITCODE}" = "0" ]; then
|
---|
| 43 | echo "retry.sh: Success after ${RETRY} tries: $*!"
|
---|
| 44 | exit 0;
|
---|
| 45 | fi
|
---|
| 46 | done
|
---|
[69210] | 47 | echo "retry.sh: Giving up: exitcode=${EXITCODE} command: $@"
|
---|
[59430] | 48 | exit ${EXITCODE};
|
---|
| 49 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.