Retry commands which potentially fail
This commit is contained in:
parent
c5e30fd131
commit
7a04fa5816
1 changed files with 20 additions and 2 deletions
|
@ -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 \
|
||||
|
|
Loading…
Reference in a new issue