glusterfs/extras/clear_xattrs.sh
Rajesh Amaravathi 5303f98f67 extras: add check for brick path existence
Adding a couple of checks to validate brick path(s)

Change-Id: I2d8538add21407d9457542373b528c2a02cd7eb6
BUG: 765572
Signed-off-by: Rajesh Amaravathi <rajesh@redhat.com>
Reviewed-on: http://review.gluster.com/2514
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
2012-01-05 09:18:11 -08:00

53 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# Clear the trusted.gfid xattr in the brick tree
# This script must be run only on a stopped brick/volume
# Stop the volume to make sure no rebalance/replace-brick
# operations are on-going
# Not much error checking
remove_xattrs ()
{
find "$1" -exec setfattr -h -x "trusted.gfid" '{}' \; > /dev/null 2>&1;
find "$1" -exec setfattr -h -x "trusted.glusterfs.volume-id" '{}' \; > /dev/null 2>&1;
}
main ()
{
if [ -z "$1" ]; then
echo "Usage: $0 <brick_path(s)>";
exit 1;
fi
export PATH;
which getfattr > /dev/null 2>&1;
if [ $? -ne 0 ]; then
echo "attr package missing";
exit 2;
fi
which setfattr > /dev/null 2>&1;
if [ $? -ne 0 ]; then
echo "attr package missing";
exit 2;
fi
for brick in "$@";
do
stat "$brick" > /dev/null 2>&1;
if [ $? -ne 0 ]; then
echo "brick: $brick does not exist";
exit 3;
fi
if [ ! -d "$brick" ]; then
echo "$brick: not a directory";
exit 4;
fi
echo "xattr clean-up in progress: $brick";
remove_xattrs "$brick";
echo "$brick ready to be used as a glusterfs brick";
done;
}
main "$@";