diff --git a/conf/mysql_credetials.conf.sample b/conf/mysql_credetials.conf.sample new file mode 100644 index 0000000..a5f10e3 --- /dev/null +++ b/conf/mysql_credetials.conf.sample @@ -0,0 +1,34 @@ +# ---------------------------------------------------- +# --- +# - Parameter Settings for Script 'optimize_mysql_tables.sh' +# --- +# ---------------------------------------------------- + + +# - MySQL / MariaDB credentials +# - +# - Giving password on command line is insecure an sind mysql 5.5 +# - you will get a warning doing so. +# - +# - Reading username/password fro file ist also possible, using MySQL/MariaDB +# - commandline parameter '--defaults-file'. +# - +# - Since Version 5.6, that method is considered as insecure. +# - To avoid giving the password on command line, we use an +# - encrypted option file +# - +# - Create (encrypted) option file: +# - $ mysql_config_editor set --login-path=local --socket=/var/run/mysqld/mysqld.sock --user=backup --password +# - $ Password: +# - +# - Use of option file: +# - $ mysql --login-path=local ... +# - +# - Example +# - mysql_credential_args="--login-path=local" +# - mysql_credential_args="--defaults-file=/etc/mysql/debian.cnf" (Debian default) +# - mysql_credential_args="--defaults-file=/usr/local/mysql/sys-maint.cnf" +# - +# - Defaults to mysql_credential_args="--login-path=local" +# - +mysql_credential_args="" diff --git a/flush_host_cache.sh b/flush_host_cache.sh index c6afe5d..45b0909 100755 --- a/flush_host_cache.sh +++ b/flush_host_cache.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +working_dir="$(dirname $(realpath $0))" +conf_file="${working_dir}/conf/mysql_credetials.conf" + #LOGGING=true LOGGING=false @@ -15,20 +18,19 @@ if [ -z "$mysqladmin" ]; then fi fi -## - Since Version 5.6, that method is considered as insecure. -## - To avoid giving the password on command line, we use an -## - encrypted option file -## - -## - Create (encrypted) option file: -## - $ mysql_config_editor set --login-path=local --socket=/var/run/mysqld/mysqld.sock --user=backup --password -## - $ Password: -## - -## - Use of option file: -## - $ mysql --login-path=local ... -## - -mysql_credential_args="--login-path=local" -#mysql_user='sys-maint' -#mysql_password='9A7NUgaJST1XiEUU' + +#--------------------------------------- +#----------------------------- +# 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.." diff --git a/flush_query_cache.sh b/flush_query_cache.sh index f885981..71b0366 100755 --- a/flush_query_cache.sh +++ b/flush_query_cache.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +working_dir="$(dirname $(realpath $0))" +conf_file="${working_dir}/conf/mysql_credetials.conf" + #LOGGING=true LOGGING=false @@ -15,20 +18,19 @@ if [ -z "$mysql" ]; then fi fi -## - Since Version 5.6, that method is considered as insecure. -## - To avoid giving the password on command line, we use an -## - encrypted option file -## - -## - Create (encrypted) option file: -## - $ mysql_config_editor set --login-path=local --socket=/var/run/mysqld/mysqld.sock --user=backup --password -## - $ Password: -## - -## - Use of option file: -## - $ mysql --login-path=local ... -## - -mysql_credential_args="--login-path=local" -#mysql_user='sys-maint' -#mysql_password='9A7NUgaJST1XiEUU' + +#--------------------------------------- +#----------------------------- +# 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 query cache.." diff --git a/optimize_mysql_tables.sh b/optimize_mysql_tables.sh index be84e05..ff6d827 100755 --- a/optimize_mysql_tables.sh +++ b/optimize_mysql_tables.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash working_dir="$(dirname $(realpath $0))" -conf_file="${working_dir}/conf/optimize_mysql_tables.conf" +conf_file="${working_dir}/conf/mysql_credetials.conf" # - Is this script running on terminal ? # -