#!/bin/sh
set -e

cat > "$INSTALL_ROOT/etc/NetworkManager/dispatcher.d/000-override-nameserver" <<'EOF'

#!/bin/sh
# Copyright (C) 2010 One Laptop Per Child Association, Inc.
# Licensed under the terms of the GNU GPL v2 or later; see COPYING for details.
# Written by Martin Langhoff <martin@laptop.org>

# REPLACE with the base domain for your servers
#basedomain="xs\.base\.domain\.tld"
basedomain="fundacionzt.org"

# REPLACE with IP addresses of your DNS servers
PRIMARYDNS="89.200.141.245"
#SECONDARYDNS="208.67.220.220" 

if="$1"
updown="$2"

if [ "$updown" = "up" ]; then
    # 
    # no confundirse con iparatodos como ISP
    if ! grep -q "^search.*\.$basedomain" /etc/resolv.conf; then
        # reemplazar resolv.conf
        echo "# Overwritten by 000-override-nameserver" > /etc/resolv.conf
        echo nameserver $PRIMARYDNS   >> /etc/resolv.conf
 #       echo nameserver $SECONDARYDNS >> /etc/resolv.conf  
    fi
fi

EOF
chmod 755 "$INSTALL_ROOT/etc/NetworkManager/dispatcher.d/000-override-nameserver"
#sh