Mon, 28 Jan 2013 17:37:18 +0100
Correct socket error reporting improvement with IPv6 portable code,
after helpful recommendation by Saúl Ibarra Corretgé on OSips devlist.
1 .\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.22)
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
6 .if t .sp .5v
7 .if n .sp
8 ..
9 .de Vb \" Begin verbatim text
10 .ft CW
11 .nf
12 .ne \\$1
13 ..
14 .de Ve \" End verbatim text
15 .ft R
16 .fi
17 ..
18 .\" Set up some character translations and predefined strings. \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote. \*(C+ will
21 .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
24 .tr \(*W-
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
26 .ie n \{\
27 . ds -- \(*W-
28 . ds PI pi
29 . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
31 . ds L" ""
32 . ds R" ""
33 . ds C`
34 . ds C'
35 'br\}
36 .el\{\
37 . ds -- \|\(em\|
38 . ds PI \(*p
39 . ds L" ``
40 . ds R" ''
41 'br\}
42 .\"
43 .\" Escape single quotes in literal strings from groff's Unicode transform.
44 .ie \n(.g .ds Aq \(aq
45 .el .ds Aq '
46 .\"
47 .\" If the F register is turned on, we'll generate index entries on stderr for
48 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
49 .\" entries marked with X<> in POD. Of course, you'll have to process the
50 .\" output yourself in some meaningful fashion.
51 .ie \nF \{\
52 . de IX
53 . tm Index:\\$1\t\\n%\t"\\$2"
54 ..
55 . nr % 0
56 . rr F
57 .\}
58 .el \{\
59 . de IX
60 ..
61 .\}
62 .\"
63 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
64 .\" Fear. Run. Save yourself. No user-serviceable parts.
65 . \" fudge factors for nroff and troff
66 .if n \{\
67 . ds #H 0
68 . ds #V .8m
69 . ds #F .3m
70 . ds #[ \f1
71 . ds #] \fP
72 .\}
73 .if t \{\
74 . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
75 . ds #V .6m
76 . ds #F 0
77 . ds #[ \&
78 . ds #] \&
79 .\}
80 . \" simple accents for nroff and troff
81 .if n \{\
82 . ds ' \&
83 . ds ` \&
84 . ds ^ \&
85 . ds , \&
86 . ds ~ ~
87 . ds /
88 .\}
89 .if t \{\
90 . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
91 . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
92 . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
93 . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
94 . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
95 . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
96 .\}
97 . \" troff and (daisy-wheel) nroff accents
98 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
99 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
100 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
101 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
102 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
103 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
104 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
105 .ds ae a\h'-(\w'a'u*4/10)'e
106 .ds Ae A\h'-(\w'A'u*4/10)'E
107 . \" corrections for vroff
108 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
109 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
110 . \" for low resolution devices (crt and lpr)
111 .if \n(.H>23 .if \n(.V>19 \
112 \{\
113 . ds : e
114 . ds 8 ss
115 . ds o a
116 . ds d- d\h'-1'\(ga
117 . ds D- D\h'-1'\(hy
118 . ds th \o'bp'
119 . ds Th \o'LP'
120 . ds ae ae
121 . ds Ae AE
122 .\}
123 .rm #[ #] #H #V #F C
124 .\" ========================================================================
125 .\"
126 .IX Title "RC 8"
127 .TH RC 8 "OpenPKG" "RC(8)" "OpenPKG"
128 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
129 .\" way too many mistakes in technical documents.
130 .if n .ad l
131 .nh
132 .SH "NAME"
133 @l_prefix@/bin/openpkg rc \- OpenPKG Run\-Command Processor
134 .SH "SYNOPSIS"
135 .IX Header "SYNOPSIS"
136 \&\fB\f(CB@l_prefix\fB@/bin/openpkg rc\fR [\fB\-s\fR|\fB\-\-silent\fR] [\fB\-v\fR|\fB\-\-verbose\fR] [\fB\-d\fR|\fB\-\-debug\fR] [\fB\-k\fR|\fB\-\-keep\fR] [\fB\-D\fR|\fB\-\-define\fR \fIname\fR=\fIvalue\fR] \fIpackage\fR \fIcommand\fR [\fIcommand\fR ...]
137 .PP
138 \&\fB\f(CB@l_prefix\fB@/bin/openpkg rc\fR \fB\-p\fR|\fB\-\-print\fR \fIpackage\fR \fIcommand\fR [\fIcommand\fR ...]
139 .PP
140 eval `\fB\f(CB@l_prefix\fB@/bin/openpkg rc\fR \fB\-e\fR|\fB\-\-eval\fR \fIpackage\fR \fIcommand\fR [\fIcommand\fR ...]`
141 .PP
142 \&\fB\f(CB@l_prefix\fB@/bin/openpkg rc\fR \fB\-q\fR|\fB\-\-query\fR \fIvariable\fR [\fIvariable\fR ...]
143 .PP
144 \&\fB\f(CB@l_prefix\fB@/bin/openpkg rc\fR \fB\-c\fR|\fB\-\-config\fR
145 .PP
146 \&\fB\f(CB@l_prefix\fB@/bin/openpkg rc\fR \fB\-h\fR|\fB\-\-help\fR
147 .SH "DESCRIPTION"
148 .IX Header "DESCRIPTION"
149 The \fB\f(CB@l_prefix\fB@/bin/openpkg rc\fR program is the run-command (rc) processor
150 of the \fBOpenPKG\fR instance \f(CW\*(C`@l_prefix@\*(C'\fR. It allows querying the rc
151 configuration variables and the execution of rc command scripts of one
152 or more installed \fBOpenPKG\fR packages. The implemented run-command
153 facility is partly modeled after the classical \s-1UNIX\s0(tm) System V
154 run-command facility plus ideas taken from the FreeBSD and NetBSD
155 run-command facilities. It mainly merges the classical startup/shutdown
156 procedures with periodical procedures into a single approach.
157 .SH "USAGE"
158 .IX Header "USAGE"
159 .ie n .IP "\fB\fB@l_prefix\fB@/bin/openpkg rc\fR [\fB\-s\fR|\fB\-\-silent\fR] [\fB\-v\fR|\fB\-\-verbose\fR] [\fB\-d\fR|\fB\-\-debug\fR] [\fB\-k\fR|\fB\-\-keep\fR] [\fB\-D\fR|\fB\-\-define\fR \fIname\fR=\fIvalue\fR] \fIpackage\fR \fIcommand\fR [\fIcommand\fR ...]" 4
160 .el .IP "\fB\f(CB@l_prefix\fB@/bin/openpkg rc\fR [\fB\-s\fR|\fB\-\-silent\fR] [\fB\-v\fR|\fB\-\-verbose\fR] [\fB\-d\fR|\fB\-\-debug\fR] [\fB\-k\fR|\fB\-\-keep\fR] [\fB\-D\fR|\fB\-\-define\fR \fIname\fR=\fIvalue\fR] \fIpackage\fR \fIcommand\fR [\fIcommand\fR ...]" 4
161 .IX Item "@l_prefix@/bin/openpkg rc [-s|--silent] [-v|--verbose] [-d|--debug] [-k|--keep] [-D|--define name=value] package command [command ...]"
162 \&\fBRun-Command Execution.\fR This executes one or more specified
163 \&\fIcommand\fRs in a particular \fIpackage\fR or in all installed packages if
164 \&\fIpackage\fR is "\f(CW\*(C`all\*(C'\fR". Option \fB\-\-silent\fR can be used to explicitly
165 disable progress messages on \f(CW\*(C`stderr\*(C'\fR. Option \fB\-\-verbose\fR can be used
166 to explicitly enable progress messages on \f(CW\*(C`stderr\*(C'\fR. By default, \fBrc\fR
167 automatically determines whether progress messages should be displayed
168 or not depending on whether \f(CW\*(C`stderr\*(C'\fR is connected to a terminal device.
169 Option \fB\-\-keep\fR can be used for debugging purposes to keep the
170 temporary files were generated during internal processing. Option
171 \&\fB\-\-define\fR can be used to on-the-fly re-define a configuration variable
172 \&\fIname\fR with \fIvalue\fR.
173 .ie n .IP "\fB\fB@l_prefix\fB@/bin/openpkg rc\fR \fB\-p\fR|\fB\-\-print\fR \fIpackage\fR \fIcommand\fR [\fIcommand\fR ...]" 4
174 .el .IP "\fB\f(CB@l_prefix\fB@/bin/openpkg rc\fR \fB\-p\fR|\fB\-\-print\fR \fIpackage\fR \fIcommand\fR [\fIcommand\fR ...]" 4
175 .IX Item "@l_prefix@/bin/openpkg rc -p|--print package command [command ...]"
176 \&\fBRun-Command Printing.\fR This is like the run-command execution (see
177 above), but instead of immediately executing all involved individual
178 run-command scripts, they are concatenated (but with all configuration
179 parts reduced to a single configuration part) and printed to \f(CW\*(C`stdout\*(C'\fR.
180 Use this for debugging or post-processing purposes.
181 .ie n .IP "eval `\fB\fB@l_prefix\fB@/bin/openpkg rc\fR \fB\-e\fR|\fB\-\-eval\fR \fIpackage\fR \fIcommand\fR [\fIcommand\fR ...]`" 4
182 .el .IP "eval `\fB\f(CB@l_prefix\fB@/bin/openpkg rc\fR \fB\-e\fR|\fB\-\-eval\fR \fIpackage\fR \fIcommand\fR [\fIcommand\fR ...]`" 4
183 .IX Item "eval `@l_prefix@/bin/openpkg rc -e|--eval package command [command ...]`"
184 \&\fBRun-Command Evaluation.\fR This is like the run-command execution
185 (see above), but the resulting exported shell environment variables
186 are output to a temporary file as a (Bourne-Shell or C\-Shell syntax)
187 shell script, suitable for evaluation within the shell environment
188 of the caller. A one-line script is printed to \f(CW\*(C`stdout\*(C'\fR which then
189 \&\*(L"sources\*(R" (and immediately removes) this temporary file. This is
190 slightly different from printing the temporary script directly to
191 \&\f(CW\*(C`stdout\*(C'\fR, because not all shell implementations like to "\fBeval\fR\*(L"
192 large multi-line scripts. Hence, use this for executing the \*(R"\f(CW\*(C`env\*(C'\fR"
193 run-commands within the current shell.
194 .ie n .IP "\fB\fB@l_prefix\fB@/bin/openpkg rc\fR \fB\-q\fR|\fB\-\-query\fR \fIvariable\fR [\fIvariable\fR ...]" 4
195 .el .IP "\fB\f(CB@l_prefix\fB@/bin/openpkg rc\fR \fB\-q\fR|\fB\-\-query\fR \fIvariable\fR [\fIvariable\fR ...]" 4
196 .IX Item "@l_prefix@/bin/openpkg rc -q|--query variable [variable ...]"
197 \&\fBConfiguration Variable Querying.\fR This queries the effective values
198 (see \fBRUN-COMMAND \s-1CONFIGURATION\s0\fR section below) of one or more
199 run-command configuration \fIvariable\fRs. Use this within a shell script
200 to selectively query a particular variable.
201 .ie n .IP "\fB\fB@l_prefix\fB@/bin/openpkg rc\fR \fB\-c\fR|\fB\-\-config\fR" 4
202 .el .IP "\fB\f(CB@l_prefix\fB@/bin/openpkg rc\fR \fB\-c\fR|\fB\-\-config\fR" 4
203 .IX Item "@l_prefix@/bin/openpkg rc -c|--config"
204 \&\fBConfiguration Variable Summary.\fR This displays on \f(CW\*(C`stdout\*(C'\fR a
205 three-column table showing the name, default and effective values of
206 all run-command configuration variables. If \f(CW\*(C`stdout\*(C'\fR is connected to
207 terminal device, variables where the default and effective values differ
208 are shown in bold mode.
209 .ie n .IP "\fB\fB@l_prefix\fB@/bin/openpkg rc\fR \fB\-h\fR|\fB\-\-help\fR" 4
210 .el .IP "\fB\f(CB@l_prefix\fB@/bin/openpkg rc\fR \fB\-h\fR|\fB\-\-help\fR" 4
211 .IX Item "@l_prefix@/bin/openpkg rc -h|--help"
212 \&\fBRequesting Help.\fR This just displays a short summary of
213 the usage for this program.
214 .SH "FILES"
215 .IX Header "FILES"
216 .ie n .SS "RUN-COMMAND \s-1FILES\s0 (\*(C`@l_prefix@/bin/openpkg rc.d/rc.*\*(C')"
217 .el .SS "RUN-COMMAND \s-1FILES\s0 (\f(CW\*(C`@l_prefix@/bin/openpkg rc.d/rc.*\*(C'\fP)"
218 .IX Subsection "RUN-COMMAND FILES (@l_prefix@/bin/openpkg rc.d/rc.*)"
219 The foundation of the \fBOpenPKG\fR run-command facility are the individual
220 run-command files \f(CW\*(C`rc.*\*(C'\fR of the installed packages. They are all
221 located in the directory \f(CW\*(C`@l_prefix@/bin/openpkg rc.d/\*(C'\fR and are named
222 "\f(CW\*(C`rc.\*(C'\fR\fIpackage\fR\*(L". They consist of one or more sections, each starting
223 with a section header \*(R"\f(CW\*(C`%\*(C'\fR\fIname\fR [\fIoptions\fR]" and following a \s-1GNU\s0
224 Bash compatible shell script. There are three classes of sections:
225 .IP "\fBSpecial Sections\fR" 4
226 .IX Item "Special Sections"
227 There are 2 sections which have a special meaning to the \fBrc\fR program
228 and cannot be used for different purposes.
229 .RS 4
230 .ie n .IP "%config" 4
231 .el .IP "\f(CW%config\fR" 4
232 .IX Item "%config"
233 This section has to consist of run-command configuration
234 variable default settings in Bourne-Shell syntax only, i.e.,
235 it has to contain one or more lines, each of exactly the form
236 "\fIpackage\fR\f(CW\*(C`_\*(C'\fR\fIvariable\fR\f(CW\*(C`=\*(C'\fR\fIvalue\fR\*(L". Notice that in section
237 \&\*(R"\f(CW%config\fR\*(L" of run-command file \*(R"\f(CW\*(C`rc.foo\*(C'\fR\*(L" the variables all have
238 to be prefixed (by convention) with \*(R"\f(CW\*(C`foo_\*(C'\fR". It is allowed that the
239 \&\fIvalue\fRs reference other variables defined before in the same section
240 or from the "\f(CW%config\fR\*(L" section of the bootstrap package \*(R"\f(CW\*(C`openpkg\*(C'\fR".
241 Additionally, by convention all lines have to be indented by 4 spaces.
242 .Sp
243 \&\s-1NOTICE:\s0 All sections of all run-command scripts see all \f(CW%config\fR
244 sections of all packages.
245 .ie n .IP "%common" 4
246 .el .IP "\f(CW%common\fR" 4
247 .IX Item "%common"
248 This section can consist of an arbitrary shell script
249 which is automatically prepended to the shell scripts
250 of all other sections on execution. It is usually used
251 to define common and local variables and functions.
252 .RE
253 .RS 4
254 .RE
255 .IP "\fBConventional Sections\fR" 4
256 .IX Item "Conventional Sections"
257 There are 9 sections which have no special meaning to the \fBrc\fR program,
258 but are used in \fBOpenPKG\fR by convention for standard purposes. Hence,
259 do not use them for arbitrary things instead.
260 .Sp
261 Throughout these sections it is possible to specify the user to be
262 switched to before the code is executed.
263 .Sp
264 A priority can be given for each section to control execution sequence
265 if "\f(CW\*(C`all\*(C'\fR" packages are given. Higher priority leads to earlier
266 starting and later stopping. The priority is a number where low numbers
267 mean high priority (numerically sorted for starting). If omitted, the
268 priority defaults to 500.
269 .Sp
270 Output generated on \fIstdout\fR and \fIstderr\fR is captured and normally
271 suppressed. In case the sections script exits with a non-zero return
272 value, the intercepted messages are consolidated, reformatted with a
273 surrounding ASCII-art border and printed to \fIstderr\fR. If the section
274 is tagged with option \fB\-o\fR, \fIstdout\fR messages are passed through
275 verbatim, even if the section script exists with a zero return value.
276 .RS 4
277 .ie n .IP "%start [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
278 .el .IP "\f(CW%start\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
279 .IX Item "%start [-u user] [-p priority]"
280 This section should start daemons or initialize components.
281 It is especially executed by \fBOpenPKG\fR during system startup.
282 .ie n .IP "%stop [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
283 .el .IP "\f(CW%stop\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
284 .IX Item "%stop [-u user] [-p priority]"
285 This section should stop daemons or cleaning up components. It is
286 especially executed by \fBOpenPKG\fR during system shutdown and package
287 deinstallation.
288 .ie n .IP "%restart [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
289 .el .IP "\f(CW%restart\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
290 .IX Item "%restart [-u user] [-p priority]"
291 This section should restart daemons.
292 It is especially executed by \fBOpenPKG\fR during package upgrades.
293 .ie n .IP "\*(C`%status \-o\*(C' [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
294 .el .IP "\f(CW\*(C`%status \-o\*(C'\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
295 .IX Item "%status -o [-u user] [-p priority]"
296 This section has to provide status information for a package
297 by printing to \f(CW\*(C`stdout\*(C'\fR (hence the \fB\-o\fR option is always required),
298 in Bourne-Shell syntax, the definition of three variables:
299 .RS 4
300 .ie n .IP "\fIpackage\fR\*(C`_enable\*(C'" 4
301 .el .IP "\fIpackage\fR\f(CW\*(C`_enable\*(C'\fR" 4
302 .IX Item "package_enable"
303 Whether package is enabled, i.e., whether it accepts run-commands. This
304 variable just has to be printed, because is already set in current
305 script environment.
306 .ie n .IP "\fIpackage\fR\*(C`_usable\*(C'" 4
307 .el .IP "\fIpackage\fR\f(CW\*(C`_usable\*(C'\fR" 4
308 .IX Item "package_usable"
309 Whether package is usable, i.e., whether it is already correctly
310 configured, etc. This variable has to be individually determined.
311 .ie n .IP "\fIpackage\fR\*(C`_active\*(C'" 4
312 .el .IP "\fIpackage\fR\f(CW\*(C`_active\*(C'\fR" 4
313 .IX Item "package_active"
314 Whether package is active, i.e., whether it is already running.
315 This variable has to be individually determined.
316 .RE
317 .RS 4
318 .RE
319 .ie n .IP "%monthly [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
320 .el .IP "\f(CW%monthly\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
321 .IX Item "%monthly [-u user] [-p priority]"
322 .PD 0
323 .ie n .IP "%weekly [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
324 .el .IP "\f(CW%weekly\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
325 .IX Item "%weekly [-u user] [-p priority]"
326 .ie n .IP "%hourly [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
327 .el .IP "\f(CW%hourly\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
328 .IX Item "%hourly [-u user] [-p priority]"
329 .ie n .IP "%quarterly [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
330 .el .IP "\f(CW%quarterly\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
331 .IX Item "%quarterly [-u user] [-p priority]"
332 .PD
333 These sections should perform periodical tasks for a package and
334 are executed on a monthly, weekly, hourly or quarterly basis.
335 .ie n .IP "%env" 4
336 .el .IP "\f(CW%env\fR" 4
337 .IX Item "%env"
338 This section is intended to export one or more environment variables
339 which are imported into the shell environment of the caller through the
340 \&\fB\-\-eval\fR command line option.
341 .RE
342 .RS 4
343 .RE
344 .IP "\fBCustom Sections\fR" 4
345 .IX Item "Custom Sections"
346 All other sections are custom ones and can be fully individual to each
347 package. Some often seen sections are \f(CW%reload\fR (just reload the
348 configuration without full stop and start procedure), \f(CW%info\fR (output
349 arbitrary information about package), etc.
350 .ie n .SS "RUN-COMMAND \s-1CONFIGURATION\s0 (\*(C`@l_prefix@/bin/openpkg rc.conf\*(C')"
351 .el .SS "RUN-COMMAND \s-1CONFIGURATION\s0 (\f(CW\*(C`@l_prefix@/bin/openpkg rc.conf\*(C'\fP)"
352 .IX Subsection "RUN-COMMAND CONFIGURATION (@l_prefix@/bin/openpkg rc.conf)"
353 The run-command configuration variables defined in the "\f(CW%config\fR"
354 sections of all installed packages can be overridden by the
355 administrator in the global file \f(CW\*(C`@l_prefix@/bin/openpkg rc.conf\*(C'\fR. This file is
356 usually empty, but can be filled with Bourne-Shell compatible variable
357 assignment statements like "\fIpackage\fR\f(CW\*(C`_\*(C'\fR\fIvariable\fR=\fIvalue\fR".
358 .ie n .SS "RUN-COMMAND \s-1FUNCTIONS\s0 (\*(C`@l_prefix@/bin/openpkg rc.func\*(C')"
359 .el .SS "RUN-COMMAND \s-1FUNCTIONS\s0 (\f(CW\*(C`@l_prefix@/bin/openpkg rc.func\*(C'\fP)"
360 .IX Subsection "RUN-COMMAND FUNCTIONS (@l_prefix@/bin/openpkg rc.func)"
361 The file \f(CW\*(C`@l_prefix@/bin/openpkg rc.func\*(C'\fR is prepended to the scripts of all
362 executed run-command sections and provides reusable functions.
363 Currently the following functions are defined:
364 .IP "\fBrcMsg\fR [\fB\-e\fR] [\fB\-w\fR] \fImessage\fR" 4
365 .IX Item "rcMsg [-e] [-w] message"
366 Print a message to the output device of the run-command caller. The
367 message is printed to the captured \fIstderr\fR (but are visible to
368 the caller of the run-command script only if the script fails). All
369 messages are prefixed with "\f(CW\*(C`rc:\*(C'\fR". If option \fB\-e\fR is given, the
370 prefix is "\f(CW\*(C`rc:ERROR:\*(C'\fR". If option \fB\-w\fR is given, the prefix is
371 "\f(CW\*(C`rc:WARNING:\*(C'\fR".
372 .IP "\fBrcPath\fR [\fB\-a\fR] [\fB\-r\fR] [\fB\-p\fR] [\fB\-e\fR] \fIvariable\fR \fIdir\fR [\fIdir\fR ...]" 4
373 .IX Item "rcPath [-a] [-r] [-p] [-e] variable dir [dir ...]"
374 Add (option \fB\-a\fR) or remove (option \fB\-r\fR) one or more \fIdir\fRectories
375 to/from the colon-separated value of a \fIvar\fRable. By default, on
376 addition, the directory is appended to the end, if option \fB\-p\fR is used
377 the directory is prepended to the start. If option \fB\-e\fR is used, the
378 directories are added only if they exist on the underlying filesystem.
379 Use this function for conveniently manipulating \f(CW\*(C`PATH\*(C'\fR, \f(CW\*(C`MANPATH\*(C'\fR,
380 \&\f(CW\*(C`INFOPATH\*(C'\fR, \f(CW\*(C`LD_LIBRARY_PATH\*(C'\fR and similar variables.
381 .IP "\fBrcTmp\fR [\fB\-i\fR] [\fB\-f\fR] [\fB\-n\fR \fIname\fR] [\fB\-k\fR]" 4
382 .IX Item "rcTmp [-i] [-f] [-n name] [-k]"
383 Convenience interface to secure temporary file handling. Option \fB\-i\fR
384 first has to be used to initialize a secure temporary directory (option
385 \&\fB\-k\fR later will kill this again). Under option \fB\-f\fR you then can get
386 reasonable temporary filenames under the created temporary directory. By
387 default, the temporary filename is just "\f(CW\*(C`tmp\*(C'\fR", but can be specified
388 with option \fB\-n\fR to be \fIname\fR.
389 .IP "\fBrcService\fR \fIpackage\fR \fIstatus\fR \fIvalue\fR" 4
390 .IX Item "rcService package status value"
391 Convenience interface to checking the \f(CW%status\fR variables
392 \&\fIpackage\fR\f(CW\*(C`_\*(C'\fR\fIstatus\fR which have to be provided by the \f(CW%config\fR (if
393 \&\fIstatus\fR is "\f(CW\*(C`enable\*(C'\fR" this is enough) and \f(CW%status\fR (if \fIstatus\fR is
394 "\f(CW\*(C`enable\*(C'\fR\*(L", \*(R"\f(CW\*(C`usable\*(C'\fR\*(L" and \*(R"\f(CW\*(C`active\*(C'\fR"). The \fBrcService\fR especially
395 caches the resolving of the variable values. Returns 0 if the resolved
396 value is \fIvalue\fR, else returns 1.
397 .IP "\fBrcVarIsYes\fR \fIname\fR" 4
398 .IX Item "rcVarIsYes name"
399 Checks whether variable \fIname\fR has a value of "\f(CW\*(C`yes\*(C'\fR\*(L", \*(R"\f(CW\*(C`true\*(C'\fR\*(L",
400 \&\*(R"\f(CW\*(C`on\*(C'\fR\*(L", or \*(R"\f(CW1\fR" (with arbitrary lower or upper case letters). Returns
401 0 if value is one of these positive ones, else returns 1.
402 .SH "EXAMPLES"
403 .IX Header "EXAMPLES"
404 First, an example run-command script \f(CW\*(C`@l_prefix@/bin/openpkg rc.d/rc.foo\*(C'\fR for a
405 fictional daemon package "\f(CW\*(C`foo\*(C'\fR":
406 .PP
407 .Vb 8
408 \& %config
409 \& foo_enable="${openpkg_rc_def}"
410 \& foo_listen="127.0.0.1"
411 \& foo_log_prolog="true"
412 \& foo_log_epilog="true"
413 \& foo_log_numfiles="10"
414 \& foo_log_minsize="1M"
415 \& foo_log_complevel="9"
416 \&
417 \& %common
418 \& foo_homedir="@l_prefix@/share/foo"
419 \& foo_cfgfile="@l_prefix@/etc/foo/foo.cfg"
420 \& foo_pidfile="@l_prefix@/var/foo/foo.pid"
421 \& foo_logfile="@l_prefix@/var/foo/foo.log"
422 \& foo_signal () {
423 \& if [ \-f ${foo_pidfile} ]; then
424 \& kill \-$1 \`cat ${foo_pidfile}\`
425 \& return $?
426 \& else
427 \& return 1
428 \& fi
429 \& }
430 \&
431 \& %status
432 \& foo_usable="no"
433 \& if [ ".\`grep \*(Aq<<PASSWORD>>\*(Aq ${foo_cfgfile}\`" = . ]; then
434 \& foo_usable="yes"
435 \& fi
436 \& foo_active="no"
437 \& if [ \-f ${foo_pidfile} ]; then
438 \& foo_signal 0
439 \& if [ $? \-eq 0 ]; then
440 \& foo_active="yes"
441 \& fi
442 \& fi
443 \& echo "foo_enable=${foo_enable}"
444 \& echo "foo_usable=${foo_usable}"
445 \& echo "foo_active=${foo_active}"
446 \&
447 \& %start
448 \& rcService foo enable yes || exit 0
449 \& rcService foo active yes && exit 0
450 \& @l_prefix@/sbin/foo \-\-listen ${foo_listen}
451 \&
452 \& %stop
453 \& rcService foo enable yes || exit 0
454 \& rcService foo active yes || exit 0
455 \& foo_signal TERM
456 \&
457 \& %restart
458 \& rcService foo enable yes || exit 0
459 \& rcService foo active yes || exit 0
460 \& rc foo stop start
461 \&
462 \& %daily
463 \& rcService foo enable yes || exit 0
464 \& shtool rotate \-f \e
465 \& \-n ${foo_log_numfiles} \-s ${foo_log_minsize} \-d \e
466 \& \-z ${foo_log_complevel} \-o @l_rusr@ \-g @l_rgrp@ \-m 644 \e
467 \& \-P "${foo_log_prolog}" \-E "${foo_log_epilog}" \e
468 \& ${foo_logfile}
469 \&
470 \& %env
471 \& if rcService foo enable yes; then
472 \& FOO_HOME="$foo_homedir"
473 \& export FOO_HOME
474 \& fi
475 .Ve
476 .PP
477 Now, show all run-command configuration variables, their
478 default values and their effective values of package "\f(CW\*(C`foo\*(C'\fR":
479 .PP
480 .Vb 1
481 \& $ @l_prefix@/bin/openpkg rc \-\-config | grep "^foo_"
482 .Ve
483 .PP
484 Override the default value of a run-command configuration
485 variable \f(CW\*(C`foo_listen\*(C'\fR:
486 .PP
487 .Vb 1
488 \& $ echo \*(Aqfoo_listen="192.168.0.1"\*(Aq >>@l_prefix@/bin/openpkg rc.conf
489 .Ve
490 .PP
491 Stop and start from scratch the package "\f(CW\*(C`foo\*(C'\fR":
492 .PP
493 .Vb 1
494 \& $ @l_prefix@/bin/openpkg rc foo stop start
495 .Ve
496 .PP
497 Query the effective value of run-command configuration
498 variable \f(CW\*(C`foo_enable\*(C'\fR in a script:
499 .PP
500 .Vb 1
501 \& if [ ".\`@l_prefix@/bin/openpkg rc \-q foo_enable\`" = .yes ]; then ...
502 .Ve
503 .PP
504 Import all environment settings from all (including "\f(CW\*(C`foo\*(C'\fR") installed
505 packages into the current Bourne-Shell environment:
506 .PP
507 .Vb 2
508 \& $ eval \`@l_prefix@/bin/openpkg rc \-\-eval all env\`
509 \& $ echo $FOO_HOME
510 .Ve
511 .SH "SEE ALSO"
512 .IX Header "SEE ALSO"
513 \&\fBOpenPKG\fR http://www.openpkg.org/
514 .SH "HISTORY"
515 .IX Header "HISTORY"
516 The \fBOpenPKG\fR run-command facility consisting of the scripts \f(CW\*(C`rc\*(C'\fR
517 and \f(CW\*(C`rc.func\*(C'\fR were originally invented in November 2000 by Ralf S.
518 Engelschall for \fBOpenPKG\fR. They were completely worked off from scratch
519 in July 2003 for \fBOpenPKG 1.3\fR.
520 .SH "AUTHOR"
521 .IX Header "AUTHOR"
522 .Vb 3
523 \& Ralf S. Engelschall
524 \& rse@engelschall.com
525 \& www.engelschall.com
526 .Ve