From 5224a785faaa615adac7cd25207912ab109ad7e6 Mon Sep 17 00:00:00 2001 From: Avra Sengupta Date: Tue, 20 May 2014 14:50:25 +0000 Subject: glusterd/geo-rep: Creating .ssh dir with right ownership Also adding -P option to the usage of df for portability in gverify.sh Change-Id: I0be19d26ea63769a934c6ccbfc04ef80768ebc9a BUG: 1099041 Signed-off-by: Avra Sengupta Reviewed-on: http://review.gluster.org/7812 Reviewed-by: Kotresh HR Tested-by: Gluster Build System Reviewed-by: Venky Shankar Tested-by: Venky Shankar Reviewed-by: Aravinda VK --- geo-replication/src/gverify.sh | 8 ++++---- geo-replication/src/peer_add_secret_pub.in | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 6 deletions(-) (limited to 'geo-replication') diff --git a/geo-replication/src/gverify.sh b/geo-replication/src/gverify.sh index c986f78a7e..32ba843cee 100755 --- a/geo-replication/src/gverify.sh +++ b/geo-replication/src/gverify.sh @@ -32,8 +32,8 @@ echo 0:0; exit 1; fi; cd \$d; -disk_size=\$(df -B1 \$d | tail -1 | awk "{print \\\$2}"); -used_size=\$(df -B1 \$d | tail -1 | awk "{print \\\$3}"); +disk_size=\$(df -P -B1 \$d | tail -1 | awk "{print \\\$2}"); +used_size=\$(df -P -B1 \$d | tail -1 | awk "{print \\\$3}"); umount -l \$d; rmdir \$d; ver=\$(gluster --version | head -1 | cut -f2 -d " "); @@ -89,8 +89,8 @@ function slave_stats() exit 1; fi; cd $d; - disk_size=$(df -B1 $d | tail -1 | awk "{print \$2}"); - used_size=$(df -B1 $d | tail -1 | awk "{print \$3}"); + disk_size=$(df -P -B1 $d | tail -1 | awk "{print \$2}"); + used_size=$(df -P -B1 $d | tail -1 | awk "{print \$3}"); no_of_files=$(find $d -maxdepth 0 -empty); umount -l $d; rmdir $d; diff --git a/geo-replication/src/peer_add_secret_pub.in b/geo-replication/src/peer_add_secret_pub.in index aed93991e5..8bfecce9b0 100644 --- a/geo-replication/src/peer_add_secret_pub.in +++ b/geo-replication/src/peer_add_secret_pub.in @@ -1,20 +1,33 @@ #!/bin/bash if [ "$1" == "" ]; then + user="root" home_dir=`getent passwd root | cut -d ':' -f 6`; else + user=$1 home_dir=`getent passwd $1 | cut -d ':' -f 6`; fi -if [ "$home_dir" == "" ]; then +if [ "$user" == "" ]; then echo "Invalid User"; exit 1; fi +if [ "$home_dir" == "" ]; then + echo "Invalid home dir"; + exit 1; +fi + if [ ! -d $home_dir/.ssh ]; then mkdir $home_dir/.ssh; chmod 700 $home_dir/.ssh; - chown root:root $home_dir/.ssh; + chown $user:$user $home_dir/.ssh; +fi + +if [ ! -d $home_dir/.ssh/authorized_keys ]; then + touch $home_dir/.ssh/authorized_keys; + chmod 600 $home_dir/.ssh/authorized_keys; + chown $user:$user $home_dir/.ssh/authorized_keys; fi cat "$GLUSTERD_WORKING_DIR"/geo-replication/common_secret.pem.pub >> $home_dir/.ssh/authorized_keys; -- cgit