summaryrefslogtreecommitdiffstats
path: root/geo-replication/src/peer_add_secret_pub.in
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2014-05-20 14:50:25 +0000
committerVenky Shankar <vshankar@redhat.com>2014-05-25 19:49:31 -0700
commit5224a785faaa615adac7cd25207912ab109ad7e6 (patch)
treeced2910f66ce52d0e99bfdd545bfdebf70c7c285 /geo-replication/src/peer_add_secret_pub.in
parent9dce23c30edb3622049d40ea16877c7b26e5753b (diff)
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 <asengupt@redhat.com> Reviewed-on: http://review.gluster.org/7812 Reviewed-by: Kotresh HR <khiremat@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Venky Shankar <vshankar@redhat.com> Tested-by: Venky Shankar <vshankar@redhat.com> Reviewed-by: Aravinda VK <avishwan@redhat.com>
Diffstat (limited to 'geo-replication/src/peer_add_secret_pub.in')
-rw-r--r--geo-replication/src/peer_add_secret_pub.in17
1 files changed, 15 insertions, 2 deletions
diff --git a/geo-replication/src/peer_add_secret_pub.in b/geo-replication/src/peer_add_secret_pub.in
index aed93991e58..8bfecce9b09 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;