openpkg/rc.8

Thu, 22 Mar 2012 21:51:36 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Mar 2012 21:51:36 +0100
changeset 412
577aba7f4106
child 427
71503088f51b
permissions
-rw-r--r--

Substitute unknown paths in new patch sections.

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

mercurial