#!/bin/bash -e
host=$(hostname -f)
cluster=$(cat /etc/direct/binlog-to-yt-sync/cluster.name)
shards=$(cat /etc/direct/binlog-to-yt-sync/db.names 2>/dev/null || echo "all")

# >> 1 - потому что в java знаковый int, а в mysql 4 byte unsigned
echo "$host $cluster $shards" | perl -pe 's/\n//g' | md5sum | cut -c1-8 | perl -le 'print hex(<>) >> 1'
