2019-12-06 16:31:10 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
upgrade_system() {
|
2021-05-01 18:45:32 -04:00
|
|
|
(
|
|
|
|
set -euo pipefail
|
2019-12-06 16:31:10 -05:00
|
|
|
|
2021-05-01 18:45:32 -04:00
|
|
|
case "$(uname | tr '[:upper:]' '[:lower:]')" in
|
|
|
|
'darwin')
|
|
|
|
if command -v brew &> /dev/null; then
|
|
|
|
brew update
|
|
|
|
brew upgrade
|
|
|
|
fi
|
|
|
|
;;
|
2020-05-25 13:36:22 -04:00
|
|
|
|
2021-05-01 18:45:32 -04:00
|
|
|
'linux')
|
2021-12-16 09:47:24 -05:00
|
|
|
# Flatpak (could be just about any distro)
|
|
|
|
if command -v flatpak &> /dev/null; then
|
|
|
|
flatpak update
|
|
|
|
fi
|
|
|
|
|
2021-05-01 18:45:32 -04:00
|
|
|
# Debian/Ubuntu
|
|
|
|
if command -v apt &> /dev/null; then
|
2022-04-25 11:58:37 -04:00
|
|
|
sudo "$SHELL" -c 'apt update && apt upgrade'
|
2021-05-01 18:45:32 -04:00
|
|
|
fi
|
2020-05-25 13:36:22 -04:00
|
|
|
|
2021-05-01 18:45:32 -04:00
|
|
|
# Fedora
|
|
|
|
if command -v dnf &> /dev/null; then
|
|
|
|
sudo dnf upgrade
|
2023-06-21 10:35:05 -04:00
|
|
|
fi
|
2019-12-06 16:31:10 -05:00
|
|
|
|
2021-05-01 18:45:32 -04:00
|
|
|
# Arch
|
|
|
|
if command -v yay &> /dev/null; then
|
|
|
|
yay -Syu --devel --timeupdate
|
|
|
|
elif command -v pacman &> /dev/null; then
|
|
|
|
sudo pacman -Syu
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
2019-12-06 16:31:10 -05:00
|
|
|
|
2022-06-24 20:38:28 -04:00
|
|
|
if command -v asdf &> /dev/null; then
|
2023-09-28 10:10:41 -04:00
|
|
|
(
|
|
|
|
cd "$HOME"
|
|
|
|
asdf update || true
|
|
|
|
asdf plugin update --all
|
|
|
|
asdf latest --all | grep -Ev '^(python|nodejs)'
|
|
|
|
LATEST_PYTHON_VERSION="$(asdf latest python)"
|
|
|
|
CURRENT_PYTHON_VERSION="$(asdf current python | awk '{print $2}')"
|
|
|
|
echo -en "python\t${LATEST_PYTHON_VERSION}\t"
|
|
|
|
if [[ "$LATEST_PYTHON_VERSION" == "$CURRENT_PYTHON_VERSION" ]]; then
|
|
|
|
echo "installed"
|
|
|
|
else
|
|
|
|
echo "missing"
|
|
|
|
fi
|
|
|
|
asdf list all nodejs |
|
|
|
|
awk -v lts="$(asdf nodejs resolve lts)" \
|
|
|
|
-v current="$(asdf current nodejs | awk '{print $2}')" \
|
|
|
|
'index($0, lts) == 1 {latest=$0} END {
|
|
|
|
printf "nodejs\t"latest"\t"
|
|
|
|
if(latest == current) {
|
|
|
|
print "installed"
|
|
|
|
} else {
|
|
|
|
print "missing"
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
)
|
2022-06-24 20:38:28 -04:00
|
|
|
fi
|
|
|
|
|
2021-05-01 18:45:32 -04:00
|
|
|
if command -v fwupdmgr &> /dev/null; then
|
2022-06-14 09:31:30 -04:00
|
|
|
(
|
|
|
|
# 2 is a valid exit code for the fwupdmgr where
|
|
|
|
# the operation was successful but did not require
|
|
|
|
# action
|
|
|
|
set +e
|
|
|
|
|
|
|
|
fwupdmgr refresh
|
|
|
|
STATUS=$?
|
|
|
|
if [ $STATUS -ne 0 ] && [ $STATUS -ne 2 ]; then
|
|
|
|
exit $STATUS
|
|
|
|
fi
|
|
|
|
|
|
|
|
fwupdmgr upgrade
|
|
|
|
STATUS=$?
|
|
|
|
if [ $STATUS -ne 0 ] && [ $STATUS -ne 2 ]; then
|
|
|
|
exit $STATUS
|
|
|
|
fi
|
|
|
|
)
|
2021-05-01 18:45:32 -04:00
|
|
|
fi
|
|
|
|
)
|
2020-05-25 13:56:17 -04:00
|
|
|
}
|