From 9d69572e74c0e4d07d475b1842d99cd93b33978b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simo=20F=C3=A4lt?= Date: Tue, 18 Jun 2024 10:08:32 +0300 Subject: [PATCH] Provisioning: Add retry for disabling Spotlight indexing Task-number: QTQAINFRA-5996 Change-Id: I6c85816f7b490fbb2423cbf7d0efe862056bc001 Reviewed-by: Toni Saario (cherry picked from commit f9bb6b202ac1087891e0e3469c8094f4567f1bc4) Reviewed-by: Qt Cherry-pick Bot --- .../common/macos/disable_spotlight.sh | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/coin/provisioning/common/macos/disable_spotlight.sh b/coin/provisioning/common/macos/disable_spotlight.sh index a404d3e7..b4907ca0 100755 --- a/coin/provisioning/common/macos/disable_spotlight.sh +++ b/coin/provisioning/common/macos/disable_spotlight.sh @@ -2,10 +2,29 @@ # Copyright (C) 2017 The Qt Company Ltd. # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -# Disable spotlight and and stop indexing -sudo mdutil -a -i off -sudo mdutil -a -i off / -# Disable spotlight indexing /Volumes -sudo mdutil -i off /Volumes -# Erase spotlight index -sudo mdutil -E / +disableSpotlight() { + # Disable spotlight and and stop indexing + sudo mdutil -a -i off + sudo mdutil -a -i off / + # Disable spotlight indexing /Volumes + sudo mdutil -i off /Volumes + # Erase spotlight index + sudo mdutil -E / +} + +# Disabling spotlight tends to be flaky, add some retry +for i in $(seq 1 5) +do + disableSpotlight + res=$? + if [[ $res -eq 0 ]] + then + echo "Spotlight disabled" + break + else + echo "Failed to disable spotlight, $i retry..." + sleep 2 + fi +done + +exit $res