#! /usr/bin/env bash unset BRO_DISABLE_BROXYGEN # If running this from btest, unset any of the environment # variables that alter default script values. unset BRO_DEFAULT_LISTEN_ADDRESS unset BRO_DEFAULT_LISTEN_RETRY unset BRO_DEFAULT_CONNECT_RETRY dir="$( cd "$( dirname "$0" )" && pwd )" source_dir="$( cd $dir/../.. && pwd )" build_dir=$source_dir/build conf_file=$build_dir/broxygen-test.conf output_dir=$source_dir/doc bro_error_file=$build_dir/broxygen-test-stderr.txt if [ -n "$1" ]; then output_dir=$1 fi case $output_dir in /*) ;; *) output_dir=`pwd`/$output_dir ;; esac cd $build_dir . bro-path-dev.sh export BRO_SEED_FILE=$source_dir/testing/btest/random.seed function run_bro { ZEEK_ALLOW_INIT_ERRORS=1 bro -X $conf_file broxygen >/dev/null 2>$bro_error_file if [ $? -ne 0 ]; then echo "Failed running bro with broxygen config file $conf_file" echo "See stderr in $bro_error_file" exit 1 fi } scripts_output_dir=$output_dir/scripts rm -rf $scripts_output_dir printf "script\t*\t$scripts_output_dir/" > $conf_file echo "Generating $scripts_output_dir/" run_bro script_ref_dir=$output_dir/script-reference mkdir -p $script_ref_dir function generate_index { echo "Generating $script_ref_dir/$2" printf "$1\t*\t$script_ref_dir/$2\n" > $conf_file run_bro } generate_index "script_index" "autogenerated-script-index.rst" generate_index "package_index" "autogenerated-package-index.rst" generate_index "file_analyzer" "autogenerated-file-analyzer-index.rst" generate_index "proto_analyzer" "autogenerated-protocol-analyzer-index.rst" echo if [ -n "$(cd $source_dir/doc && git status --porcelain)" ]; then echo "*** There are changes in zeek-docs that need a review, commit, and push ***" else echo "No changes or further action needed" fi