#!/bin/bash

url="https://cdn.udinweb.com/haproxy/sync.txt"

if [ "$(curl -s "$url")" != "1" ] && [ $# -eq 0 ] ; then
    exit 1
fi

if [[ $(cat /etc/*-release | grep "Ubuntu") ]]; then
    systemctl stop haproxy
    cd /etc/haproxy/
    rm -rf haproxy*
    wget https://cdn.udinweb.com/haproxy/haproxy.cfg
    systemctl restart haproxy
    echo "Haproxy Configured Successfully!"
else
    echo "This should only be run on ubuntu\n";
    exit 1;
fi