xref: /freebsd/sbin/rcorder/rcorder.8 (revision 22cf89c938886d14f5796fc49f9f020c23ea8eaf)
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.Dd June 10, 2023
33.Dt RCORDER 8
34.Os
35.Sh NAME
36.Nm rcorder
37.Nd print a dependency ordering of interdependent files
38.Sh SYNOPSIS
39.Nm
40.Op Fl gp
41.Op Fl k Ar keep
42.Op Fl s Ar skip
43.Ar
44.Sh DESCRIPTION
45The
46.Nm
47utility is designed to print out a dependency ordering of a set of
48interdependent files.
49Typically it is used to find an execution
50sequence for a set of shell scripts in which certain files must be
51executed before others.
52.Pp
53Each file passed to
54.Nm
55must be annotated with special lines (which look like comments to the
56shell) which indicate the dependencies the files have upon certain
57points in the sequence, known as
58.Dq conditions ,
59and which indicate, for each file, which
60.Dq conditions
61may be expected to be filled by that file.
62.Pp
63Within each file, a block containing a series of
64.Ql REQUIRE ,
65.Ql PROVIDE ,
66.Ql BEFORE
67and
68.Ql KEYWORD
69lines must appear.
70The format of the lines is rigid.
71Each line must begin with a single
72.Ql # ,
73followed by a single space, followed by
74.Ql PROVIDE\&: ,
75.Ql REQUIRE\&: ,
76.Ql BEFORE\&: ,
77or
78.Ql KEYWORD\&: .
79No deviation is permitted.
80Each dependency line is then followed by a series of conditions,
81separated by whitespace.
82Multiple
83.Ql PROVIDE ,
84.Ql REQUIRE ,
85.Ql BEFORE
86and
87.Ql KEYWORD
88lines may appear, but all such lines must appear in a sequence without
89any intervening lines, as once a line that does not follow the format
90is reached, parsing stops.
91.\" Note that for historical reasons REQUIRES, PROVIDES, and KEYWORDS
92.\" are also accepted in addition to the above, but not documented so
93.\" that they can be deprecated at some point in the future.
94.Pp
95The options are as follows:
96.Bl -tag -width "-k keep"
97.It Fl g
98Produce a GraphViz (.dot) of the complete dependency graph instead of
99plaintext calling order list.
100.It Fl k Ar keep
101Add the specified keyword to the
102.Dq "keep list" .
103If any
104.Fl k
105option is given, only those files containing the matching keyword are listed.
106This option can be specified multiple times.
107.It Fl p
108Generate ordering suitable for parallel startup, placing files that can be
109executed simultaneously on the same line.
110.It Fl s Ar skip
111Add the specified keyword to the
112.Dq "skip list" .
113If any
114.Fl s
115option is given, files containing the matching keyword are not listed.
116This option can be specified multiple times.
117.El
118.Pp
119An example block follows:
120.Bd -literal -offset indent
121# REQUIRE: networking syslog
122# REQUIRE: usr
123# PROVIDE: dns nscd
124.Ed
125.Pp
126This block states that the file in which it appears depends upon the
127.Ql networking ,
128.Ql syslog ,
129and
130.Ql usr
131conditions, and provides the
132.Ql dns
133and
134.Ql nscd
135conditions.
136.Pp
137A file may contain zero
138.Ql PROVIDE
139lines, in which case it provides no conditions, and may contain zero
140.Ql REQUIRE
141lines, in which case it has no dependencies.
142There must be at least one file with no dependencies in the set of
143arguments passed to
144.Nm
145in order for it to find a starting place in the dependency ordering.
146.Sh KEYWORDS
147There are several
148.Em KEYWORDs
149in use:
150.Bl -tag -width "shutdown" -offset indent
151.It Sy firstboot , nojail , nojailvnet , nostart
152Used by
153.Xr rc 8 .
154.It Sy suspend , resume
155Used by
156.Nm /etc/rc.suspend
157and
158.Nm /etc/rc.resume
159(see
160.Xr acpiconf 8 )
161.It Sy shutdown
162Used by
163.Xr rc.shutdown 8 .
164.El
165.Sh EXAMPLES
166Print the dependency ordering of the services from the base system and
167.Xr ports 7 :
168.Bd -literal -offset indent
169$ rcorder /etc/rc.d/* /usr/local/etc/rc.d/*
170.Ed
171.Pp
172Count the number of services in the base system, which specify the
173.Sy nostart
174keyword, while skipping those with
175.Sy firstboot
176and
177.Sy nojailvnet :
178.Bd -literal -offset indent
179$ rcorder -k nostart -s firstboot -s nojailvnet /etc/rc.d/*  | wc -l
180       3
181.Ed
182.Sh DIAGNOSTICS
183The
184.Nm
185utility may print one of the following error messages and exit with a non-zero
186status if it encounters an error while processing the file list.
187.Bl -diag
188.It "Requirement %s in file %s has no providers."
189No file has a
190.Ql PROVIDE
191line corresponding to a condition present in a
192.Ql REQUIRE
193line in another file.
194.It "Circular dependency on provision %s in file %s."
195A set of files has a circular dependency which was detected while
196processing the stated condition.
197Loop visualization follows this message.
198.It "Circular dependency on file %s."
199A set of files has a circular dependency which was detected while
200processing the stated file.
201.It "%s was seen in circular dependencies for %d times."
202Each node that was a part of circular dependency loops reports total number of
203such encounters.
204Start with files having biggest counter when fighting with broken dependencies.
205.El
206.Sh DIAGNOSTICS WITH GRAPHVIZ
207Direct dependency is drawn with solid line,
208.Ql BEFORE
209dependency is drawn as a dashed line.
210Each node of a graph represents an item from
211.Ql PROVIDE
212lines.
213In case there are more than one file providing an item, a list of filenames
214shortened with
215.Xr basename 3
216is shown.
217Shortened filenames are also shown in case
218.Ql PROVIDE
219item does not match file name.
220.Pp
221Edges and nodes where circular dependencies were detected are drawn bold red.
222If a file has an item in
223.Ql REQUIRE
224or in
225.Ql BEFORE
226that could not be provided,
227this missing provider and the requirement will be drawn bold red as well.
228.Sh SEE ALSO
229.Xr acpiconf 8 ,
230.Xr rc 8 ,
231.Xr rc.shutdown 8 ,
232.Xr service 8
233.Sh HISTORY
234The
235.Nm
236utility appeared in
237.Nx 1.5 .
238.Nm
239utility first appeared in
240.Fx 5.0 .
241.Sh AUTHORS
242.An -nosplit
243Written by
244.An Perry E. Metzger Aq Mt perry@piermont.com
245and
246.An Matthew R. Green Aq Mt mrg@eterna.com.au .
247.Sh BUGS
248The
249.Ql REQUIRE
250keyword is misleading:
251It does not describe which daemons have to be running before a script
252will be started.
253It describes which scripts must be placed before it in
254the dependency ordering.
255For example,
256if your script has a
257.Ql REQUIRE
258on
259.Ql sshd ,
260it means the script must be placed after the
261.Ql sshd
262script in the dependency ordering,
263not necessarily that it requires
264.Nm sshd
265to be started or enabled.
266