From cb870fadaaf74fbceb7a150861cfa37370836a42 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Sun, 24 Nov 2019 16:43:45 -0800 Subject: [PATCH] add scripts and stuff necessary to automatically generate the diagram using graph-easy... required writting a simple awk script to add the necessary border for MarkDeep.. haven't integrated the diagram generation into the file yet.. --- Makefile | 6 ++++++ box.sh | 32 ++++++++++++++++++++++++++++++++ diag.txt | 25 +++++++++++++++++++++++++ diag_inp.txt | 9 +++++++++ 4 files changed, 72 insertions(+) create mode 100644 Makefile create mode 100644 box.sh create mode 100644 diag.txt create mode 100644 diag_inp.txt diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d6b5ff6 --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +# https://github.com/ironcamel/Graph-Easy +diag.txt: diag_inp.txt box.sh + graph-easy < $< | sh box.sh > $@ + +diagtest: + ls box.sh diag_inp.txt Makefile | entr sh -c 'make diag.txt && cat diag.txt' diff --git a/box.sh b/box.sh new file mode 100644 index 0000000..df74250 --- /dev/null +++ b/box.sh @@ -0,0 +1,32 @@ +#!/bin/sh +fname=$(mktemp foobar.XXXXX) +cat > "$fname" +awk ' +maxline == 1 { + if (maxlength < length) + maxlength = length +} + +function printtop () { + blank = "" + for (i = 0; i < maxlength + 4; i++) + blank = blank "*" + printf("%s\n", blank) +} + +output == 1 && FNR == 1 { + printtop() + printf("* %*s *\n", maxlength, "") +} + +output == 1 { + printf("* %s%*s *\n", $0, maxlength - length, "") +} + +END { + printf("* %*s *\n", maxlength, "") + printtop() +} +' maxline=1 "$fname" maxline=0 output=1 "$fname" + +rm "$fname" diff --git a/diag.txt b/diag.txt new file mode 100644 index 0000000..437b062 --- /dev/null +++ b/diag.txt @@ -0,0 +1,25 @@ +********************************************************************************* +* * +* +-------------+ * +* | Internet | * +* +-------------+ * +* | * +* | * +* | * +* +----------------+ +-------------+ * +* | Host machine |-----------------------------| VLAN Switch | * +* +----------------+ +-------------+ * +* | | * +* | | * +* | | * +* +----------------+ +-----------------+ +-------------+ +--------+ * +* | USB Hub | --- | Power Controler | --- | RockPro64 | | 12V PS | * +* +----------------+ +-----------------+ +-------------+ +--------+ * +* | | | | * +* | +-----------------------+-------------------+ * +* | | * +* +----------------+ | * +* | Serial adapter |-------------------------------+ * +* +----------------+ * +* * +********************************************************************************* diff --git a/diag_inp.txt b/diag_inp.txt new file mode 100644 index 0000000..73a1a26 --- /dev/null +++ b/diag_inp.txt @@ -0,0 +1,9 @@ +[ Internet ] { flow: north } -- [ VLAN Switch ] +[ Host machine ] -- [ VLAN Switch ] +[ Host machine ] { flow: south } -- [ USB Hub ] +[ RockPro64 ] { flow: north } -- [ VLAN Switch ] +[ USB Hub ] -- [ Power Controler ] +[ USB Hub ] -- [ Serial adapter ] +[ Serial adapter ] -- [ RockPro64 ] +[ Power Controler ] -- [ 12V PS ] +[ Power Controler ] { flow: east } -- [ RockPro64 ]