#!/bin/bash

# Keep plain /etc/resolv.conf only if admin set the DNS IPs
# Otherwise, /etc/resolv.conf is a link to systemd-resolved compatibility file

ACTIVER_RESOLV_TEMPLATE=$(CreoleGet test_activer_resolvconf_template)

if [ "${ACTIVER_RESOLV_TEMPLATE}" = 'oui' -a -L /etc/resolv.conf ]
then
    echo "Suppression du lien symbolique /etc/resolv.conf"
    rm -f /etc/resolv.conf
elif [ "${ACTIVER_RESOLV_TEMPLATE}" = 'non' -a -f /etc/resolv.conf ]
then
    echo "Création du lien symbolique /etc/resolv.conf vers /run/systemd/resolve/stub-resolv.conf"
    rm -f /etc/resolv.conf
    ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
fi

exit 0
