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

32 lines
1.0 KiB
Plaintext
Raw Permalink Normal View History

2021-01-07 08:09:41 +00:00
#!/bin/bash
if [ $MACHINE_TYPE == "mac" ]; then
2022-05-09 11:00:44 +00:00
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
2021-01-07 08:09:41 +00:00
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) }' )
2021-01-07 08:09:41 +00:00
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
2022-07-16 18:02:20 +00:00
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
2021-01-07 08:09:41 +00:00
print-system-upgrade-date $LAST_SYSTEM_UPGRADE_DATE update-all-packages
fi