#!/bin/sh

if [ $# -ne 2 ]
then 
    cat <<EOF

usage: $0 <server1> <server2>

       Writes ./dhcpd.<server1> and ./dhcpd.<server2> including only the
       parts of the configuration necessary to run a ISC DHCP server (ver. 3
       or newer). You need to provide a file "/etc/dhcp3/dhcpd.master" with
       the rest of your DHCP servers configuration.

EOF
    exit
fi

cat <<EOF >dhcpd.$1
# created by      $USER
# with help from  $0
# at              $(date --iso-8601=minutes)

failover peer "pool" {
   primary;
   address $1.tu-graz.ac.at;
   port 519;
   peer address $2.tu-graz.ac.at;
   peer port 520;
   max-response-delay 60;
   max-unacked-updates 10;
   mclt 3600;
   split 128;
   load balance max seconds 3;
}

include "/etc/dhcp3/dhcpd.master";
EOF

cat <<EOF >dhcpd.$2
# created by      $USER
# with help from  $0
# at              $(date --iso-8601=minutes)

failover peer "pool" {
   secondary;
   address $2.tu-graz.ac.at;
   port 520;
   peer address $1.tu-graz.ac.at;
   peer port 519;
   max-response-delay 60;
   max-unacked-updates 10;
}

include "/etc/dhcp3/dhcpd.master";
EOF
