]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_common.sh: check if $sshdir exist, otherwise create it
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Thu, 14 Feb 2013 12:47:02 +0000 (13:47 +0100)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Thu, 14 Feb 2013 17:12:30 +0000 (18:12 +0100)
Check if $sshdir exist. If not, create it before cd to the
directory.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/ceph_common.sh

index 5e77a175c928b20cc3aebc3c77a391ab5d5c772a..fd3f72f381fc6dfb2c9cad9a73b159acc1306a60 100644 (file)
@@ -89,8 +89,8 @@ do_cmd() {
            sudo su $user -c "$1" || { [ -z "$3" ] && echo "failed: '$1'" && exit 1; }
        fi
     else
-       [ $verbose -eq 1 ] && echo "--- $ssh $2 \"cd $sshdir ; ulimit -c unlimited ; $1\""
-       $ssh $2 "cd $sshdir ; ulimit -c unlimited ; $1" || { [ -z "$3" ] && echo "failed: '$ssh $1'" && exit 1; }
+       [ $verbose -eq 1 ] && echo "--- $ssh $2 \"if [ ! -d $sshdir ]; then mkdir -p $sshdir; fi; cd $sshdir ; ulimit -c unlimited ; $1\""
+       $ssh $2 "if [ ! -d $sshdir ]; then mkdir -p $sshdir; fi; cd $sshdir ; ulimit -c unlimited ; $1" || { [ -z "$3" ] && echo "failed: '$ssh $1'" && exit 1; }
     fi
 }
 
@@ -105,8 +105,8 @@ do_root_cmd() {
            sudo bash -c "$1" || { echo "failed: '$1'" ; exit 1; }
        fi
     else
-       [ $verbose -eq 1 ] && echo "--- $rootssh $2 \"cd $sshdir ; ulimit -c unlimited ; $1\""
-       $rootssh $2 "cd $sshdir ; ulimit -c unlimited ; $1" || { echo "failed: '$rootssh $1'" ; exit 1; }
+       [ $verbose -eq 1 ] && echo "--- $rootssh $2 \"if [ ! -d $sshdir ]; then mkdir -p $sshdir; fi ; cd $sshdir ; ulimit -c unlimited ; $1\""
+       $rootssh $2 "if [ ! -d $sshdir ]; then mkdir -p $sshdir; fi ; cd $sshdir; ulimit -c unlimited ; $1" || { echo "failed: '$rootssh $1'" ; exit 1; }
     fi
 }