feat: added optional input of remote host name#18
Conversation
BMDan
left a comment
There was a problem hiding this comment.
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)" |
| 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 |
There was a problem hiding this comment.
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.
|
|
||
| local MYSQL_COMMAND_PARAMS="-S $socket -u$user" | ||
| if [ "$socket" != "" ]; then | ||
| local MYSQL_COMMAND_PARAMS="-S$socket -u$user" |
There was a problem hiding this comment.
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.
| # $1: Path to .my.cnf | ||
| # $2: Path to socket (optional) | ||
| # $3: username | ||
| # $4: password |
There was a problem hiding this comment.
Update this comment to match usage.
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 ^^