Merge pull request #206 from nnyyxxxx/testing-7

Add failsafe incase Rate-mirrors fails
This commit is contained in:
Chris Titus 2024-09-04 16:48:18 -05:00 committed by GitHub
commit 3c27844f6a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 /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; } cd yay-git && makepkg --noconfirm -si || { echo -e "${RED}Failed to install yay${RC}"; exit 1; }
else else
echo "Aur helper already installed" echo "AUR helper already installed"
fi fi
if command_exists yay; then if command_exists yay; then
AUR_HELPER="yay" AUR_HELPER="yay"
elif command_exists paru; then elif command_exists paru; then
@ -21,7 +22,9 @@ fastUpdate() {
echo "No AUR helper found. Please install yay or paru." echo "No AUR helper found. Please install yay or paru."
exit 1 exit 1
fi fi
$AUR_HELPER -S --needed --noconfirm rate-mirrors-bin
${AUR_HELPER} -S --needed --noconfirm rate-mirrors-bin
if [ -s /etc/pacman.d/mirrorlist ]; then if [ -s /etc/pacman.d/mirrorlist ]; then
$ESCALATION_TOOL cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak $ESCALATION_TOOL cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
fi fi
@ -31,18 +34,26 @@ fastUpdate() {
if [ "${DTYPE}" = "unknown" ]; then if [ "${DTYPE}" = "unknown" ]; then
dtype_local="arch" dtype_local="arch"
fi fi
$ESCALATION_TOOL rate-mirrors --top-mirrors-number-to-retest=5 --disable-comments --save /etc/pacman.d/mirrorlist --allow-root ${dtype_local} $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) apt-get|nala)
$ESCALATION_TOOL apt-get update $ESCALATION_TOOL apt-get update
if ! command_exists nala; then if ! command_exists nala; then
$ESCALATION_TOOL apt-get install -y nala || { echo -e "${YELLOW}Falling back to apt-get${RC}"; PACKAGER="apt-get"; } $ESCALATION_TOOL apt-get install -y nala || { echo -e "${YELLOW}Falling back to apt-get${RC}"; PACKAGER="apt-get"; }
fi fi
if [ "${PACKAGER}" = "nala" ]; then if [ "${PACKAGER}" = "nala" ]; then
$ESCALATION_TOOL cp /etc/apt/sources.list /etc/apt/sources.list.bak $ESCALATION_TOOL cp /etc/apt/sources.list /etc/apt/sources.list.bak
$ESCALATION_TOOL nala update $ESCALATION_TOOL nala update
PACKAGER="nala" PACKAGER="nala"
fi fi
$ESCALATION_TOOL ${PACKAGER} upgrade -y $ESCALATION_TOOL ${PACKAGER} upgrade -y
;; ;;
dnf) dnf)