summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorAravinda VK <avishwan@redhat.com>2015-02-18 19:07:23 +0530
committerVijay Bellur <vbellur@redhat.com>2015-03-18 02:54:25 -0700
commit7e98a0e0b1e346f89047b57e495f66f1b4223997 (patch)
tree0524dda8ad7066acab8d50537fe4f6e08f19fd29 /extras
parentc9b1aea9b3f7087336c75548b59574f251813136 (diff)
feature/glusterfind: A tool to find incremental changes
Documentation is available in patch: http://review.gluster.org/#/c/9800/ A tool which helps to get list of modified files or list of all files in GlusterFS Volume using Changelog or find command. Usage ===== glusterfind --help Create: ------- glusterfind create --help The tool creates status file $GLUSTERD_WORKDIR/SESSION/VOLUME/status and records current timestamp to initiate the session. This timestamp will be used as start time for next runs. As part of create also generates ssh key and distributes to all peers. and enables build.pgfid and changelog using volume set command. Pre: ---- glusterfind pre --help This command is used to generate the list of files modified after session creation time or after last run. To get list of all files/dirs in Volume, run pre command with `--full` argument. The tool gets all nodes details using gluster volume info and runs node agent for each brick in respective nodes via ssh command. Once these node agents generate the output file, tool copies to local using scp. Merges all the output files to generate the final output file. Post: ----- glusterfind post --help After consuming the list, this sub command is called to update the session time based on pre command status file. List: ----- glusterfind list --help To view all the sessions Delete: ------- glusterfind delete --help Delete session. Known Issues ------------ 1. Deleted files will not get listed, since we can't convert GFID to Path if file/dir is deleted. 2. Only new name will get listed if Renamed. 3. All hardlinks will get listed. Change-Id: I82991feb0aea85cb6ec035fddbf80a2b276e86b0 BUG: 1193893 Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on: http://review.gluster.org/9682 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Venky Shankar <vshankar@redhat.com> Reviewed-by: Prashanth Pai <ppai@redhat.com> Reviewed-by: Kotresh HR <khiremat@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'extras')
-rw-r--r--extras/Makefile.am3
-rwxr-xr-xextras/hook-scripts/S56glusterd-geo-rep-create-post.sh2
-rw-r--r--extras/peer_add_secret_pub.in63
3 files changed, 67 insertions, 1 deletions
diff --git a/extras/Makefile.am b/extras/Makefile.am
index e2b29f2da45..89f69440423 100644
--- a/extras/Makefile.am
+++ b/extras/Makefile.am
@@ -1,3 +1,6 @@
+gsyncddir = $(libexecdir)/glusterfs
+gsyncd_SCRIPTS = peer_add_secret_pub
+
EditorModedir = $(docdir)
EditorMode_DATA = glusterfs-mode.el glusterfs.vim
diff --git a/extras/hook-scripts/S56glusterd-geo-rep-create-post.sh b/extras/hook-scripts/S56glusterd-geo-rep-create-post.sh
index 8d3734e8097..067dd7427da 100755
--- a/extras/hook-scripts/S56glusterd-geo-rep-create-post.sh
+++ b/extras/hook-scripts/S56glusterd-geo-rep-create-post.sh
@@ -75,6 +75,6 @@ if [ -f $pub_file ]; then
scp $pub_file $slave_ip:$pub_file_tmp
ssh $slave_ip "mv $pub_file_tmp ${pub_file_dname}/${mastervol}_${slavevol}_${pub_file_bname}"
ssh $slave_ip "gluster system:: copy file /geo-replication/${mastervol}_${slavevol}_common_secret.pem.pub > /dev/null"
- ssh $slave_ip "gluster system:: execute add_secret_pub root $mastervol $slavevol > /dev/null"
+ ssh $slave_ip "gluster system:: execute add_secret_pub root geo-replication/${mastervol}_${slavevol}_common_secret.pem.pub > /dev/null"
fi
fi
diff --git a/extras/peer_add_secret_pub.in b/extras/peer_add_secret_pub.in
new file mode 100644
index 00000000000..e3a9aa2a48b
--- /dev/null
+++ b/extras/peer_add_secret_pub.in
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+user=$1
+pub_file=$2
+
+if [ "$user" == "" ]; then
+ echo "Invalid User";
+ exit 1;
+fi
+
+if [ "$pub_file" == "" ]; then
+ echo "Invalid pub file";
+ exit 1;
+fi
+
+home_dir=`getent passwd $user | cut -d ':' -f 6`;
+
+if [ "$home_dir" == "" ]; then
+ echo "Invalid home dir";
+ exit 1;
+fi
+
+authorized_keys_file=$(cat /etc/ssh/sshd_config | \
+ grep -e "^AuthorizedKeysFile" | \
+ awk '{print $2}' | tail -1);
+
+# If not set, use default location
+if [ "x$authorized_keys_file" == "x" ]; then
+ authorized_keys_file="%h/.ssh/authorized_keys"
+fi
+
+# If default location
+if [ "$authorized_keys_file" == ".ssh/authorized_keys" ]; then
+ authorized_keys_file="%h/$authorized_keys_file"
+fi
+
+# Replace %u with user name (ex: /etc/ssh/keys/%u/authorized_keys)
+authorized_keys_file="${authorized_keys_file//%u/$user}";
+
+# Replace %h with home dir (ex: %h/.ssh/authorized_keys)
+authorized_keys_file="${authorized_keys_file//%h/$home_dir}";
+ssh_dir=$(dirname $authorized_keys_file);
+
+if [ ! -d $ssh_dir ]; then
+ mkdir $ssh_dir;
+ chmod 700 $ssh_dir;
+ chown $user: $ssh_dir;
+fi
+
+if [ ! -d $authorized_keys_file ]; then
+ touch $authorized_keys_file;
+ chmod 600 $authorized_keys_file;
+ chown $user: $authorized_keys_file;
+fi
+
+# Add to authorized_keys file only if not exists already
+while read line
+do
+ grep -Fxq "$line" $authorized_keys_file;
+ [ $? -ne 0 ] && echo "$line" >> $authorized_keys_file;
+done < "$GLUSTERD_WORKDIR"/$pub_file;
+
+exit 0;