ffmpeg-6: fix COMPONENT_REVISION
[oi-userland.git] / components / sysutils / scfdot / files / scfdotctl
blob2806f60601fc84ef8437f1121e9660362e55bd7f
1 #!/bin/sh
4 # CDDL HEADER START
6 # The contents of this file are subject to the terms of the
7 # Common Development and Distribution License (the "License").
8 # You may not use this file except in compliance with the License.
10 # You can obtain a copy of the license at CDDL.LICENSE.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at CDDL.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
20 # CDDL HEADER END
24 # Copyright 2005 Sun Microsystems, Inc. All rights reserved.
25 # Copyright 2017 Andreas Grueninger, Grueninger GmbH, (grueni). All rights reserved.
28 # check the requirements
29 if [ ! -f /usr/bin/dot ] || [ ! -f /usr/bin/gs ]; then
30 echo "-> Ups! We need graphviz and ghostscript, please install the packages with:"
31 echo "pkg install print/filter/ghostscript image/graphviz"
32 exit
35 # Build scfdot, invoke it to generate a graph description, and run dot to
36 # render it to PostScript. The resulting file will be <hostname>.ps .
38 # Options to pass to scfdot. This limits the graph to 300" by 42", includes
39 # legend.ps as the legend (built below), and consolidates inetd services into
40 # a single node. See the comment at the top of scfdot.c for other options.
41 # Edit please directly below in the second call of scfdot.
43 HOSTNAME=`hostname`
44 SCFDOTOPTSL='-L'
46 # Margin, in inches, to include above and below the legend.
47 LEGEND_MARGIN=3
49 # Options to pass to dot when rendering the graph. Consider increasing
50 # mclimit, which dictates how long dot spends optimizing node placement. It
51 # defaults to 1.0; 100 should produce good output, but it may take a long
52 # time.
53 DOTOPTS=-Gmclimit=100
55 cat << EOF > /tmp/functions.awk.$$
56 BEGIN {
57 f = "";
58 left = 0;
59 bottom = 0;
60 right = 0;
61 top = 0;
64 f == "enlarge" && /^%%BoundingBox:/ {
65 printf "%s %d %d %d %d\n", \$1, \$2 - left * 72, \$3 - bottom * 72, \\
66 \$4 + right * 72, \$5 + top * 72;
67 next;
69 f == "setpage" && /^%%BoundingBox:/ {
70 width = \$4; height = \$5
72 f == "setpage" && /^%%BeginSetup\$/ {
73 if (width == 0 || height == 0) {
74 exit 1;
76 print;
78 # I doubt this is necessary, but the PPD spec suggests it.
79 print "%%BeginFeature: *CustomPageSize";
81 # Here we print the parameters to the code below. We add an inch of
82 # 'far' margin (the 'near' margin should have already been set by dot
83 # to be whatever margin was set to in the .dot file).
84 printf "%d %d\n", width + 72, height + 72;
86 # This is the magic code from HP's ppd file. Actually, the ppd code
87 # begins with pop pop pop, but that just discards the orientation and
88 # offset parameters, so if we don't print them in the first place, it
89 # won't matter.
90 print "<</PageSize [ 5 -2 roll ] /ImagingBBox null>>setpagedevice";
92 print "%%EndFeature";
93 next;
95 { print }
97 EOF
100 scfdot "${SCFDOTOPTSL}" > /tmp/legend.dot.$$
101 dot -Teps /tmp/legend.dot.$$ > /tmp/legend.ps.$$
102 awk -f /tmp/functions.awk.$$ top="${LEGEND_MARGIN}" bottom="${LEGEND_MARGIN}" f=enlarge \
103 /tmp/legend.ps.$$ > "/tmp/${HOSTNAME}-legend.ps.$$"
104 scfdot -l "/tmp/${HOSTNAME}-legend.ps.$$" -s "300,42" -x consolidate_inetd_svcs > /tmp/hostname.dot.$$
105 echo "If you want to speed up the process use lower values for option Gmclimit (used value: ${DOTOPTS})"
106 dot -Tps2 ${DOTOPTS} < /tmp/hostname.dot.$$ > /tmp/hostname.ps.$$
107 awk -f /tmp/functions.awk.$$ f=setpage /tmp/hostname.ps.$$ > "${HOSTNAME}.ps"
108 grep BoundingBox "${HOSTNAME}.ps"|tail -1
109 ps2pdf -dPDFFitPage "${HOSTNAME}.ps" "${HOSTNAME}.pdf"
110 rm /tmp/legend.dot.$$ /tmp/legend.ps.$$ \
111 /tmp/hostname.dot.$$ /tmp/hostname.ps.$$ \
112 /tmp/functions.awk.$$ "/tmp/${HOSTNAME}-legend.ps.$$"
113 echo "created ${HOSTNAME}.ps and ${HOSTNAME}.pdf"