# This file is managed by puppet.
# the variable "new_resolv_options" will exist if resolv-options is provided in the DHCP OFFER packet
# this is a custom option that Twitch sets at the top level Infoblox DHCP scope, dhcp option 224 = text
#

# default options if no resolv option are passed via DHCP
default_options="rotate timeout:3"

# delete all options lines to prevent dups
/bin/sed -i.bak '/^options /d' /etc/resolv.conf

# apply new_resolv_options otherwise use default_options
if [ "$new_resolv_options" ]; then
  for option in $new_resolv_options
  do
    /bin/sed -i.bak -e "\$aoptions ${option}" /etc/resolv.conf
  done
else
  for option in $default_options
  do
    /bin/sed -i.bak -e "\$aoptions ${option}" /etc/resolv.conf
  done
fi
