52 lines
1.1 KiB
Bash
Executable File
52 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
working_dir="$(dirname $(realpath $0))"
|
|
conf_file="${working_dir}/conf/mysql_credetials.conf"
|
|
|
|
#LOGGING=true
|
|
LOGGING=false
|
|
|
|
mysqladmin=`realpath $(which mysqladmin) 2>/dev/null`
|
|
if [ -z "$mysqladmin" ]; then
|
|
if [ -x "/usr/local/mysql/bin/mysqladmin" ]; then
|
|
mysql=/usr/local/mysql/bin/mysqladmin
|
|
else
|
|
echo
|
|
echo -e "\t[ Error ]: \"mysqladmin\" not found !!!"
|
|
echo
|
|
exit
|
|
fi
|
|
fi
|
|
|
|
|
|
#---------------------------------------
|
|
#-----------------------------
|
|
# Read Configurations from $conf_file
|
|
#-----------------------------
|
|
#---------------------------------------
|
|
|
|
if [[ -f "$conf_file" ]]; then
|
|
source "$conf_file"
|
|
fi
|
|
|
|
[[ -z "$mysql_credential_args" ]] && mysql_credential_args="--login-path=local"
|
|
|
|
|
|
if $LOGGING ;then
|
|
echo -e "\n[ `date` ] Going to flush host cache.."
|
|
fi
|
|
|
|
if [ -n "$mysql_credential_args" ] ; then
|
|
$mysqladmin $mysql_credential_args flush-hosts
|
|
else
|
|
$mysqladmin -u$mysql_user -p$mysql_password flush-hosts
|
|
fi
|
|
|
|
[[ $? -gt 0 ]] && echo -e "\t[ Error ]: Flushing host cache failed !!"
|
|
|
|
if $LOGGING ;then
|
|
echo -e "\n[ `date` ] End flushing host cache"
|
|
fi
|
|
|
|
exit 0
|