#!/bin/bash

#Cursor GPT prompt:
#Please do any improvement you find fit.
#
#Please comment (#) in the end what was changed and why it is better.
#
#Please don't change the color names.

# Colors
Red='\e[0;31m'  # Kept color names as requested
BRed='\e[1;31m'  # Kept color names as requested
BIRed='\e[1;91m'  # Kept color names as requested
Gre='\e[0;32m'  # Kept color names as requested
BGre='\e[1;32m'  # Kept color names as requested
BBlu='\e[1;34m'  # Kept color names as requested
BWhi='\e[1;37m'  # Kept color names as requested
RCol='\e[0m'  # Kept color names as requested

codename="$(grep UBUNTU_CODENAME /etc/os-release | cut -d = -f 2)"
osname="$(grep -E '="?Ubuntu"?$' /etc/os-release | cut -d = -f 2)"

if [[ "$codename" =~ ^(focal|hirsute|impish|jammy|kinetic)$ && $osname == \"Ubuntu\" ]]; then  # Changed the condition for better readability
  bash src/pre-23.sh "$@"  # Changed to use double quotes for consistency
fi

if [[ "$codename" =~ ^(lunar|mantic|noble)$ && $osname == \"Ubuntu\" ]]; then
  bash src/post-23.sh "$@"  # Changed to use double quotes for consistency
fi

if [[ "$codename" =~ ^(focal|hirsute|impish|jammy|kinetic|lunar|mantic|noble)$ && $osname == \"Ubuntu\" ]]; then  # Changed the condition for better readability
: #no-op cmd, thanks to https://stackoverflow.com/a/17583599
else
  echo -e "${Red}
------------------------------------------------------------------
Sorry, Script is only for Ubuntu ${BWhi}20.04, 21.04, 21.10, 22.04, 22.10, 23.04 & 23.10 & 24.04${Red} Only
Exiting...
------------------------------------------------------------------
${RCol}"
  exit 1
fi
