-# (we do this because we don't want to have to specify the password on the command line
-# because then anyone would be able to see it with a 'ps aux'. instead, we create a
-# temporary ~/.my.cnf in root's home directory).
-
-if [ "$dbusername" != "" ]; then
- home=`grep '^root:' $vroot/etc/passwd | awk -F: '{print $6}'`
- [ -d $home ] || fatal "Can't find root's home directory ($home)."
- mycnf="$vroot$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 <<EOF
+# only if dbusername and dbpassword specified.
+# we create a tmp file because we don't want to
+# specify the password on the command line.
+
+defaultsfile=""
+
+if [ "$dbusername" != "" -a "$dbpassword" != "" ]
+then
+ if [ $usevserver ]
+ then
+ vhome=`$VSERVER $vsname exec getent passwd "root" | awk -F: '{print $6}'`
+ home="$vroot$vhome"
+ else
+ home=`getent passwd "root" | awk -F: '{print $6}'`
+ fi
+
+ [ -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 <<EOF