diff mbox

mkcephfs: Don't transfer absolute path of mkcephfs to other hosts.

Message ID 201311060925048528111@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

majianpeng Nov. 6, 2013, 1:25 a.m. UTC
When exec 'mkcephfs -a -c ceph.conf',it will transfer absolute path of
mkcephfs to other hosts.But for different hosts, the path of mkcephfs
may different.It will make the command error.The error message is
"bash: ./mkcephfs: No such file or directory".
So we should transfer the name mkcephfs to other hosts.It those hosts,it
will automaicly search by PATH.

Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>

---
 src/mkcephfs.in | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

-- 
1.8.4

Comments

yunchuanwen Nov. 6, 2013, 2:20 a.m. UTC | #1
Hi Jianpeng,
    I think this patch will work in the situation that 'mkcephfs' has
been added to the $PATH of other hosts, but what about that 'mkcephfs'
have been deployed to the same path in all cluster nodes, but NOT
added to $PATH, then the original version will work, but now it not
gotta work.
   So my suggestion is, first check if the path $0 is valid or not on
other hosts by using something like ' if [ -f $0 ]', if so, just go as
now it is. Otherwise, remove other name components of the path, and
try to use it.


2013/11/6 majianpeng <majianpeng@gmail.com>:
> When exec 'mkcephfs -a -c ceph.conf',it will transfer absolute path of
> mkcephfs to other hosts.But for different hosts, the path of mkcephfs
> may different.It will make the command error.The error message is
> "bash: ./mkcephfs: No such file or directory".
> So we should transfer the name mkcephfs to other hosts.It those hosts,it
> will automaicly search by PATH.
>
> Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>
> ---
>  src/mkcephfs.in | 19 ++++++++++++++++---
>  1 file changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/src/mkcephfs.in b/src/mkcephfs.in
> index 2838568..c5e41d9 100644
> --- a/src/mkcephfs.in
> +++ b/src/mkcephfs.in
> @@ -455,6 +455,7 @@ fi
>  ### do everything via ssh ###
>
>  if [ $allhosts -eq 1 ]; then
> +    localhost=$hostname
>
>      verify_conf
>
> @@ -498,10 +499,18 @@ if [ $allhosts -eq 1 ]; then
>         fi
>
>         if [ $mkfs -eq 1 ] && [ "$type" = "osd" ]; then
> -           do_root_cmd "$0 -d $rdir --prepare-osdfs $name"
> +               if [ $localhost = $host ]; then
> +                   do_root_cmd "$0 -d $rdir --prepare-osdfs $name"
> +               else
> +                   do_root_cmd "$(basename $0) -d $rdir --prepare-osdfs $name"
> +               fi
>         fi
>
> -       do_root_cmd "$0 -d $rdir --init-daemon $name"
> +       if [ $localhost = $host ]; then
> +           do_root_cmd "$0 -d $rdir --init-daemon $name"
> +       else
> +           do_root_cmd "$(basename $0) -d $rdir --init-daemon $name"
> +       fi
>
>         # collect the key
>         if [ -n "$ssh" ]; then
> @@ -544,7 +553,11 @@ if [ $allhosts -eq 1 ]; then
>             fi
>         fi
>
> -       do_root_cmd "$0 -d $rdir --init-daemon $name"
> +       if [ $localhost = $host ]; then
> +           do_root_cmd "$0 -d $rdir --init-daemon $name"
> +       else
> +           do_root_cmd "$(basename $0) -d $rdir --init-daemon $name"
> +       fi
>
>         if [ -n "$ssh" ]; then
>             #cleanup no longer need rdir
> --
> 1.8.4
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/src/mkcephfs.in b/src/mkcephfs.in
index 2838568..c5e41d9 100644
--- a/src/mkcephfs.in
+++ b/src/mkcephfs.in
@@ -455,6 +455,7 @@  fi
 ### do everything via ssh ###
 
 if [ $allhosts -eq 1 ]; then
+    localhost=$hostname
 
     verify_conf
 
@@ -498,10 +499,18 @@  if [ $allhosts -eq 1 ]; then
 	fi
 	
 	if [ $mkfs -eq 1 ] && [ "$type" = "osd" ]; then
-	    do_root_cmd "$0 -d $rdir --prepare-osdfs $name"
+		if [ $localhost = $host ]; then
+		    do_root_cmd "$0 -d $rdir --prepare-osdfs $name"
+		else
+		    do_root_cmd "$(basename $0) -d $rdir --prepare-osdfs $name"
+		fi
 	fi
 
-	do_root_cmd "$0 -d $rdir --init-daemon $name"
+	if [ $localhost = $host ]; then
+	    do_root_cmd "$0 -d $rdir --init-daemon $name"
+	else
+	    do_root_cmd "$(basename $0) -d $rdir --init-daemon $name"
+	fi
 
 	# collect the key
 	if [ -n "$ssh" ]; then
@@ -544,7 +553,11 @@  if [ $allhosts -eq 1 ]; then
 	    fi
 	fi
 	
-	do_root_cmd "$0 -d $rdir --init-daemon $name"
+	if [ $localhost = $host ]; then
+	    do_root_cmd "$0 -d $rdir --init-daemon $name"
+	else
+	    do_root_cmd "$(basename $0) -d $rdir --init-daemon $name"
+	fi
 
 	if [ -n "$ssh" ]; then
 	    #cleanup no longer need rdir