#!/bin/sh
echo "This will setup DNS clustering on this server"

read -p 'DNS Cluster user on this box? [root]' clusteruser
clusteruser=${clusteruser:=root}
read -p 'Server to get key from? [backup2.afrihost.com]' server
server=${server:=dnscluster.afrihost.com}

read -p 'Username:' username
read -p 'Password:' password


ip=`host -t A $server | cut -f 4 -d ' '`

mkdir -p "/var/cpanel/cluster/$clusteruser/config"
wget "--http-user=$username" "--http-password=$password" "http://$server/bill/cpanelwhm/whmauthfile.php" -O "/var/cpanel/cluster/$clusteruser/config/$ip"
echo -n 'sync' > "/var/cpanel/cluster/$clusteruser/config/$ip-dnsrole"

echo Created the file "/var/cpanel/cluster/$clusteruser/config/$ip"
echo with contents:
echo ===================================
cat "/var/cpanel/cluster/$clusteruser/config/$ip"
echo ===================================
