#!/bin/bash -ex

set +e
echo "$1" | grep '^yandex-du-releaser='
if [ "$?" -eq "0" ]
then
    set +x
    echo 'This command would not restart the server, use tabula-update <version> instead.'
    echo 'For example:'
    echo 'tabula-update 1.1234-1'
    exit 1
fi
set -e

for h in `curl -sL https://c.yandex-team.ru/api/groups2hosts/direct_tabula|grep -E '^[a-z0-9.-]+\.yandex\.(ru|net)$'`; do
    ssh "$h" sudo /usr/local/bin/ts-update.pl --conf /etc/ts-updater/tabula.conf $@
done

