dotfiles/symlinks/bin/print-last-system-upgrade

32 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
if [ $MACHINE_TYPE == "mac" ]; then
if [ ! -f $MY_CONFIG_CACHE_DIR/brew-upgrade-date ]; then
echo $( date +%s ) > $MY_CONFIG_CACHE_DIR/brew-upgrade-date
fi
LAST_BREW_UPGRADE=$( cat $MY_CONFIG_CACHE_DIR/brew-upgrade-date )
print-system-upgrade-date $LAST_BREW_UPGRADE update-all-packages
else
if type pacman &> /dev/null
then
LAST_SYSTEM_UPGRADE=$( cat /var/log/pacman.log | grep "starting full system upgrade" | awk 'END{ print substr($1, 2, length($1)-2) }' )
LAST_SYSTEM_UPGRADE_DATE=$( date -d "$LAST_SYSTEM_UPGRADE" +%s )
fi
if type apt &> /dev/null
then
LAST_SYSTEM_UPGRADE=$( stat /var/cache/apt/pkgcache.bin | grep Modify | sed 's/Modify: //' )
LAST_SYSTEM_UPGRADE_DATE=$( date -d "$LAST_SYSTEM_UPGRADE" +%s )
fi
if type dnf &> /dev/null
then
LAST_SYSTEM_UPGRADE=$( stat /var/cache/dnf/packages.db | grep Modify | sed 's/Modify: //' )
LAST_SYSTEM_UPGRADE_DATE=$( date -d "$LAST_SYSTEM_UPGRADE" +%s )
fi
print-system-upgrade-date $LAST_SYSTEM_UPGRADE_DATE update-all-packages
fi