create_database.sh, max_memory_limit_mysql.sh: use configuration file 'mysql_credetials.conf'.

This commit is contained in:
2018-12-10 16:32:47 +01:00
parent 5221328f91
commit eb335c9a95
2 changed files with 79 additions and 75 deletions

View File

@@ -3,7 +3,7 @@
working_dir="$(dirname $(realpath $0))"
log_dir="${working_dir}/log"
conf_file="${working_dir}/conf/create_drop_database.conf"
conf_file="${working_dir}/conf/mysql_credetials.conf"
tmp_log_file="$(mktemp)"
@@ -277,8 +277,11 @@ else
warn "No Configuration File found. Loading defaults.."
fi
[[ -n "$MYSQL_CREDENTIAL_ARGS" ]] || MYSQL_CREDENTIAL_ARGS="$DEFAULT_MYSQL_CREDENTIAL_ARGS"
#[[ -n "$ACTION" ]] || ACTION="$DEFAULT_ACTION"
if [[ -n "$mysql_credential_args" ]]; then
MYSQL_CREDENTIAL_ARGS="$mysql_credential_args"
else
MYSQL_CREDENTIAL_ARGS="$DEFAULT_MYSQL_CREDENTIAL_ARGS"
fi
if ! $NON_INTERACTIVE_MODE ; then
@@ -464,59 +467,60 @@ else
echo_ok
fi
if [[ "$MYSQL_CUR_DISTRIBUTION" = "MariaDB" ]] ; then
echononl " Grant usage to user '$DATABASE_USER' (Creates User..)"
mysql $MYSQL_CREDENTIAL_ARGS -N -s -e \
"GRANT USAGE ON *.* TO '$DATABASE_USER'@'localhost' IDENTIFIED BY '$DATABASE_PASSWD'" > $tmp_log_file 2>&1
if [[ $? -ne 0 ]] ; then
echo_failed
error "$(cat $tmp_log_file)"
else
echo_ok
fi
echononl " Grant all privileges to user '$DATABASE_USER' on Database '$DATABASE_NAME'"
mysql $MYSQL_CREDENTIAL_ARGS -N -s -e \
"GRANT ALL PRIVILEGES ON ${DATABASE_NAME}.* TO '$DATABASE_USER'@'localhost'" > $tmp_log_file 2>&1
if [[ $? -ne 0 ]] ; then
echo_failed
error "$(cat $tmp_log_file)"
else
echo_ok
fi
if $ACCESS_FROM_OUTSIDE ; then
for _ip in $IP_ADDRESSES ; do
echononl " Grant usage to user '$DATABASE_USER' access from ${_ip}"
mysql $MYSQL_CREDENTIAL_ARGS -N -s -e \
"GRANT USAGE ON *.* TO '$DATABASE_USER'@'${_ip}' IDENTIFIED BY '$DATABASE_PASSWD'" > $tmp_log_file 2>&1
if [[ $? -ne 0 ]] ; then
echo_failed
error "$(cat $tmp_log_file)"
else
echo_ok
fi
echononl " Grant all privileges to user '$DATABASE_USER' on Database '$DATABASE_NAME' from $_ip"
mysql $MYSQL_CREDENTIAL_ARGS -N -s -e \
"GRANT ALL PRIVILEGES ON ${DATABASE_NAME}.* TO '$DATABASE_USER'@'${_ip}'" > $tmp_log_file 2>&1
if [[ $? -ne 0 ]] ; then
echo_failed
error "$(cat $tmp_log_file)"
else
echo_ok
fi
done
fi
elif [[ $MAJOR_VERSION -gt 8 ]] \
#if [[ "$MYSQL_CUR_DISTRIBUTION" = "MariaDB" ]] ; then
#
# echononl " Grant usage to user '$DATABASE_USER' (Creates User..)"
# mysql $MYSQL_CREDENTIAL_ARGS -N -s -e \
# "GRANT USAGE ON *.* TO '$DATABASE_USER'@'localhost' IDENTIFIED BY '$DATABASE_PASSWD'" > $tmp_log_file 2>&1
# if [[ $? -ne 0 ]] ; then
# echo_failed
# error "$(cat $tmp_log_file)"
# else
# echo_ok
# fi
#
# echononl " Grant all privileges to user '$DATABASE_USER' on Database '$DATABASE_NAME'"
# mysql $MYSQL_CREDENTIAL_ARGS -N -s -e \
# "GRANT ALL PRIVILEGES ON ${DATABASE_NAME}.* TO '$DATABASE_USER'@'localhost'" > $tmp_log_file 2>&1
# if [[ $? -ne 0 ]] ; then
# echo_failed
# error "$(cat $tmp_log_file)"
# else
# echo_ok
# fi
#
# if $ACCESS_FROM_OUTSIDE ; then
#
# for _ip in $IP_ADDRESSES ; do
#
# echononl " Grant usage to user '$DATABASE_USER' access from ${_ip}"
# mysql $MYSQL_CREDENTIAL_ARGS -N -s -e \
# "GRANT USAGE ON *.* TO '$DATABASE_USER'@'${_ip}' IDENTIFIED BY '$DATABASE_PASSWD'" > $tmp_log_file 2>&1
# if [[ $? -ne 0 ]] ; then
# echo_failed
# error "$(cat $tmp_log_file)"
# else
# echo_ok
# fi
#
# echononl " Grant all privileges to user '$DATABASE_USER' on Database '$DATABASE_NAME' from $_ip"
# mysql $MYSQL_CREDENTIAL_ARGS -N -s -e \
# "GRANT ALL PRIVILEGES ON ${DATABASE_NAME}.* TO '$DATABASE_USER'@'${_ip}'" > $tmp_log_file 2>&1
# if [[ $? -ne 0 ]] ; then
# echo_failed
# error "$(cat $tmp_log_file)"
# else
# echo_ok
# fi
#
# done
#
# fi
#
#elif [[ $MAJOR_VERSION -gt 8 ]] \
if [[ "$MYSQL_CUR_DISTRIBUTION" = "MySQL" ]] && ([[ $MAJOR_VERSION -gt 8 ]] \
|| ( [[ $MAJOR_VERSION -eq 8 ]] && [[ $MINOR_VERSION -gt 0 ]] ) \
|| ( [[ $MAJOR_VERSION -eq 8 ]] && [[ $MINOR_VERSION -eq 0 ]] && [[ $PATCH_LEVEL -ge 3 ]] ) ; then
|| ( [[ $MAJOR_VERSION -eq 8 ]] && [[ $MINOR_VERSION -eq 0 ]] && [[ $PATCH_LEVEL -ge 3 ]] )) ; then
# - Use (password) plugin mysql_native_password
# -