2018-05-02 10:29:49 +02:00
|
|
|
#!/usr/bin/env bash
|
2019-08-25 18:38:57 +02:00
|
|
|
|
|
|
|
# A simple script for updating all package managers simultaneously
|
|
|
|
|
|
|
|
# Show commands being executed
|
2018-05-02 10:29:49 +02:00
|
|
|
set -x
|
2019-08-25 18:38:57 +02:00
|
|
|
|
2022-04-03 00:40:07 +02:00
|
|
|
# This is said to be a poor practice that should only be used for debugging
|
2024-07-21 08:45:23 +02:00
|
|
|
#export LC_ALL=C.utf8
|
|
|
|
# More universally supported even on older systems
|
|
|
|
export LC_ALL="en_DK.UTF-8"
|
2022-04-01 20:53:37 +02:00
|
|
|
|
2020-06-11 16:22:14 +02:00
|
|
|
# if hash checks that the command exists
|
2024-06-06 19:59:19 +02:00
|
|
|
if hash apt-get 2> /dev/null; then
|
2023-04-06 11:03:10 +02:00
|
|
|
# I am not sure if -y here even does anything, at least it won't work for
|
|
|
|
# accepting suite changes for Debian when testing becomes stable.
|
|
|
|
# Checking for updates or new packages.
|
|
|
|
apt-get -y update
|
2019-08-25 18:38:57 +02:00
|
|
|
|
2023-04-06 11:03:10 +02:00
|
|
|
# potentially unsafe first time, so there hopefully is space for new kernels
|
|
|
|
apt-get "$@" autoremove
|
2022-09-07 15:10:44 +02:00
|
|
|
|
2023-04-06 11:03:10 +02:00
|
|
|
# If arguments like -y are passed to the script, they become "$@"
|
|
|
|
apt-get "$@" upgrade --with-new-pkgs
|
2020-06-10 22:37:54 +02:00
|
|
|
|
2023-04-06 11:03:10 +02:00
|
|
|
# potentially unsafe, second time after new kernel is installed
|
|
|
|
apt-get "$@" autoremove
|
2019-11-01 09:17:55 +01:00
|
|
|
fi
|
2019-08-25 18:38:57 +02:00
|
|
|
|
2024-06-06 19:59:19 +02:00
|
|
|
if hash dpkg 2> /dev/null; then
|
2023-04-06 11:03:10 +02:00
|
|
|
# In case dpkg was interrupted previously, configure packages.
|
|
|
|
dpkg --configure -a
|
2022-09-07 19:13:07 +02:00
|
|
|
fi
|
|
|
|
|
2022-04-21 08:11:24 +02:00
|
|
|
# Enables Fedora third party repositories if not enabled, otherwise quiet.
|
|
|
|
# My systems most likely have them already
|
2024-06-06 19:59:19 +02:00
|
|
|
if hash fedora-third-party 2> /dev/null; then
|
2023-04-06 11:03:10 +02:00
|
|
|
fedora-third-party enable
|
|
|
|
# Are they enabled?
|
|
|
|
fedora-third-party query
|
2022-04-21 08:11:24 +02:00
|
|
|
fi
|
|
|
|
|
2024-06-06 19:59:19 +02:00
|
|
|
if hash dnf 2> /dev/null; then
|
2023-04-06 11:03:10 +02:00
|
|
|
# I don't know if -y does anything here either and I think this may be
|
|
|
|
# useless, but I am used to it coming from apt and I think it will just
|
|
|
|
# say nothing to do or do nothing if mirrors haven't updated.
|
2024-04-27 20:22:31 +02:00
|
|
|
dnf -v check-update -y
|
2021-02-01 09:26:53 +01:00
|
|
|
|
2023-04-06 11:03:10 +02:00
|
|
|
# potentially unsafe first time, I am not sure if this is concern outside of Debian/Ubuntu though
|
2024-01-02 08:54:00 +01:00
|
|
|
dnf -v "$@" autoremove
|
2022-09-07 19:14:44 +02:00
|
|
|
|
2023-04-06 11:03:10 +02:00
|
|
|
# If arguments like -y are passed to the script, they become "$@"
|
2024-04-18 06:23:59 +02:00
|
|
|
#dnf -v "$@" upgrade
|
|
|
|
|
2024-04-27 20:22:31 +02:00
|
|
|
# Doing check-update and upgrade together seems to be necessary for
|
|
|
|
# Chromium based browsers and their repositories :shrug:
|
2024-04-18 06:23:59 +02:00
|
|
|
dnf -v "$@" upgrade --refresh
|
2021-02-28 14:55:17 +01:00
|
|
|
|
2023-04-06 11:03:10 +02:00
|
|
|
# potentially unsafe, see a few lines above and the apt-get section
|
2024-01-02 08:54:00 +01:00
|
|
|
dnf -v "$@" autoremove
|
2021-01-24 10:04:39 +01:00
|
|
|
fi
|
|
|
|
|
2024-06-06 19:59:19 +02:00
|
|
|
if hash rpmconf 2> /dev/null; then
|
2023-04-06 11:03:10 +02:00
|
|
|
# Tests if there are rpmsave/rpmnew files, hopefully is non-interactive
|
|
|
|
rpmconf -a -t
|
2021-02-21 10:55:08 +01:00
|
|
|
fi
|
|
|
|
|
2024-06-06 19:59:19 +02:00
|
|
|
if hash flatpak 2> /dev/null; then
|
2023-04-06 11:03:10 +02:00
|
|
|
# Flatpak apps are sandboxed and should be safe to update automatically
|
|
|
|
# KEEP --noninteractive IN PLACE! While it removes progress bar, it also
|
|
|
|
# doesn't blink making it worth it in case of migraine attack.
|
|
|
|
flatpak update --noninteractive --assumeyes
|
2023-09-05 09:08:40 +02:00
|
|
|
flatpak update --noninteractive --assumeyes --no-static-deltas
|
2023-04-06 11:03:10 +02:00
|
|
|
# Note to self
|
|
|
|
echo '!!! In case of weird errors e.g. while trying to checkout, try running: flatpak repair'
|
2023-09-05 09:08:40 +02:00
|
|
|
#echo ' 404 is not a weird error, try flatpak <subcommand> --no-static-deltas'
|
2023-04-06 11:03:10 +02:00
|
|
|
# Flatpak's version of `apt autoremove`
|
|
|
|
flatpak uninstall --unused --assumeyes --noninteractive
|
2023-09-27 21:13:56 +02:00
|
|
|
# And as an user although probably inapplicable for sudo/root
|
|
|
|
flatpak update --user --noninteractive --assumeyes
|
|
|
|
flatpak update --user --noninteractive --assumeyes --no-static-deltas
|
|
|
|
flatpak uninstall --user --unused --assumeyes --noninteractive
|
2019-11-01 09:17:55 +01:00
|
|
|
fi
|
2019-08-25 18:38:57 +02:00
|
|
|
|
2024-06-06 19:59:19 +02:00
|
|
|
if hash snap 2> /dev/null; then
|
2024-03-19 12:23:30 +01:00
|
|
|
# I don't want my systems full of old snaps
|
|
|
|
# > retain must be a number between 2 and 20, not "1"
|
|
|
|
snap set system refresh.retain=2
|
2023-04-06 11:03:10 +02:00
|
|
|
# Snap packages auto-update anyway though, but I like checking them while
|
|
|
|
# doing everything else too
|
|
|
|
snap refresh
|
|
|
|
# so I may have some sort of an idea when snap packages have been updated
|
|
|
|
# if they have auto-refreshed
|
|
|
|
snap changes
|
2019-11-01 09:17:55 +01:00
|
|
|
fi
|
2023-01-15 13:47:41 +01:00
|
|
|
# I don't have flatpak or snap going to background, because I often do
|
|
|
|
# ./deb-update.bash && poweroff
|
2019-08-25 18:38:57 +02:00
|
|
|
|
2024-06-06 19:59:19 +02:00
|
|
|
if hash pkcon 2> /dev/null; then
|
2024-07-22 06:22:59 +02:00
|
|
|
# KDE Plasma uses PackageKit for the update indicator
|
2024-07-22 14:26:10 +02:00
|
|
|
pkcon backend-details --noninteractive --plain --verbose
|
2024-07-22 06:22:59 +02:00
|
|
|
pkcon refresh --noninteractive --plain --verbose
|
2024-07-22 14:26:10 +02:00
|
|
|
(pkcon get-updates --noninteractive --plain --verbose &)
|
|
|
|
(pkcon get-distro-upgrades --noninteractive --plain --verbose &)
|
2024-07-22 06:22:59 +02:00
|
|
|
pkcon update --noninteractive --plain --verbose
|
2021-02-21 10:55:08 +01:00
|
|
|
fi
|
|
|
|
|
2024-06-06 19:59:19 +02:00
|
|
|
if hash apt-file 2> /dev/null; then
|
2023-04-06 11:03:10 +02:00
|
|
|
# So the local apt-file database is up-to-date.
|
|
|
|
apt-file update
|
2019-11-01 09:17:55 +01:00
|
|
|
fi
|
2019-08-25 18:38:57 +02:00
|
|
|
|
2024-06-06 19:59:19 +02:00
|
|
|
if hash needrestart 2> /dev/null; then
|
2023-04-06 11:03:10 +02:00
|
|
|
# needrestart batch mode, should be visible on bottom of scrollback
|
|
|
|
# see https://github.com/liske/needrestart/blob/master/README.batch.md
|
|
|
|
needrestart -b
|
2024-05-05 10:21:30 +02:00
|
|
|
# Give me a moment to see what needrestart says even if I pipe or enter
|
|
|
|
# multiple commands at once!
|
|
|
|
sleep 5
|
2021-02-21 10:55:08 +01:00
|
|
|
fi
|
|
|
|
|
2022-09-11 13:10:50 +02:00
|
|
|
# Sedric workaround, located in this repo. I trust /root/
|
2023-05-18 11:25:47 +02:00
|
|
|
if [ -f /root/fixgrub.bash ]; then
|
2023-04-06 11:03:10 +02:00
|
|
|
/root/fixgrub.bash
|
2022-09-11 13:10:50 +02:00
|
|
|
fi
|
|
|
|
|
2024-05-03 18:51:05 +02:00
|
|
|
# Lumina & Sedric have been having kernel update issues, let's see if this
|
|
|
|
# script could detect and suggest action for that.
|
|
|
|
if [ -f /root/fix-kernel-install.bash ]; then
|
|
|
|
/root/fix-kernel-install.bash
|
|
|
|
fi
|
|
|
|
|
2019-08-25 18:38:57 +02:00
|
|
|
# Hide commands being executed again
|
2018-05-02 10:29:49 +02:00
|
|
|
set +x
|