#!/usr/bin/env bash # set -e SCANNER="$PWD/ei-scanner" PROTOFILE="$PWD/protocol.xml" TEMPLATEDIR="$PWD" OUTDIR="$PWD" SITENAME="ei" INDEXPAGE="" while [[ $# -gt 0 ]]; do case "$1" in --verbose | -v) set -x shift ;; --scanner) SCANNER="$2" shift 2; ;; --protocol) PROTOFILE="$2" shift 2 ;; --template-dir) TEMPLATEDIR="$2" shift 2 ;; --output-dir) OUTDIR="$2" shift 2 ;; --index-page) INDEXPAGE="$2" shift 2; ;; **) echo "Unknown argument: $1" exit 1 ;; esac done SITEDIR="$OUTDIR/$SITENAME" if [[ -e "$SITEDIR" ]]; then echo "$SITEDIR already exists, updating" else hugo new site "$SITEDIR" git clone --depth=1 https://github.com/McShelby/hugo-theme-relearn "$SITEDIR/themes/hugo-theme-relearn" fi cp "$TEMPLATEDIR/config.toml" "$SITEDIR/" if [[ -n "$INDEXPAGE" ]]; then cp "$INDEXPAGE" "$SITEDIR/content/_index.md" fi pushd "$SITEDIR" > /dev/null || exit 1 # Generate a list of available interfaces and read that # list line-by-line to generate a separate .md file # for each interface mkdir -p "$SITEDIR/content/interfaces" while read -r iface; do $SCANNER --component=ei --jinja-extra-data="{ \"interface\": \"$iface\" }" --output="$SITEDIR/content/interfaces/$iface.md" "$PROTOFILE" "$TEMPLATEDIR/interface.md.tmpl" done < <($SCANNER --component=ei "$PROTOFILE" - < /dev/null || exit 1