Sync some manuals from bin & sbin with NetBSD-8
[minix.git] / sbin / rcorder / rcorder-visualize.sh
blob763b5abc6280ff5d88addc9e9ba1c3d1d3852bf2
1 #!/bin/sh
2 # $NetBSD: rcorder-visualize.sh,v 1.5 2009/08/09 17:08:53 apb Exp $
4 # Written by Joerg Sonnenberger. You may freely use and redistribute
5 # this script.
7 # Simple script to show the dependency graph for rc scripts.
8 # Output is in the dot(1) language and can be rendered using
9 # sh rcorder-visualize | dot -T svg -o rcorder.svg
10 # dot(1) can be found in graphics/graphviz in pkgsrc.
12 rc_files=${*:-/etc/rc.d/*}
15 echo ' digraph {'
16 for f in $rc_files; do
17 < $f awk '
18 /# PROVIDE: / { provide = $3 }
19 /# REQUIRE: / { for (i = 3; i <= NF; i++) requires[$i] = $i }
20 /# BEFORE: / { for (i = 3; i <= NF; i++) befores[$i] = $i }
22 END {
23 print " \"" provide "\";"
24 for (x in requires) print " \"" provide "\"->\"" x "\";"
25 for (x in befores) print " \"" x "\"->\"" provide "\";"
28 done
29 echo '}'