#!/bin/bash -e
host=$(hostname -f)
cluster=$(cat /etc/direct/binlog-to-yt-sync/cluster.name)
shard=$(cat /etc/direct/binlog-to-yt-sync/db.name 2>/dev/null || echo "all")
#echo "$host $cluster $shard" | perl -pe 's/\n//g'

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