blob: 14f104b986de318f1f78a9376fa2059b5796d178 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#!/bin/bash
#Usage: generate-gfid-file.sh <master-volfile-server:master-volume> <path-to-get-gfid.sh> <output-file> [dirs-list-file]
function get_gfids()
{
GET_GFID_CMD=$1
OUTPUT_FILE=$2
DIR_PATH=$3
find "$DIR_PATH" -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;
rm -f $OUTPUT;
touch $OUTPUT;
if [ "$DIRS_FILE" = "." ]
then
get_gfids $GFID_CMD $OUTPUT "."
else
while read line
do
get_gfids $GFID_CMD $OUTPUT "$line"
done < $DIRS_FILE
fi;
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/'`
if [ "$#" -lt 4 ]
then
DIRS_FILE="."
else
DIRS_FILE=$4
fi
mount_client $VOLFILE_SERVER $VOLUME_NAME $GET_GFID_CMD $OUTPUT $DIRS_FILE
}
main "$@";
|