mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-05-16 01:07:12 +08:00
pt-mysql-summary added ask-pass option
This commit is contained in:
+14
-1
@@ -75,6 +75,7 @@ HAVE_EXT_ARGV="" # Got --, everything else is put into EXT_ARGV
|
||||
OPT_ERRS=0 # How many command line option errors
|
||||
OPT_VERSION="" # If --version was specified
|
||||
OPT_HELP="" # If --help was specified
|
||||
OPT_ASK_PASS="" # If --ask-pass was specified
|
||||
PO_DIR="" # Directory with program option spec files
|
||||
|
||||
usage() {
|
||||
@@ -175,6 +176,7 @@ parse_options() {
|
||||
OPT_ERRS=0
|
||||
OPT_VERSION=""
|
||||
OPT_HELP=""
|
||||
OPT_ASK_PASS=""
|
||||
PO_DIR="$PT_TMPDIR/po"
|
||||
|
||||
if [ ! -d "$PO_DIR" ]; then
|
||||
@@ -489,7 +491,14 @@ mysql_options() {
|
||||
if [ -n "$OPT_USER" ]; then
|
||||
MYSQL_ARGS="$MYSQL_ARGS --user=$OPT_USER"
|
||||
fi
|
||||
if [ -n "$OPT_PASSWORD" ]; then
|
||||
if [ -n "$OPT_ASK_PASS" ]; then
|
||||
stty -echo
|
||||
>&2 printf "Enter MySQL password: "
|
||||
read GIVEN_PASS
|
||||
stty echo
|
||||
printf "\n"
|
||||
MYSQL_ARGS="$MYSQL_ARGS --password=$GIVEN_PASS"
|
||||
elif [ -n "$OPT_PASSWORD" ]; then
|
||||
MYSQL_ARGS="$MYSQL_ARGS --password=$OPT_PASSWORD"
|
||||
fi
|
||||
|
||||
@@ -2923,6 +2932,10 @@ All options after -- are passed to C<mysql>.
|
||||
|
||||
mysqldump and summarize all databases. See L<"--databases">.
|
||||
|
||||
=item --ask-pass
|
||||
|
||||
Prompt for a password when connecting to MySQL.
|
||||
|
||||
=item --config
|
||||
|
||||
type: string
|
||||
|
||||
@@ -40,7 +40,15 @@ mysql_options() {
|
||||
if [ -n "$OPT_USER" ]; then
|
||||
MYSQL_ARGS="$MYSQL_ARGS --user=$OPT_USER"
|
||||
fi
|
||||
if [ -n "$OPT_PASSWORD" ]; then
|
||||
# handle ask-pass option (issue lp#1455486)
|
||||
if [ -n "$OPT_ASK_PASS" ]; then
|
||||
stty -echo
|
||||
>&2 printf "Enter MySQL password: "
|
||||
read GIVEN_PASS
|
||||
stty echo
|
||||
printf "\n"
|
||||
MYSQL_ARGS="$MYSQL_ARGS --password=$GIVEN_PASS"
|
||||
elif [ -n "$OPT_PASSWORD" ]; then
|
||||
MYSQL_ARGS="$MYSQL_ARGS --password=$OPT_PASSWORD"
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user