Sync usage with man page.
[netbsd-mini2440.git] / sbin / rcorder / rcorder-visualize.sh
blobdda5e7f48f40a34e0b39c6a5df5e7e597bae5f42
1 #!/bin/sh
2 # $NetBSD: rcorder-visualize.sh,v 1.4 2009/04/15 23:03:34 joerg 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 '}'