summaryrefslogtreecommitdiffstats
path: root/geo-replication/src
diff options
context:
space:
mode:
Diffstat (limited to 'geo-replication/src')
-rw-r--r--geo-replication/src/Makefile.am4
-rwxr-xr-xgeo-replication/src/gverify.sh69
-rw-r--r--geo-replication/src/peer_add_secret_pub.in21
-rwxr-xr-xgeo-replication/src/set_geo_rep_pem_keys.sh41
4 files changed, 96 insertions, 39 deletions
diff --git a/geo-replication/src/Makefile.am b/geo-replication/src/Makefile.am
index 324d8869f8b..20b5b6bde6b 100644
--- a/geo-replication/src/Makefile.am
+++ b/geo-replication/src/Makefile.am
@@ -1,11 +1,11 @@
gsyncddir = $(libexecdir)/glusterfs
-gsyncd_SCRIPTS = gverify.sh peer_add_secret_pub peer_gsec_create
+gsyncd_SCRIPTS = gverify.sh peer_add_secret_pub peer_gsec_create set_geo_rep_pem_keys.sh
# peer_gsec_create and peer_add_secret_pub are not added to
# EXTRA_DIST as it's derived from a .in file
-EXTRA_DIST = gverify.sh
+EXTRA_DIST = gverify.sh set_geo_rep_pem_keys.sh
gsyncd_PROGRAMS = gsyncd
diff --git a/geo-replication/src/gverify.sh b/geo-replication/src/gverify.sh
index e9c9b28837d..c986f78a7ea 100755
--- a/geo-replication/src/gverify.sh
+++ b/geo-replication/src/gverify.sh
@@ -49,29 +49,13 @@ echo $cmd_line;
function cmd_slave()
{
- VOL=$1;
local cmd_line;
cmd_line=$(cat <<EOF
function do_verify() {
-v=\$1;
-d=\$(mktemp -d 2>/dev/null);
-glusterfs -s localhost --xlator-option="*dht.lookup-unhashed=off" --volfile-id \$v -l $slave_log_file \$d;
-i=\$(stat -c "%i" \$d);
-if [[ "\$i" -ne "1" ]]; then
-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}");
-no_of_files=\$(find \$d -maxdepth 0 -empty);
-umount -l \$d;
-rmdir \$d;
ver=\$(gluster --version | head -1 | cut -f2 -d " ");
-echo \$disk_size:\$used_size:\$ver:\$no_of_files;
+echo \$ver;
};
-cd /tmp;
-[ x$VOL != x ] && do_verify $VOL;
+source /etc/profile && do_verify;
EOF
);
@@ -89,37 +73,58 @@ function master_stats()
function slave_stats()
{
- SLAVEHOST=$1;
- SLAVEVOL=$2;
+ SLAVEUSER=$1;
+ SLAVEHOST=$2;
+ SLAVEVOL=$3;
local cmd_line;
- cmd_line=$(cmd_slave $SLAVEVOL);
- SSHM $SLAVEHOST bash -c "'$cmd_line'";
+ local ver;
+ local status;
+
+ d=$(mktemp -d 2>/dev/null);
+ glusterfs --xlator-option="*dht.lookup-unhashed=off" --volfile-server $SLAVEHOST --volfile-id $SLAVEVOL -l $slave_log_file \$d;
+ mount -t glusterfs $SLAVEHOST:$SLAVEVOL $d
+ i=$(stat -c "%i" $d);
+ if [[ "$i" -ne "1" ]]; then
+ 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}");
+ no_of_files=$(find $d -maxdepth 0 -empty);
+ umount -l $d;
+ rmdir $d;
+
+ cmd_line=$(cmd_slave);
+ ver=`SSHM $SLAVEUSER@$SLAVEHOST bash -c "'$cmd_line'"`;
+ status=$disk_size:$used_size:$ver:$no_of_files;
+ echo $status
}
function main()
{
- log_file=$4
+ log_file=$5
> $log_file
# Use FORCE_BLOCKER flag in the error message to differentiate
# between the errors which the force command should bypass
- ping -w 5 $2;
+ ping -w 5 $3;
if [ $? -ne 0 ]; then
- echo "FORCE_BLOCKER|$2 not reachable." > $log_file
+ echo "FORCE_BLOCKER|$3 not reachable." > $log_file
exit 1;
fi;
- ssh -oNumberOfPasswordPrompts=0 $2 "echo Testing_Passwordless_SSH";
+ ssh -oNumberOfPasswordPrompts=0 $2@$3 "echo Testing_Passwordless_SSH";
if [ $? -ne 0 ]; then
- echo "FORCE_BLOCKER|Passwordless ssh login has not been setup with $2." > $log_file
+ echo "FORCE_BLOCKER|Passwordless ssh login has not been setup with $3 for user $2." > $log_file
exit 1;
fi;
ERRORS=0;
master_data=$(master_stats $1);
- slave_data=$(slave_stats $2 $3);
+ slave_data=$(slave_stats $2 $3 $4);
master_disk_size=$(echo $master_data | cut -f1 -d':');
slave_disk_size=$(echo $slave_data | cut -f1 -d':');
master_used_size=$(echo $master_data | cut -f2 -d':');
@@ -129,7 +134,7 @@ function main()
slave_no_of_files=$(echo $slave_data | cut -f4 -d':');
if [[ "x$master_disk_size" = "x" || "x$master_version" = "x" || "$master_disk_size" -eq "0" ]]; then
- echo "FORCE_BLOCKER|Unable to fetch master volume details. Please check the master cluster and master volume." > $log_file;
+ echo "FORCE_BLOCKER|Unable to fetch master volume details. Please check the master cluster and master volume." > $log_file;
exit 1;
fi;
@@ -157,13 +162,13 @@ function main()
fi
if [ -z $slave_no_of_files ]; then
- echo "$2::$3 is not empty. Please delete existing files in $2::$3 and retry, or use force to continue without deleting the existing files." >> $log_file;
+ echo "$3::$4 is not empty. Please delete existing files in $3::$4 and retry, or use force to continue without deleting the existing files." >> $log_file;
ERRORS=$(($ERRORS + 1));
fi;
if [[ $master_version > $slave_version ]]; then
- echo "Gluster version mismatch between master and slave." >> $log_file;
- ERRORS=$(($ERRORS + 1));
+ echo "Gluster version mismatch between master and slave." >> $log_file;
+ ERRORS=$(($ERRORS + 1));
fi;
exit $ERRORS;
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;
diff --git a/geo-replication/src/set_geo_rep_pem_keys.sh b/geo-replication/src/set_geo_rep_pem_keys.sh
new file mode 100755
index 00000000000..16c55ed0a49
--- /dev/null
+++ b/geo-replication/src/set_geo_rep_pem_keys.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+# Script to copy the pem keys from the user's home directory
+# to $GLUSTERD_WORKING_DIR/geo-replication/ and then copy
+# the keys to other nodes in the cluster and add them to the
+# respective authorized keys. The script takes as argument the
+# user name and assumes that the user will be present in all
+# the nodes in the cluster. Not to be used for root user
+
+function main()
+{
+ user=$1
+ if [ "$user" == "" ]; then
+ echo "Please enter the user's name"
+ exit 1;
+ fi
+
+ if [ "$user" == "root" ]; then
+ echo "This script is not needed for root"
+ exit 1;
+ fi
+
+ home_dir=`getent passwd | grep $user | cut -d ':' -f 6`;
+
+ if [ "$home_dir" == "" ]; then
+ echo "No user $user found"
+ exit 1;
+ fi
+
+ if [ -f $home_dir/common_secret.pem.pub ]; then
+ cp $home_dir/common_secret.pem.pub /var/lib/glusterd/geo-replication/
+ gluster system:: copy file /geo-replication/common_secret.pem.pub
+ gluster system:: execute add_secret_pub $user
+ else
+ echo "$home_dir/common_secret.pem.pub not present. Please run geo-replication command on master with push-pem option to generate the file"
+ exit 1;
+ fi
+ exit 0;
+}
+
+main "$@";