2022-01-23 10:37:44 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-01-03 13:33:02 -05:00
|
|
|
if [ -t 1 ] ; then
|
|
|
|
c_134=$'\033[1;34m'
|
|
|
|
c_131=$'\033[1;31m'
|
|
|
|
c_off=$'\033[0m'
|
|
|
|
else
|
|
|
|
c0="c0"
|
|
|
|
fi
|
|
|
|
|
2022-01-23 10:37:44 -05:00
|
|
|
detect_dual_boot() {
|
|
|
|
if [[ $EUID -eq 0 ]] && [[ -x /usr/bin/os-prober ]]; then
|
|
|
|
local OSPROBER_OUT="$(os-prober)" || { DUALBOOT="Os-prober error"; exit; }
|
|
|
|
echo $OSPROBER_OUT | grep -q "Windows Boot Manager" &> /dev/null && DUALBOOT="Yes" || DUALBOOT="No/Undetected"
|
2022-01-27 13:23:27 -05:00
|
|
|
elif [[ -x /usr/bin/efibootmgr ]] && [ -d /boot/efi ]; then
|
2022-01-23 10:37:44 -05:00
|
|
|
local EFIBOOTMGR_OUT="$(efibootmgr)" || { DUALBOOT="Efibootmgr error"; exit; }
|
|
|
|
echo $EFIBOOTMGR_OUT | grep -q "Windows Boot Manager" &> /dev/null && DUALBOOT="Probably (Run as root to verify)" || DUALBOOT="No/Undetected"
|
|
|
|
elif [[ -x /usr/bin/os-prober ]]; then
|
|
|
|
DUALBOOT="<superuser required>"
|
|
|
|
else
|
|
|
|
DUALBOOT="No detection tool installed"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-01-27 13:23:27 -05:00
|
|
|
detect_snapshots() {
|
|
|
|
if [ -d /.snapshots ] || pacman -Qq snapper-support &> /dev/null; then
|
2023-01-02 23:01:43 -05:00
|
|
|
printf "snapper "
|
2022-01-27 13:23:27 -05:00
|
|
|
elif [ -d /run/timeshift ] || pacman -Qq timeshift-support &> /dev/null; then
|
2023-01-02 23:01:43 -05:00
|
|
|
printf "timeshift "
|
2022-01-27 13:23:27 -05:00
|
|
|
elif pacman -Qq snapper &> /dev/null; then
|
2023-01-02 23:01:43 -05:00
|
|
|
printf "snapper(custom) "
|
2022-01-27 13:23:27 -05:00
|
|
|
elif pacman -Qq timeshift &> /dev/null; then
|
2023-01-02 23:01:43 -05:00
|
|
|
printf "timeshift(custom) "
|
2022-01-27 13:23:27 -05:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-01-30 13:47:35 -05:00
|
|
|
generate_relevant_software() {
|
|
|
|
local RELEVANT=()
|
2023-01-02 23:01:43 -05:00
|
|
|
local packages
|
|
|
|
packages="$(pacman -Qq garuda-dracut-support mkinitcpio dracut nvidia-dkms 2> /dev/null | xargs || true)"
|
|
|
|
|
2022-01-30 13:47:35 -05:00
|
|
|
systemctl is-enabled tlp &> /dev/null && RELEVANT+=("tlp")
|
|
|
|
systemctl is-active NetworkManager &> /dev/null && RELEVANT+=("NetworkManager")
|
|
|
|
systemctl is-active connman &> /dev/null && RELEVANT+=("connman")
|
2023-01-02 23:01:43 -05:00
|
|
|
|
|
|
|
if [[ "$packages" =~ (^| )garuda-dracut-support($| ) ]]; then
|
|
|
|
RELEVANT+=("dracut")
|
|
|
|
elif [[ "$packages" =~ (^| )dracut($| ) ]]; then
|
|
|
|
RELEVANT+=("dracut(custom)")
|
|
|
|
fi
|
|
|
|
[[ "$packages" =~ (^| )mkinitcpio($| ) ]] && RELEVANT+=("mkinitcpio")
|
|
|
|
[[ "$packages" =~ (^| )nvidia-dkms($| ) ]] && RELEVANT+=("nvidia-dkms")
|
|
|
|
|
|
|
|
detect_snapshots
|
|
|
|
|
2022-03-13 11:10:53 -04:00
|
|
|
local RELEVANT_SOFTWARE="${RELEVANT[*]}"
|
2022-01-30 13:47:35 -05:00
|
|
|
[ -z "$RELEVANT_SOFTWARE" ] && RELEVANT_SOFTWARE="None"
|
2022-03-13 11:10:53 -04:00
|
|
|
echo "$RELEVANT_SOFTWARE"
|
|
|
|
}
|
|
|
|
|
|
|
|
generate_system_update() {
|
|
|
|
local last_update
|
|
|
|
last_update="$(date -r /var/lib/garuda/last_update +%s 2> /dev/null)" || { echo "Unknown/Never"; return; }
|
|
|
|
local reboot=""
|
|
|
|
if [ "$last_update" -gt "$(date -r /proc +%s)" ]; then
|
2023-01-03 13:33:02 -05:00
|
|
|
reboot=" ${c_131}↻${c_off}"
|
2022-03-13 11:10:53 -04:00
|
|
|
fi
|
|
|
|
echo -e "$(date -d"@$last_update" +%F)${reboot}"
|
2022-01-30 13:47:35 -05:00
|
|
|
}
|
|
|
|
|
2023-01-03 13:33:02 -05:00
|
|
|
inxi -Faz${c0} --zv
|
|
|
|
|
|
|
|
echo -e "${c_134}Garuda ($(pacman -Q garuda-common-settings | awk '{print $2}')):${c_off}"
|
2022-02-02 09:02:13 -05:00
|
|
|
install_date="$(head -n1 /var/log/pacman.log | cut -d " " -f1 | cut -c 2-11)"
|
2023-01-03 13:33:02 -05:00
|
|
|
echo -e "${c_134} System install date:${c_off} ${install_date}"
|
|
|
|
echo -e "${c_134} Last full system update:${c_off} $(generate_system_update)"
|
|
|
|
echo -e "${c_134} Is partially upgraded: ${c_off} $([ -e /var/lib/garuda/partial_upgrade ] && echo Yes || echo No)"
|
|
|
|
echo -e "${c_134} Relevant software: ${c_off} $(generate_relevant_software)"
|
2022-01-27 13:23:27 -05:00
|
|
|
detect_dual_boot &> /dev/null
|
2023-01-03 13:33:02 -05:00
|
|
|
echo -e "${c_134} Windows dual boot: ${c_off} ${DUALBOOT}"
|
|
|
|
echo -e "${c_134} Failed units: ${c_off} $(systemctl list-units --failed --full --all --plain --no-legend | awk '{printf("%s ",$1)}')"
|
2022-02-02 09:02:13 -05:00
|
|
|
if [ "$1" == "funstuff" ]; then
|
|
|
|
update_count="$(paclog --grep="starting full system upgrade" | wc -l)"
|
2023-01-03 13:33:02 -05:00
|
|
|
echo -e "${c_134} Total system updates: ${c_off} ${update_count}"
|
|
|
|
echo -e "${c_134} --> Updates per week: ${c_off} $(( ${update_count}/(($(date +%s) - $(date --date="$install_date" +%s) )/(60*60*24*7)) ))"
|
2022-02-02 09:02:13 -05:00
|
|
|
fi
|
2023-01-03 13:33:02 -05:00
|
|
|
|