glusterfs/extras/geo-rep/generate-gfid-file.sh
Emmanuel Dreyfus 33be39b42f Regression test portability: mktemp
Linux mktemp accepts to run without a template, NetBSD mandates it. Since
the template option has the same syntax, add it everywhere. While there,
also do this in scripts outside of regression testing.

BUG: 764655
Change-Id: I3ec140afbc9009257c81a56d77afcc21fef74cc4
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8432
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Tested-by: Harshavardhana <harsha@harshavardhana.net>
2014-08-20 13:46:44 -07:00

54 lines
1017 B
Bash

#!/bin/bash
#Usage: generate-gfid-file.sh <master-volfile-server:master-volume> <path-to-get-gfid.sh> <output-file>
function get_gfids()
{
GET_GFID_CMD=$1
OUTPUT_FILE=$2
find . -exec $GET_GFID_CMD {} \; > $OUTPUT_FILE
}
function mount_client()
{
local T; # temporary mount
local i; # inode number
VOLFILE_SERVER=$1;
VOLUME=$2;
GFID_CMD=$3;
OUTPUT=$4;
T=$(mktemp -d -t ${0##*/}.XXXXXX);
glusterfs -s $VOLFILE_SERVER --volfile-id $VOLUME $T;
i=$(stat -c '%i' $T);
[ "x$i" = "x1" ] || fatal "could not mount volume $MASTER on $T";
cd $T;
get_gfids $GFID_CMD $OUTPUT
cd -;
umount $T || fatal "could not umount $MASTER from $T";
rmdir $T || warn "rmdir of $T failed";
}
function main()
{
SLAVE=$1
GET_GFID_CMD=$2
OUTPUT=$3
VOLFILE_SERVER=`echo $SLAVE | sed -e 's/\(.*\):.*/\1/'`
VOLUME_NAME=`echo $SLAVE | sed -e 's/.*:\(.*\)/\1/'`
mount_client $VOLFILE_SERVER $VOLUME_NAME $GET_GFID_CMD $OUTPUT
}
main "$@";