Last active
March 23, 2022 07:18
-
-
Save lmlsna/5879269c0a1b8fca3dcd31cdcea71e6e to your computer and use it in GitHub Desktop.
Upgrade EOL version of Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script will perform the same function as `do-release-upgrade` when that tool is giving | |
# an error for an EOL verison of Ubuntu, or some other "cannot upgrade from <current> to <next>". | |
# It does this safely by downloading the release-upgrade meta-pacakge from your target distribution. | |
# | |
# See https://help.ubuntu.com/community/EOLUpgrades/ for more information. | |
# Make sure a release is given as argument | |
if [[ "$1" == "" ]]; then | |
echo "Usage: ./$(basename $0) <release_codename_to_update_to>" | |
exit 2 | |
fi | |
CURRENT_RELEASE="$(lsb_release -sc)" | |
TARGET_RELEASE="${1,,}" | |
# If apt-get update fails to find a release file, switch to old-releases instead of archive | |
apt-get update | |
if [[ $? -ne 0 ]]; then | |
echo 'apt-update failed. Trying old-releases repository...' | |
sed "s/http:\/\/.*archive\./http:\/\/old-releases./g" /etc/apt/sources.list | |
fi | |
# Try again | |
apt-get update | |
if [[ $? -ne 0 ]]; then | |
echo 'Still not working, idk...' | |
fi | |
cd /tmp | |
wget "$(curl -sSL 'https://changelogs.ubuntu.com/meta-release' | grep -E '^UpgradeTool:' | grep "$TARGET_RELEASE" | cut -d ' ' -f 2)" -O ${TARGET_RELEASE}.tar.gz | |
rm -r /tmp/updater | |
mkdir /tmp/updater | |
tar -xvf ${TARGET_RELEASE}.tar.gz -C updater | |
cd updater | |
./${TARGET_RELEASE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment