2009-04-16 02:36:04 +04:00
|
|
|
#!/bin/sh
|
2009-04-16 03:03:34 +04:00
|
|
|
# $NetBSD: rcorder-visualize.sh,v 1.4 2009/04/15 23:03:34 joerg Exp $
|
2009-04-16 02:36:04 +04:00
|
|
|
#
|
2009-04-16 03:03:34 +04:00
|
|
|
# Written by Joerg Sonnenberger. You may freely use and redistribute
|
2009-04-16 02:36:04 +04:00
|
|
|
# this script.
|
|
|
|
#
|
|
|
|
# Simple script to show the dependency graph for rc scripts.
|
|
|
|
# Output is in the dot(1) language and can be rendered using
|
|
|
|
# sh rcorder-visualize | dot -T svg -o rcorder.svg
|
|
|
|
# dot(1) can be found in graphics/graphviz in pkgsrc.
|
|
|
|
|
2009-04-16 02:44:26 +04:00
|
|
|
rc_files=/etc/rc.d/*
|
2009-04-16 02:36:04 +04:00
|
|
|
|
|
|
|
{
|
|
|
|
echo ' digraph {'
|
|
|
|
for f in $rc_files; do
|
|
|
|
< $f awk '
|
|
|
|
/# PROVIDE: / { provide = $3 }
|
|
|
|
/# REQUIRE: / { for (i = 3; i <= NF; i++) requires[$i] = $i }
|
|
|
|
/# BEFORE: / { for (i = 3; i <= NF; i++) befores[$i] = $i }
|
|
|
|
|
|
|
|
END {
|
|
|
|
print " \"" provide "\";"
|
|
|
|
for (x in requires) print " \"" provide "\"->\"" x "\";"
|
|
|
|
for (x in befores) print " \"" x "\"->\"" provide "\";"
|
|
|
|
}
|
|
|
|
'
|
|
|
|
done
|
|
|
|
echo '}'
|
2009-04-16 02:38:26 +04:00
|
|
|
}
|