#!/bin/sh N="ionice -c3 nice -n19 chrt -i 0" MIRRORLIST="/etc/pacman.d/mirrorlist.custom" cd "$HOME" || exit 1 sudo true || exit 1 if [ $# -eq 0 ] || [ "$1" != "check" ]; then check_only=0 else check_only=1 fi if [ $check_only -eq 0 ]; then echo -e "\n*** Examining mirrors\n" rate-mirrors --allow-root --protocol=https --entry-country=DE --country-neighbors-per-country=0 --country-test-mirrors-per-country=10 arch --max-delay=7200 | sudo tee "$MIRRORLIST" if ! grep "^Server =" $MIRRORLIST; then echo "Something went wrong, overriding $MIRRORLIST" echo 'Server = https://mirror.cmt.de/archlinux/$repo/os/$arch' | sudo tee "$MIRRORLIST" fi echo "" yay -Syy echo -e "\n*** Vulnerable packages\n" arch-audit -f "%s %n %v %t" echo -e "\n*** Packages with available security fixes\n" arch-audit -q -u echo -e "\n*** Latest upstream kernel releases\n" timeout 5s \ w3m -no-cookie -dump https://lkml.org/ | \ awk '/[3-9]\.[0-9]+.* patch/ { gsub(/^[ \t]+/,"",$0); gsub(/[ \t]+$/,"",$0); printf "%s %s\n",$1,$2; }' local_ver=$(uname -r) local_ver=${local_ver%%-[0-9]*-custom} echo -e "\n*** Latest Arch kernel packages (local version: $local_ver)\n" PACKAGE=$(pacman -Qoq /lib/modules/$(uname -r)/kernel/ | tail -1) PACKAGE=${PACKAGE%-custom} [ -n "$PACKAGE" ] || PACKAGE="linux" PACKAGE="linux-lts" TMPDIR=$(mktemp -d /tmp/git-tmp.XXXXXX) || exit 1 PACKAGE_URL="https://gitlab.archlinux.org/archlinux/packaging/packages/${PACKAGE}.git/" pushd "$TMPDIR" >/dev/null || exit 1 git clone -q --depth=1 -n "$PACKAGE_URL" . git log -1 popd >/dev/null rm -rf "$TMPDIR" else yay -Sy fi echo -e "\n*** Packages with updates\n" pikaur -Qu || yay -Qu if [ $check_only -eq 0 ]; then echo -e "\nHit RETURN to continue" read echo -e "*** Updating Arch packages\n" sudo pacman -S --noconfirm --needed archlinux-keyring || exit 1 sudo systemctl stop archlinux-keyring-wkd-sync.timer sudo systemctl mask archlinux-keyring-wkd-sync.timer sudo pacman -Su --noconfirm || exit 1 echo -e "\n*** Updating AUR packages\n" $N yay -Sua --noconfirm --answerdiff None --answerupgrade None || exit 1 yes | yay -Scc fi echo -e "\n*** Orphaned libaries left" sudo lsof +c 0 2>/dev/null | grep 'DEL.*lib' | awk '{ print $1,$NF }' | sort -u echo -e "\n*** Startup failures\n" sudo systemctl --no-pager --failed echo -e "\n*** Pacman warnings and errors\n" D1=`date -I` D2=`date -I -d '1 day ago'` grep -Ei "^.("$D1"|"$D2").*(warning|error):" /var/log/pacman.log echo -e "\n*** Superfluous packages\n" pacman -Qtdq | tr '\n' ' ' if [ $# -eq 0 ] || [ "$1" != "check" ]; then echo -e "\n*** Packages with updates left\n" pikaur -Qu || yay -Qu fi echo -e "\n\n*** Scanning for broken symlinks, boot files and binaries\n" sudo find /etc/systemd/system/ -xtype l sudo grep -E "^linux|^initrd|^EFI" /boot/loader/entries/* | awk '{ printf "/boot%s\n",$2 }' | sort | uniq | xargs -n1 ls >/dev/null PYDIRS=$(stat -c '%W %n' /usr/lib/python[3-9].* | sort -n | head -n -1 | awk '{ print $2 }') if [ -n "$PYDIRS" ]; then for d in $PYDIRS; do echo "Found obsolete python directory $d, packages requiring rebuild:" pacman -Qoq "$d" done fi sudo findbrokenpkgs