#!/bin/bash

set -e

cat <<EOF > /etc/alertmanager-irc-relay.yml
http_host: localhost
http_port: 8000

irc_host: localhost
irc_port: 6667
irc_use_ssl: no
EOF

service alertmanager-irc-relay restart

for i in $(seq 1 5); do
  if curl -s http://localhost:8000; then
    exit 0
  fi
  sleep 1
done

exit 1
