summaryrefslogtreecommitdiffstats
path: root/extras/clear_xattrs.sh
blob: bdce5b895a3313c4491a3b6cbeae410c9c940e15 (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
#!/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 "Please specify the brick path(s)";
        exit 1;
    fi

    which getfattr > /dev/null 2>&1;
    if [ $? -ne 0 ]; then
        echo "attr package missing";
        exit 1;
    fi

    which setfattr > /dev/null 2>&1;
    if [ $? -ne 0 ]; then
        echo "attr package missing";
        exit 1;
    fi

    for brick in "$@";
    do
        echo "xattr clean-up in progress: $brick";
        remove_xattrs "$brick";
        echo "$brick ready to be used as a glusterfs brick";
    done;
}

main "$@";