#!/bin/sh
#
# Check that Main-Server's hostname is set to short hostname 'tjener', not FQDN 'tjener.intern'.

if test -r /etc/debian-edu/config ; then
    . /etc/debian-edu/config
fi

LC_ALL=C
export LC_ALL

scriptname="$0"

case $PROFILE in
*Main-Server*)
    # Check that the hostname of the Main-Server is set to its short hostname (not FQDN)
    if [ -e /etc/hostname ] && grep -q -E "^tjener\$" /etc/hostname; then
        printf "success: %s: Main-Server's hostname is set to 'tjener'\n" "${scriptname}"
    elif [ -e /etc/hostname ] && grep -q -E "^tjener\.intern\$" /etc/hostname; then
        printf "error: %s: Main-Server's hostname is (still) set to 'tjener.intern', please drop the DNS domain part from it\n" "${scriptname}"
        exit 1
    else
        printf "error: %s: Main-Server's hostname is not 'tjener'\n" "${scriptname}"
        exit 1
    fi
    ;;
esac
