New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mysql: Pull out the correct variable when setting read-only mode #406
Conversation
MariaDB10 has 3 variables that include read_only. Pull out the correct variable instead of grep'ing for it.
or read_only_state=`$MYSQL $MYSQL_OPTIONS_REPL \ -ss -e "select @@read_only" ` if [ $read_only_state -eq 1 ]; then |
for correctness it should also be SHOW GLOBAL VARIABLES LIKE 'read_only' |
@grooverdan Merged in the 2 suggestions, Thanks. |
Currently, this PR is broken. I don't know if it is because of changes in the mysql agent, either way it would need to be fixed to be merged. @symonds, still interested in submitting this? |
|
||
if [ "$read_only_state" = "ON" ]; then | ||
if [ $read_only_state =~ '*ON' ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to http://shellcheck.net, this has two issues:
- SC2074 Can't use =~ in [ ]. Use [[..]] instead.
- Don't quote rhs of =~, it'll match literally rather than as a regex. 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Mon, Feb 22, 2016 at 06:00:05AM -0800, Kristoffer Grönlund wrote:
- if [ "$read_only_state" = "ON" ]; then
- if [ $read_only_state =~ '*ON' ]; then
According to http://shellcheck.net, this has two issues:
- SC2074 Can't use =~ in [ ]. Use [[..]] instead.
I think that [[..]] is a bashism, this is a /bin/sh script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=~
is not in POSIX test either
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Mon, Feb 22, 2016 at 07:14:15AM -0800, Kristoffer Grönlund wrote:
- if [ "$read_only_state" = "ON" ]; then
- if [ $read_only_state =~ '*ON' ]; then
=~
is not in POSIX test either
Right, so it shouldn't be used. Just wanted to warn about
introducing stuff which aren't available in /bin/sh.
MariaDB10 has 3 variables that include read_only. Pull out the correct variable instead of grep'ing for it.