diff options
Diffstat (limited to 'geo-replication/src/peer_add_secret_pub.in')
-rw-r--r-- | geo-replication/src/peer_add_secret_pub.in | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/geo-replication/src/peer_add_secret_pub.in b/geo-replication/src/peer_add_secret_pub.in index c036cf33416..04dee1b1ea1 100644 --- a/geo-replication/src/peer_add_secret_pub.in +++ b/geo-replication/src/peer_add_secret_pub.in @@ -1,9 +1,20 @@ #!/bin/bash -if [ ! -d ~/.ssh ]; then - mkdir ~/.ssh; - chmod 700 ~/.ssh - chown root:root ~/.ssh +if [ "$1" == "" ]; then + home_dir=`echo $HOME` +else + home_dir=`getent passwd | grep $1 | cut -d ':' -f 6`; fi -cat "$GLUSTERD_WORKING_DIR"/geo-replication/common_secret.pem.pub >> ~/.ssh/authorized_keys +if [ "$home_dir" == "" ]; then + echo "Invalid User"; + exit 1; +fi + +if [ ! -d $home_dir/.ssh ]; then + mkdir $home_dir/.ssh; + chmod 700 $home_dir/.ssh; + chown root:root $home_dir/.ssh; +fi + +cat "$GLUSTERD_WORKING_DIR"/geo-replication/common_secret.pem.pub >> $home_dir/.ssh/authorized_keys; |