I have a the function is_mysql_db() to identify if the installed database in the server is a mysql server. So ideally the code in main body should call the function to determine whether I should consider this server a mysql server or not.
I tried at the end of the function to put double brackets, single "=", using or not variable for comparison. I am honestly out of ideas and I would like this code to look as clear as possible as this is only a small part of it.
Below my sample code:
#!/bin/bash
is_mysql_db(){
yum_mysql_out=$(yum list installed | grep mysql-community | awk '{ print $1 }' | tail -n1)
[ $yum_mysql_out == "mysql-community-server.x86_64" ]
}
if [ is_mysql_db ]
then
echo "Installed"
else
echo "Not Installed"
fi
I would expect if the MySQL yum package is installed to detect it and return the package is installed and if its not to return Not Installed. Simple but not that much apparently.