forked from vbellur/gfid
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgfid-mv
executable file
·43 lines (35 loc) · 1.15 KB
/
gfid-mv
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
#!/bin/bash
# This script reads a list of files/directories which have mismatched
# gfid's and fixes them.
# For directories it creates a new directory and moves all the contents
# inside it and renames it.
# For files it copies them to a temporary name and renames it.
# Run this script with the current working directory being the GlusterFS
# mountpoint.
FILE=$1
TMPFILE=".gfid_tmp_file"
TMPDIR=".gfid_tmp_dir"
if [ "$#" -ne 1 ]; then
echo "usage: gfid-mv <mismatch file>"
exit 1
fi
while read line
do
if [ -h "$line" ]; then
# skip symbolic links
true
elif [ -f "$line" ]; then
rm -f "$TMPFILE"
rsync -aAX "$line" "$TMPFILE"
mv "$TMPFILE" "$line"
echo "$line: OK"
elif [ -d "$line" ]; then
rm -rf "$TMPDIR"
rsync -ptgodAX "$line" "$TMPDIR"
mv "$line"/* "$TMPDIR"
mv -T "$TMPDIR" "$line"
echo "$line: OK"
elif [ ! -e "$line" ]; then
echo "$line: ENOENT"
fi
done <"$FILE"