X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=handlers%2Fmysql;h=7ca9ab64ecbc2dc6a17839ecad79e5cfa21a5279;hb=0d606253af6ecb8ede07b0991a1f295fb70e7e65;hp=cb7010435a3dbfd98a7e0eaf834a0b297e5e1207;hpb=603c015425c36977b13a73fec79c9fa9e857e358;p=matthijs%2Fupstream%2Fbackupninja.git diff --git a/handlers/mysql b/handlers/mysql index cb70104..7ca9ab6 100644 --- a/handlers/mysql +++ b/handlers/mysql @@ -1,3 +1,4 @@ +# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- # # mysql handler script for backupninja # @@ -47,32 +48,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 @@ -115,19 +90,21 @@ fi # specify the password on the command line. defaultsfile="" + if [ "$dbusername" != "" -a "$dbpassword" != "" ] then if [ $usevserver ] then - home=`$VSERVER $vsname exec getent passwd "root" | awk -F: '{print $6}'` - home="$vroot$home" - debug "Home set to: $home" + vhome=`$VSERVER $vsname exec getent passwd "root" | awk -F: '{print $6}'` + home="$vroot$vhome" else home=`getent passwd "root" | awk -F: '{print $6}'` - debug "Home set to: $home" fi + [ -d $home ] || fatal "Can't find root's home directory ($home)." + mycnf="$home/.my.cnf" + if [ -f $mycnf ] then # rename temporarily @@ -135,27 +112,64 @@ then debug "mv $mycnf $tmpcnf" mv $mycnf $tmpcnf fi + oldmask=`umask` umask 077 cat > $mycnf <