From 7a04fa5816bdfaace021c63624d83a4d50547a62 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 23 May 2023 06:43:51 +0000 Subject: [PATCH] Retry commands which potentially fail --- scripts/Arch/Devices/Surface/install.sh | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/scripts/Arch/Devices/Surface/install.sh b/scripts/Arch/Devices/Surface/install.sh index 7b774c12..6aa2a45f 100755 --- a/scripts/Arch/Devices/Surface/install.sh +++ b/scripts/Arch/Devices/Surface/install.sh @@ -11,6 +11,21 @@ sudo pacman-key --lsign-key 56C464BAAC421453; pacmanConf="/etc/pacman.conf"; +retry() { + retryCount="$1"; + command="${@:2}"; + exitCode=0; + + for i in $(seq 1 $retryCount); + do + eval "$command" && { + exitCode=0; + break; + }; + exitCode="$?"; + done; +} + if ! grep "^\[linux-surface\]$" "$pacmanConf" then { @@ -20,9 +35,12 @@ then } | sudo tee -a "$pacmanConf" > /dev/null; fi; -sudo pacman --noconfirm -Syu; +for i in $(seq 1 5); +do pacman --noconfirm -Syu && s=0 && break || s=$? && sleep 15; done; (exit $s) -sudo pacman --noconfirm -Sy \ +retry 5 sudo pacman --noconfirm -Syu; + +retry 5 sudo pacman --noconfirm -Sy \ intel-ucode \ linux-surface \ linux-surface-headers \