#!/usr/bin/env bash
# This is media plugin for selfdns-client.
# Works only on virtual machines and only if host have RA conductor tag
# It takes all ip addresses in global scope from ip utility
# And posts them as A/AAAA addresses for current host (PTR will added on api call)

# Load variables and helper functions
. /usr/lib/yandex-media-common-selfdns-plugin/helpers

# Get active interface ips from global scope
IP_ADDRESSES=$(ip -o addr show $default_route_iface scope global | sed -r 's|.*inet6?\s+(.*)/[0-9]{2}\s+.*|\1|g')

# common sanity checks
check_virtual

# RA tag
check_conductor_tag "RA"

# Fire the answer!
answer "${IP_ADDRESSES}"
