mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-05 21:28:48 +00:00
Merge pull request #206 from nnyyxxxx/testing-7
Add failsafe incase Rate-mirrors fails
This commit is contained in:
commit
3c27844f6a
|
@ -11,8 +11,9 @@ fastUpdate() {
|
|||
cd /opt && $ESCALATION_TOOL git clone https://aur.archlinux.org/yay-git.git && $ESCALATION_TOOL chown -R ${USER}:${USER} ./yay-git
|
||||
cd yay-git && makepkg --noconfirm -si || { echo -e "${RED}Failed to install yay${RC}"; exit 1; }
|
||||
else
|
||||
echo "Aur helper already installed"
|
||||
echo "AUR helper already installed"
|
||||
fi
|
||||
|
||||
if command_exists yay; then
|
||||
AUR_HELPER="yay"
|
||||
elif command_exists paru; then
|
||||
|
@ -21,28 +22,38 @@ fastUpdate() {
|
|||
echo "No AUR helper found. Please install yay or paru."
|
||||
exit 1
|
||||
fi
|
||||
$AUR_HELPER -S --needed --noconfirm rate-mirrors-bin
|
||||
|
||||
${AUR_HELPER} -S --needed --noconfirm rate-mirrors-bin
|
||||
|
||||
if [ -s /etc/pacman.d/mirrorlist ]; then
|
||||
$ESCALATION_TOOL cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
|
||||
fi
|
||||
|
||||
|
||||
# If for some reason DTYPE is still unknown use always arch so the rate-mirrors does not fail
|
||||
dtype_local=${DTYPE}
|
||||
if [ "${DTYPE}" = "unknown" ]; then
|
||||
dtype_local="arch"
|
||||
fi
|
||||
|
||||
$ESCALATION_TOOL rate-mirrors --top-mirrors-number-to-retest=5 --disable-comments --save /etc/pacman.d/mirrorlist --allow-root ${dtype_local}
|
||||
if [ $? -ne 0 ] || [ ! -s /etc/pacman.d/mirrorlist ]; then
|
||||
echo -e "${RED}Rate-mirrors failed, restoring backup.${RC}"
|
||||
$ESCALATION_TOOL cp /etc/pacman.d/mirrorlist.bak /etc/pacman.d/mirrorlist
|
||||
fi
|
||||
;;
|
||||
|
||||
apt-get|nala)
|
||||
$ESCALATION_TOOL apt-get update
|
||||
if ! command_exists nala; then
|
||||
$ESCALATION_TOOL apt-get install -y nala || { echo -e "${YELLOW}Falling back to apt-get${RC}"; PACKAGER="apt-get"; }
|
||||
fi
|
||||
|
||||
if [ "${PACKAGER}" = "nala" ]; then
|
||||
$ESCALATION_TOOL cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
$ESCALATION_TOOL nala update
|
||||
PACKAGER="nala"
|
||||
fi
|
||||
|
||||
$ESCALATION_TOOL ${PACKAGER} upgrade -y
|
||||
;;
|
||||
dnf)
|
||||
|
|
Loading…
Reference in New Issue
Block a user