- defaultsfile="--defaults-file=$mycnf"
-elif [ "$userset" == "false" ]; then
- # if user is set, don't use $configfile
- defaultsfile="--defaults-file=$configfile"
+ if [ $usevserver = yes ]
+ then
+ defaultsfile="--defaults-extra-file=$vhome/.my.cnf"
+ else
+ defaultsfile="--defaults-extra-file=$mycnf"
+ fi
+fi
+
+# if a user is not set, use $configfile, otherwise use $mycnf
+if [ "$user" == "" ]; then
+ user=root;
+ defaultsfile="--defaults-extra-file=$configfile"
+else
+ userset=true;
+ if [ $usevserver = yes ]
+ 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-extra-file=$userhome/.my.cnf"
+ debug "using $defaultsfile"