#! /usr/bin/env bash
#
# Just check Bro's configuration for errors.
#
# check_config <installed_policies_flag> <print loaded scripts flag> <dir-to-set-as-cwd> <Bro parameters>

. `dirname $0`/broctl-config.sh

# Tell the BroControl script code that this is only a check.
export BROCTL_CHECK=1

use_installed_policies=$1
tmp_node_dir=$3
source ${scriptsdir}/set-bro-path
shift

print_scripts=$1
shift

cd $1
shift

export PATH=${bindir}:${scriptsdir}:$PATH

echo $@ >.cmdline
touch .checking

${bro} $@
rc=$?

if [ "$rc" == "0" ] && [ "$print_scripts" == "1" ]; then
    cat loaded_scripts*
fi

exit $rc
