Hi,
This is basically a Bash scripting question, but since it concerns Rocky Linux, I thought I might as well ask here.
The following code snippet checks if the script is running on Rocky Linux 8.x and exits if this is not the case:
# Make sure we're running Rocky Linux 8.x.
if [ -f /etc/os-release ]
then
source /etc/os-release
OS="${ROCKY_SUPPORT_PRODUCT}"
VER="${ROCKY_SUPPORT_PRODUCT_VERSION}"
else
echo
echo "Unsupported operating system." >&2
echo
exit 1
fi
if [ "${OS}" != "Rocky Linux" ] && [ "${VER}" != "8" ]
then
echo
echo "Unsupported operating system." >&2
echo
exit 1
fi
Is there a way to write this in a more elegant in compact manner? My Bash scripting skills are a bit rusty.
Thanks & cheers from the sunny South of France,
Niki