From: Olaf Hering Subject: [PATCH] tools/hotplug: add helper script to visualize systemd dependencies Date: Wed, 15 Oct 2014 12:20:55 +0200 Message-ID: <1413368455-18465-1-git-send-email-olaf@aepfle.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Olaf Hering List-Id: xen-devel@lists.xenproject.org A small helper to draw a graph with dot(1) and show it with display(1): bash tools/hotplug/Linux/systemd/show_service_dependencies.sh \ tools/hotplug/Linux/systemd/*.in Signed-off-by: Olaf Hering --- .../Linux/systemd/show_service_dependencies.sh | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tools/hotplug/Linux/systemd/show_service_dependencies.sh b/tools/hotplug/Linux/systemd/show_service_dependencies.sh new file mode 100644 index 0000000..e3e4c68 --- /dev/null +++ b/tools/hotplug/Linux/systemd/show_service_dependencies.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# dot(1) from graphviz, display(1) from ImageMagick +# Usage: bash $0 tools/hotplug/Linux/systemd/*.in +( +echo " digraph systemd {" +for file in "$@" +do + if test -f "$file" + then + unit=${file##*/} + unit=${unit%.in} + requires="`grep ^Requires= $file | cut -f 2- -d =`" + before="`grep ^Before= $file | cut -f 2- -d =`" + after="`grep ^After= $file | cut -f 2- -d =`" + echo "\"$unit\" [fillcolor=lightgray color=black fontcolor=black style=filled];" + for i in $requires + do + echo "\"$i\" -> \"$unit\" [color=red];" + done + for i in $after + do + echo "\"$i\" -> \"$unit\" [color=blue];" + done + for i in $before + do + echo "\"$unit\" -> \"$i\" [color=green];" + done + fi +done +echo "}" +) | dot -Tpng | display -