This file is indexed.

/usr/share/glusterfs/scripts/gsync-upgrade.sh is in glusterfs-common 3.8.8-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash
#usage: gsync-upgrade.sh <slave-volfile-server:slave-volume> <gfid-file>
#                        <path-to-gsync-sync-gfid> <ssh-identity-file>
#<slave-volfile-server>: a machine on which gluster cli can fetch slave volume info.
#                        slave-volfile-server defaults to localhost.
#
#<gfid-file>: a file containing paths and their associated gfids
#            on master. The paths are relative to master mount point
#            (not absolute). An example extract of <gfid-file> can be,
#
#            <extract>
#            22114455-57c5-46e9-a783-c40f83a72b09 /dir
#            25772386-3eb8-4550-a802-c3fdc938ca80 /dir/file
#            </extract>
#
#<ssh-identity-file>: file from which the identity (private key) for public key authentication is read.

SLAVE_MOUNT='/tmp/glfs_slave'

function SSH()
{
    HOST=$1
    SSHKEY=$2

    shift 2

    ssh -qi $SSHKEY \
        -oPasswordAuthentication=no \
        -oStrictHostKeyChecking=no \
        "$HOST" "$@";
}

function get_bricks()
{
    SSHKEY=$3

    SSH $1 $SSHKEY "gluster volume info $2" | grep -E 'Brick[0-9]+' | sed -e 's/[^:]*:\(.*\)/\1/g'
}

function cleanup_brick()
{
    HOST=$1
    BRICK=$2
    SSHKEY=$3

    # TODO: write a C program to receive a list of files and does cleanup on
    # them instead of spawning a new setfattr process for each file if
    # performance is bad.
    SSH -i $SSHKEY $HOST  "rm -rf $BRICK/.glusterfs/* && find $BRICK -exec setfattr -x trusted.gfid {} \;"
}

function cleanup_slave()
{
    SSHKEY=$2

    VOLFILE_SERVER=`echo $1 | sed -e 's/\(.*\):.*/\1/'`
    VOLUME_NAME=`echo $1 | sed -e 's/.*:\(.*\)/\1/'`

    BRICKS=`get_bricks $VOLFILE_SERVER $VOLUME_NAME $SSHKEY`

    for i in $BRICKS; do
	HOST=`echo $i | sed -e 's/\(.*\):.*/\1/'`
	BRICK=`echo $i | sed -e 's/.*:\(.*\)/\1/'`
	cleanup_brick $HOST $BRICK $SSHKEY
    done

    SSH -i $SSHKEY $VOLFILE_SERVER "gluster --mode=script volume stop $VOLUME_NAME; gluster volume start $VOLUME_NAME";

}

function mount_client()
{
    local T; # temporary mount
    local i; # inode number
    GFID_FILE=$3
    SYNC_CMD=$4

    T=$(mktemp -d -t ${0##*/}.XXXXXX);

    glusterfs --aux-gfid-mount -s $1 --volfile-id $2 $T;

    i=$(stat -c '%i' $T);

    [ "x$i" = "x1" ] || fatal "could not mount volume $MASTER on $T";

    cd $T;

    $SYNC_CMD $GFID_FILE

    cd -;

    umount -l $T || fatal "could not umount $MASTER from $T";

    rmdir $T || warn "rmdir of $T failed";
}

function sync_gfids()
{
    SLAVE=$1
    GFID_FILE=$2

    SLAVE_VOLFILE_SERVER=`echo $SLAVE | sed -e 's/\(.*\):.*/\1/'`
    SLAVE_VOLUME_NAME=`echo $SLAVE | sed -e 's/.*:\(.*\)/\1/'`

    if [ "x$SLAVE_VOLFILE_SERVER" = "x" ]; then
        SLAVE_VOLFILE_SERVER="localhost"
    fi

    mount_client $SLAVE_VOLFILE_SERVER $SLAVE_VOLUME_NAME $GFID_FILE $3
}

function upgrade()
{
    SLAVE=$1
    GFID_FILE=$2
    SYNC_CMD=$3
    SSHKEY=$4

    cleanup_slave $SLAVE $SSHKEY
    sync_gfids $SLAVE $GFID_FILE $SYNC_CMD
}

upgrade "$@"