mkcephfs: Don't transfer absolute path of mkcephfs to other hosts.
PATCH 1/1 mkcephfs: Don't transfer absolute path of mkcephfs to other hosts.
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.
--- src/mkcephfs.in | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
src/mkcephfs.in +16 -3
@@ -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
Signature · 1 line
1.8.4
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 <[email protected]>:
Quoted 60 lines
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 <[email protected]>--- src/mkcephfs.in | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)src/mkcephfs.in +16
-4@@ -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