Retry commands which potentially fail

This commit is contained in:
Manuel Thalmann 2023-05-23 06:43:51 +00:00
parent c5e30fd131
commit 7a04fa5816

View file

@ -11,6 +11,21 @@ sudo pacman-key --lsign-key 56C464BAAC421453;
pacmanConf="/etc/pacman.conf"; 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" if ! grep "^\[linux-surface\]$" "$pacmanConf"
then then
{ {
@ -20,9 +35,12 @@ then
} | sudo tee -a "$pacmanConf" > /dev/null; } | sudo tee -a "$pacmanConf" > /dev/null;
fi; 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 \ intel-ucode \
linux-surface \ linux-surface \
linux-surface-headers \ linux-surface-headers \