ubuntu tools misc

This commit is contained in:
2025-03-19 19:08:19 +08:00
parent b70b89433b
commit 021db1064e
5 changed files with 8 additions and 31 deletions

39
tools/ubuntu/desktop-upgrade.sh Executable file
View File

@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# https://dev.to/chefgs/upgrading-an-end-of-life-eol-ubuntu-os-to-lts-version-3a36
# https://changelogs.ubuntu.com/meta-release
# shellcheck disable=SC1091
source /etc/os-release
echo "Loading..."
mapfile -t codenames < <(curl -s https://changelogs.ubuntu.com/meta-release | grep -oP '(?<=Dist:\s).*')
thisCodename="$VERSION_CODENAME"
for idx in "${!codenames[@]}"; do
if [ "${codenames[idx]}" = "$thisCodename" ]; then
nextCodename=${codenames[((idx+1))]}
fi
done
targetDownloadPath="$(pwd)/upgrade-$nextCodename"
targetToolPath="$targetDownloadPath/unpacked"
targetToolFile="$targetDownloadPath/$nextCodename.tar.gz"
echo "Current dist: $thisCodename"
echo "Next dist: $nextCodename"
echo "Target path: $targetToolFile"
rm -rf "$targetToolPath"
mkdir -p "$targetToolPath"
echo "Downloading..."
cd "$targetDownloadPath" || exit 1
wget "http://archive.ubuntu.com/ubuntu/dists/${nextCodename}-updates/main/dist-upgrader-all/current/${nextCodename}.tar.gz"
echo "Unpacking..."
tar -xaf "$targetToolFile" -C "$targetToolPath"
echo "Starting..."
cd ./unpacked || exit 1
# shellcheck disable=SC2086
sudo ./$nextCodename