Last active
July 26, 2023 19:21
-
-
Save dviererbe/0255733d25a27c9a3ddc0bfc9535c243 to your computer and use it in GitHub Desktop.
Check if the ubuntu image '-latest' redirects work.
This file contains 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
#!/usr/bin/env bash | |
# Check if the ubuntu image '-latest' redirects work. | |
#source /etc/os-release | |
UBUNTU_CODENAME=jammy | |
VERSION_ID=22.04 | |
all_checks_successful=true | |
function check_url() | |
{ | |
url="$1" | |
if ! response=$(curl --silent --head --output /dev/null --write-out '%{http_code}' "$url"); then | |
echo "Failed to run curl for url '$url' (Exit Code: $?)." | |
fi | |
if [ "$response" != "301" ]; then # 301 is the expected status code for a redirect | |
all_checks_successful=false | |
echo "Get $url resonded with $response" | |
fi | |
} | |
function server_image_url() | |
{ | |
DPKG_ARCH=$1 | |
if [ "$DPKG_ARCH" = "amd64" ]; then | |
echo https://releases.ubuntu.com/$UBUNTU_CODENAME/ubuntu-$VERSION_ID-latest-live-server-$DPKG_ARCH.iso | |
else | |
echo http://cdimage.ubuntu.com/releases/$UBUNTU_CODENAME/release/ubuntu-$VERSION_ID-latest-live-server-$DPKG_ARCH.iso | |
fi | |
} | |
function desktop_image_url() | |
{ | |
DPKG_ARCH=$1 | |
if [ "$DPKG_ARCH" = "amd64" ]; then | |
echo https://releases.ubuntu.com/$UBUNTU_CODENAME/ubuntu-$VERSION_ID-latest-desktop-$DPKG_ARCH.iso | |
else | |
echo http://cdimage.ubuntu.com/releases/$UBUNTU_CODENAME/release/ubuntu-$VERSION_ID-latest-desktop-$DPKG_ARCH.iso | |
fi | |
} | |
check_url "$(server_image_url amd64)" | |
check_url "$(desktop_image_url amd64)" | |
check_url "$(server_image_url arm64)" | |
check_url "$(server_image_url ppc64el)" | |
check_url "$(server_image_url s390x)" | |
if $all_checks_successful; then | |
echo "All checks successful!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated script, because there are no desktop images for s390x, arm64, ppc64el and riscv64 and the live-server riscv64 image is not an
.iso
, as there is no cdrom drive.