xref: /freebsd/sbin/rcorder/rcorder.8 (revision 1d386b48)
1.\"	$NetBSD: rcorder.8,v 1.3 2000/07/17 14:16:22 mrg Exp $
2.\"
3.\" Copyright (c) 1998
4.\"	Perry E. Metzger.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\"    must display the following acknowledgment:
16.\"	This product includes software developed for the NetBSD Project
17.\"	by Perry E. Metzger.
18.\" 4. The name of the author may not be used to endorse or promote products
19.\"    derived from this software without specific prior written permission.
20.\"
21.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31.\"
32.\" $FreeBSD$
33.\"
34.Dd June 10, 2023
35.Dt RCORDER 8
36.Os
37.Sh NAME
38.Nm rcorder
39.Nd print a dependency ordering of interdependent files
40.Sh SYNOPSIS
41.Nm
42.Op Fl gp
43.Op Fl k Ar keep
44.Op Fl s Ar skip
45.Ar
46.Sh DESCRIPTION
47The
48.Nm
49utility is designed to print out a dependency ordering of a set of
50interdependent files.
51Typically it is used to find an execution
52sequence for a set of shell scripts in which certain files must be
53executed before others.
54.Pp
55Each file passed to
56.Nm
57must be annotated with special lines (which look like comments to the
58shell) which indicate the dependencies the files have upon certain
59points in the sequence, known as
60.Dq conditions ,
61and which indicate, for each file, which
62.Dq conditions
63may be expected to be filled by that file.
64.Pp
65Within each file, a block containing a series of
66.Ql REQUIRE ,
67.Ql PROVIDE ,
68.Ql BEFORE
69and
70.Ql KEYWORD
71lines must appear.
72The format of the lines is rigid.
73Each line must begin with a single
74.Ql # ,
75followed by a single space, followed by
76.Ql PROVIDE\&: ,
77.Ql REQUIRE\&: ,
78.Ql BEFORE\&: ,
79or
80.Ql KEYWORD\&: .
81No deviation is permitted.
82Each dependency line is then followed by a series of conditions,
83separated by whitespace.
84Multiple
85.Ql PROVIDE ,
86.Ql REQUIRE ,
87.Ql BEFORE
88and
89.Ql KEYWORD
90lines may appear, but all such lines must appear in a sequence without
91any intervening lines, as once a line that does not follow the format
92is reached, parsing stops.
93.\" Note that for historical reasons REQUIRES, PROVIDES, and KEYWORDS
94.\" are also accepted in addition to the above, but not documented so
95.\" that they can be deprecated at some point in the future.
96.Pp
97The options are as follows:
98.Bl -tag -width "-k keep"
99.It Fl g
100Produce a GraphViz (.dot) of the complete dependency graph instead of
101plaintext calling order list.
102.It Fl k Ar keep
103Add the specified keyword to the
104.Dq "keep list" .
105If any
106.Fl k
107option is given, only those files containing the matching keyword are listed.
108This option can be specified multiple times.
109.It Fl p
110Generate ordering suitable for parallel startup, placing files that can be
111executed simultaneously on the same line.
112.It Fl s Ar skip
113Add the specified keyword to the
114.Dq "skip list" .
115If any
116.Fl s
117option is given, files containing the matching keyword are not listed.
118This option can be specified multiple times.
119.El
120.Pp
121An example block follows:
122.Bd -literal -offset indent
123# REQUIRE: networking syslog
124# REQUIRE: usr
125# PROVIDE: dns nscd
126.Ed
127.Pp
128This block states that the file in which it appears depends upon the
129.Ql networking ,
130.Ql syslog ,
131and
132.Ql usr
133conditions, and provides the
134.Ql dns
135and
136.Ql nscd
137conditions.
138.Pp
139A file may contain zero
140.Ql PROVIDE
141lines, in which case it provides no conditions, and may contain zero
142.Ql REQUIRE
143lines, in which case it has no dependencies.
144There must be at least one file with no dependencies in the set of
145arguments passed to
146.Nm
147in order for it to find a starting place in the dependency ordering.
148.Sh KEYWORDS
149There are several
150.Em KEYWORDs
151in use:
152.Bl -tag -width "shutdown" -offset indent
153.It Sy firstboot , nojail , nojailvnet , nostart
154Used by
155.Xr rc 8 .
156.It Sy suspend , resume
157Used by
158.Nm /etc/rc.suspend
159and
160.Nm /etc/rc.resume
161(see
162.Xr acpiconf 8 )
163.It Sy shutdown
164Used by
165.Xr rc.shutdown 8 .
166.El
167.Sh EXAMPLES
168Print the dependency ordering of the services from the base system and
169.Xr ports 7 :
170.Bd -literal -offset indent
171$ rcorder /etc/rc.d/* /usr/local/etc/rc.d/*
172.Ed
173.Pp
174Count the number of services in the base system, which specify the
175.Sy nostart
176keyword, while skipping those with
177.Sy firstboot
178and
179.Sy nojailvnet :
180.Bd -literal -offset indent
181$ rcorder -k nostart -s firstboot -s nojailvnet /etc/rc.d/*  | wc -l
182       3
183.Ed
184.Sh DIAGNOSTICS
185The
186.Nm
187utility may print one of the following error messages and exit with a non-zero
188status if it encounters an error while processing the file list.
189.Bl -diag
190.It "Requirement %s in file %s has no providers."
191No file has a
192.Ql PROVIDE
193line corresponding to a condition present in a
194.Ql REQUIRE
195line in another file.
196.It "Circular dependency on provision %s in file %s."
197A set of files has a circular dependency which was detected while
198processing the stated condition.
199Loop visualization follows this message.
200.It "Circular dependency on file %s."
201A set of files has a circular dependency which was detected while
202processing the stated file.
203.It "%s was seen in circular dependencies for %d times."
204Each node that was a part of circular dependency loops reports total number of
205such encounters.
206Start with files having biggest counter when fighting with broken dependencies.
207.El
208.Sh DIAGNOSTICS WITH GRAPHVIZ
209Direct dependency is drawn with solid line,
210.Ql BEFORE
211dependency is drawn as a dashed line.
212Each node of a graph represents an item from
213.Ql PROVIDE
214lines.
215In case there are more than one file providing an item, a list of filenames
216shortened with
217.Xr basename 3
218is shown.
219Shortened filenames are also shown in case
220.Ql PROVIDE
221item does not match file name.
222.Pp
223Edges and nodes where circular dependencies were detected are drawn bold red.
224If a file has an item in
225.Ql REQUIRE
226or in
227.Ql BEFORE
228that could not be provided,
229this missing provider and the requirement will be drawn bold red as well.
230.Sh SEE ALSO
231.Xr acpiconf 8 ,
232.Xr rc 8 ,
233.Xr rc.shutdown 8 ,
234.Xr service 8
235.Sh HISTORY
236The
237.Nm
238utility appeared in
239.Nx 1.5 .
240.Nm
241utility first appeared in
242.Fx 5.0 .
243.Sh AUTHORS
244.An -nosplit
245Written by
246.An Perry E. Metzger Aq Mt perry@piermont.com
247and
248.An Matthew R. Green Aq Mt mrg@eterna.com.au .
249.Sh BUGS
250The
251.Ql REQUIRE
252keyword is misleading:
253It does not describe which daemons have to be running before a script
254will be started.
255It describes which scripts must be placed before it in
256the dependency ordering.
257For example,
258if your script has a
259.Ql REQUIRE
260on
261.Ql sshd ,
262it means the script must be placed after the
263.Ql sshd
264script in the dependency ordering,
265not necessarily that it requires
266.Nm sshd
267to be started or enabled.
268