diff options
author | Micah Anderson <micah@riseup.net> | 2005-12-27 17:38:07 +0000 |
---|---|---|
committer | Micah Anderson <micah@riseup.net> | 2005-12-27 17:38:07 +0000 |
commit | def238857d639692f86290681bc5f0572aaadb9e (patch) | |
tree | 1d1d271656e09d7cdba06e5d78544d261808d0b2 | |
parent | 065c9aa959922aaad5d9453335cd3fc5c3495bcd (diff) | |
download | backupninja-def238857d639692f86290681bc5f0572aaadb9e.tar.gz backupninja-def238857d639692f86290681bc5f0572aaadb9e.tar.bz2 |
r221@um: micah | 2005-12-27 11:54:34 -0500
If the user is set, make sure the --defaults-file is set for
that user.
-rw-r--r-- | handlers/mysql | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/handlers/mysql b/handlers/mysql index 20905d5..8507acc 100644 --- a/handlers/mysql +++ b/handlers/mysql @@ -47,32 +47,6 @@ then fi fi -if [ "$user" == "" ]; then - userset=false; - user=root; -else - userset=true; - if [ $usevserver ] - then - userhome=`$VSERVER $vsname exec getent passwd "$user" | awk -F: '{print $6}'` - if [ $? -eq 2 ] - then - fatal "User $user not found in /etc/passwd" - fi - userhome="$vroot$userhome" - debug "User home set to: $userhome" - [ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf" - else - userhome=`getent passwd "$user" | awk -F: '{print $6}'` - if [ $? -eq 2 ] - then - fatal "User $user not found in /etc/passwd" - fi - debug "User home set to: $userhome" - [ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf" - fi -fi - ## Prepare ignore part of the command ## This only works for mysqldump at the moment @@ -170,6 +144,33 @@ elif [ "$userset" == "false" ]; then defaultsfile="--defaults-file=$configfile" fi +if [ "$user" == "" ]; then + userset=false; + user=root; +else + userset=true; + if [ $usevserver ] + then + vuserhome=`$VSERVER $vsname exec getent passwd "$user" | awk -F: '{print $6}'` + if [ $? -eq 2 ] + then + fatal "User $user not found in /etc/passwd" + fi + userhome="$vroot$vuserhome" + else + userhome=`getent passwd "$user" | awk -F: '{print $6}'` + if [ $? -eq 2 ] + then + fatal "User $user not found in /etc/passwd" + fi + fi + + debug "User home set to: $userhome" + [ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf" + defaultsfile="--defaults-file=$vuserhome/.my.cnf" + debug "using $defaultsfile" +fi + ####################################################################### ## HOT COPY @@ -239,13 +240,13 @@ then databases=`echo 'show databases' | $VSERVER $vsname exec su $user -c "$MYSQL $defaultsfile" | grep -v Database` if [ $? -ne 0 ] then - fatal "Something unexpected happened, the defaults file may have gone missing or is corrupt" + fatal "Authentication problem, maybe user/password is wrong" fi else databases=`echo 'show databases' | su $user -c "$MYSQL $defaultsfile" | grep -v Database` if [ $? -ne 0 ] then - fatal "Something unexpected happened, the defaults file may have gone missing or is corrupt" + fatal "Authentication problem, maybe user/password is wrong" fi fi fi |