mysql,pgsql,svn,sys: fixed failing "is vserver running" test
[matthijs/upstream/backupninja.git] / handlers / mysql
index 57b9ecfe52b2fb695279f8816ed4c77c83d5c080..8d59fa4b0cd1cb897b8199605930a604058adf6b 100644 (file)
@@ -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
 
@@ -57,7 +57,7 @@ then
        [ -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."
+       [ "$running" = "1" ] || fatal "vserver $vsname is not running."
 fi
        
 # create backup dirs, the vroot variable will be empty if no vsname was specified
@@ -95,7 +95,7 @@ fi
 
 defaultsfile=""
 if [ "$dbusername" != "" -a "$dbpassword" != "" ]; then
-       home=`grep '^root:' /etc/passwd | awk -F: '{print $6}'`
+       home=`getent passwd "root" | awk -F: '{print $6}'`
        [ -d $home ] || fatal "Can't find root's home directory ($home)."
        mycnf="$home/.my.cnf"
        if [ -f $mycnf ]; then