X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=handlers%2Fmysql;h=965b05e9eb00b679f358865b1a5f294654ac5aed;hb=036db2ee35b7d9afa4d3a06bd2c80382b7d1443b;hp=57b9ecfe52b2fb695279f8816ed4c77c83d5c080;hpb=07b7055d3ae14fa8caeef26d3a7b43686b3eef4e;p=matthijs%2Fupstream%2Fbackupninja-vserver.git diff --git a/handlers/mysql b/handlers/mysql index 57b9ecf..965b05e 100644 --- a/handlers/mysql +++ b/handlers/mysql @@ -22,7 +22,7 @@ if [ "$user" == "" ]; then user=root; else userset=true; - userhome=`grep "^$user:" /etc/passwd | awk -F: '{print $6}'` + userhome=`getent passwd "$user" | awk -F: '{print $6}'` [ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf" fi @@ -51,16 +51,19 @@ fi # If needed, make sure that the specified vserver exists and is running. if [ $usevserver ] then - info "examining vserver '$vsname'" + info "Examining vserver '$vsname'" # does it exist ? vroot="$VROOTDIR/$vsname" [ -d $vroot ] || fatal "vserver '$vsname' does not exist at '$vroot'" # is it running ? - running=`$VSERVERINFO $vsname RUNNING` - [ $running = 1 ] || fatal "vserver $vsname is not running." + $VSERVERINFO -q $vsname RUNNING + if [ $? -ne 0 ] + then + fatal "vserver $vsname is not running." + fi fi -# create backup dirs, the vroot variable will be empty if no vsname was specified +# create backup dirs, vroot variable will be empty if no vsname was specified # and will proceed to operate on the host [ -d $vroot$backupdir ] || mkdir -p $vroot$backupdir [ -d $vroot$backupdir ] || fatal "Backup directory '$vroot$backupdir'" @@ -94,19 +97,25 @@ fi # specify the password on the command line. defaultsfile="" -if [ "$dbusername" != "" -a "$dbpassword" != "" ]; then - home=`grep '^root:' /etc/passwd | awk -F: '{print $6}'` - [ -d $home ] || fatal "Can't find root's home directory ($home)." - mycnf="$home/.my.cnf" - if [ -f $mycnf ]; then - # rename temporarily - tmpcnf="$home/my.cnf.disable" - debug "mv $mycnf $tmpcnf" - mv $mycnf $tmpcnf - fi - oldmask=`umask` - umask 077 - cat > $mycnf < $mycnf <