#!/bin/sh -e
#
# Test if the smbadmin account is created

. /usr/share/debian-edu-config/testsuite-lib.sh

DOMAIN=SKOLELINUX

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

# Only Main-Server install samba
if echo "$PROFILE" | grep -Eq 'Main-Server' ; then
    :
else
    exit 0
fi

# Only test if samba is installed
if  deb_installed samba ; then
    :
else
    echo "info: $0: samba is not installed"
    exit 0
fi

if pidof smbd > /dev/null ; then
    echo "success: $0: samba is running."
else
    echo "error: $0: samba is not running."
    exit 1
fi

netstat_check netbios-ns udp "Netbios name"
netstat_check netbios-ssn tcp "Netbios session"

if command -v net >/dev/null ; then
    echo "success: $0: found net binary."
    if net time 2>&1 | grep -q $(date +%Y) ; then
	echo "success: $0: command 'net time' is working."
    else
	echo "error: $0: command 'net time' fails, check if Samba is working."
    fi
else
    echo "error: $0: missing net binary."
fi

exit 0
