#!/bin/sh

set -e

# ensure a (tmpfs-based) /run/samba exists before running testparm
[ -d /run/samba ] || mkdir -p /run/samba

if [ "$1" = "configure" ] ; then
    SERVER_ROLE=`samba-tool testparm --parameter-name="server role"  2>/dev/null | tail -1`
    if [ "$SERVER_ROLE" = "active directory domain controller" ]; then
        echo "Checking smb.conf with samba-tool"
        samba-tool testparm -d1 --suppress-prompt > /dev/null
        echo "Done"
    else
        echo "Checking smb.conf with testparm"
        testparm -d1 --suppress-prompt > /dev/null
        echo "Done"
    fi
fi


