Skip to content

feat: added optional input of remote host name#18

Open
Melsi wants to merge 1 commit into
BMDan:mainfrom
Melsi:master
Open

feat: added optional input of remote host name#18
Melsi wants to merge 1 commit into
BMDan:mainfrom
Melsi:master

Conversation

@Melsi
Copy link
Copy Markdown

@Melsi Melsi commented Dec 5, 2021

Hi.

I tried running the script on a server with remote database and added prompting for a host as alternative to socket including saving to .my.cnf.
I know I could have manually created a .my.cnf but maybe this could be of some use ^^

Copy link
Copy Markdown
Owner

@BMDan BMDan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Thank you for contributing. A few small concerns, but nothing stopping this from merging once those are addressed.

Comment thread tuning-primer.sh
local MYSQL_COMMAND_PARAMS="-h$host -uadmin"
fi
MYSQL_COMMAND="mysql $MYSQL_COMMAND_PARAMS -p$(cat /etc/psa/.psa.shadow)"
MYSQLADMIN_COMMAND="mysqladmin $MYSQL_COMMAND_PARAMS-p$(cat /etc/psa/.psa.shadow)"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after PARAMS.

Comment thread tuning-primer.sh
cecho "Found potential sockets: $found_socks"
cecho "Using: $socket" red
read -p "Would you like to provide a different socket?: [y/N] " REPLY
read -p "Would you like to provide a different socket/host?: [y/N] " REPLY
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Host and socket are mutually exclusive*, and the UX of the prompts that follow is strange as a result. Change y/N to something like s/h/N. Or ask host and socket as two separate questions; both approaches strike me as valid.

*: Excepting the weird special case of -h localhost, which is a total disaster unto itself.

Comment thread tuning-primer.sh

local MYSQL_COMMAND_PARAMS="-S $socket -u$user"
if [ "$socket" != "" ]; then
local MYSQL_COMMAND_PARAMS="-S$socket -u$user"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer parameter expansion (${foo[@]} syntax) where possible. It's fine if you'd rather not—to put it mildly, there are quite a few spots in the script that break in the face of parameters with spaces and special characters—but I'd prefer new code to follow best practices whenever practical.

Comment thread tuning-primer.sh
# $1: Path to .my.cnf
# $2: Path to socket (optional)
# $3: username
# $4: password
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this comment to match usage.

@BMDan BMDan linked an issue Dec 10, 2021 that may be closed by this pull request
@BMDan
Copy link
Copy Markdown
Owner

BMDan commented May 2, 2022

@Melsi are you interested in finishing this update and getting it ready for merge? Per #17, it certainly looks like people are interested in the functionality.

Edit: To be clear, anyone else is also welcome to take a crack at it. PRs welcomed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable remote connection with DB

2 participants