summaryrefslogtreecommitdiffstats
path: root/retiolum/scripts/adv_graphgen/scripts/build-graphs
blob: 891516718ffc2a12ca78a3444b1191ad1b9ba404 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh
set -eufx
mode=${1?arg1 must be either 'anonymous' or 'complete'}
out=${2?arg2 must be set to an outdir}
# for creating all the graphs
TYPE=svg
# for creating real pictures
TYPE2=png

DOTFILE=`mktemp`
trap 'rm "$DOTFILE"' INT TERM KILL EXIT

tinc-stats2json | tinc-build-graph  "$mode" > "$DOTFILE"

i=1
for setter in dot circo 'neato -Goverlap=prism ' sfdp
do
  tmpgraph=`mktemp --tmpdir=$out`
  # first build, then move to avoid half-built graphs
  "$setter" -T$TYPE -o "$tmpgraph" "$DOTFILE" ||:
  chmod go+rx "$tmpgraph"
  mv "$tmpgraph" "$out/retiolum_$i.$TYPE"
  i=`expr $i + 1`
done

convert -limit memory 32Mib -limit map 64Mib "$out/retiolum_1.$TYPE"  "$out/retiolum_1.$TYPE2"
rm "$DOTFILE"