Skip to content
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

feat: added optional input of remote host name #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Melsi
Copy link

@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
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.

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
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.

@@ -229,10 +237,11 @@ function second_login_failed()
cecho "Could not auto detect login info!"
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
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.

@@ -242,7 +251,11 @@ function second_login_failed()
read -p "User: " user
read -rsp "Password: " pass

local MYSQL_COMMAND_PARAMS="-S $socket -u$user"
if [ "$socket" != "" ]; then
local MYSQL_COMMAND_PARAMS="-S$socket -u$user"
Copy link
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.

@@ -117,11 +117,14 @@ function write_mycnf() {
# $4: password
Copy link
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
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