head 1.45; access; symbols OSSP_RC_0_7_3:1.45 OSSP_RC_0_7_2:1.45 OSSP_RC_0_7_1:1.44 OSSP_RC_ALPHA_06:1.31 OSSP_RC_EXBROKEN:1.31 OSSP_RC_SPEC:1.26; locks; strict; comment @# @; 1.45 date 2003.07.09.10.21.21; author thl; state Exp; branches; next 1.44; 1.44 date 2003.07.07.12.55.42; author ms; state Exp; branches; next 1.43; 1.43 date 2003.06.26.18.45.14; author ms; state Exp; branches; next 1.42; 1.42 date 2003.06.23.17.22.41; author ms; state Exp; branches; next 1.41; 1.41 date 2003.06.23.17.11.28; author ms; state Exp; branches; next 1.40; 1.40 date 2003.06.23.17.08.20; author ms; state Exp; branches; next 1.39; 1.39 date 2003.06.23.17.06.44; author ms; state Exp; branches; next 1.38; 1.38 date 2003.06.23.16.55.05; author ms; state Exp; branches; next 1.37; 1.37 date 2003.06.23.16.44.55; author ms; state Exp; branches; next 1.36; 1.36 date 2003.06.23.15.46.05; author ms; state Exp; branches; next 1.35; 1.35 date 2003.06.23.14.53.10; author ms; state Exp; branches; next 1.34; 1.34 date 2003.06.23.14.46.33; author ms; state Exp; branches; next 1.33; 1.33 date 2003.06.23.14.43.48; author ms; state Exp; branches; next 1.32; 1.32 date 2003.06.23.11.29.44; author ms; state Exp; branches; next 1.31; 1.31 date 2003.05.21.12.49.20; author ms; state Exp; branches; next 1.30; 1.30 date 2002.04.11.16.52.45; author ms; state Exp; branches; next 1.29; 1.29 date 2002.03.01.22.48.23; author ms; state Exp; branches; next 1.28; 1.28 date 2002.02.28.15.30.04; author ms; state Exp; branches; next 1.27; 1.27 date 2002.02.04.22.35.20; author ms; state Exp; branches; next 1.26; 1.26 date 2002.01.31.21.14.10; author ms; state Exp; branches; next 1.25; 1.25 date 2002.01.31.10.11.43; author ms; state Exp; branches; next 1.24; 1.24 date 2002.01.30.22.55.26; author ms; state Exp; branches; next 1.23; 1.23 date 2002.01.29.15.35.05; author ms; state Exp; branches; next 1.22; 1.22 date 2002.01.29.09.14.38; author ms; state Exp; branches; next 1.21; 1.21 date 2002.01.29.08.42.20; author ms; state Exp; branches; next 1.20; 1.20 date 2002.01.29.07.31.11; author ms; state Exp; branches; next 1.19; 1.19 date 2002.01.28.16.01.23; author ms; state Exp; branches; next 1.18; 1.18 date 2002.01.28.14.30.04; author ms; state Exp; branches; next 1.17; 1.17 date 2002.01.28.14.25.47; author ms; state Exp; branches; next 1.16; 1.16 date 2002.01.28.12.08.13; author ms; state Exp; branches; next 1.15; 1.15 date 2002.01.23.15.36.05; author ms; state Exp; branches; next 1.14; 1.14 date 2002.01.23.14.58.51; author ms; state Exp; branches; next 1.13; 1.13 date 2002.01.23.13.44.50; author ms; state Exp; branches; next 1.12; 1.12 date 2002.01.23.13.40.54; author ms; state Exp; branches; next 1.11; 1.11 date 2002.01.23.13.31.20; author ms; state Exp; branches; next 1.10; 1.10 date 2002.01.23.13.29.21; author ms; state Exp; branches; next 1.9; 1.9 date 2002.01.23.13.10.39; author ms; state Exp; branches; next 1.8; 1.8 date 2002.01.23.13.09.20; author ms; state Exp; branches; next 1.7; 1.7 date 2002.01.22.20.10.27; author ms; state Exp; branches; next 1.6; 1.6 date 2002.01.22.18.00.59; author ms; state Exp; branches; next 1.5; 1.5 date 2002.01.21.18.14.54; author ms; state Exp; branches; next 1.4; 1.4 date 2002.01.18.16.47.53; author ms; state Exp; branches; next 1.3; 1.3 date 2002.01.17.15.47.10; author ms; state Exp; branches; next 1.2; 1.2 date 2002.01.06.12.40.50; author openpkg-cvs; state Exp; branches; next 1.1; 1.1 date 2002.01.04.22.32.04; author openpkg-cvs; state Exp; branches; next ; desc @@ 1.45 log @put top topics in first paragraph @ text @## ## rc.pod -- OSSP Run-command Processor (manual page) ## Copyright (c) 2002-2003 Cable & Wireless Deutschland GmbH ## Copyright (c) 2002-2003 The OSSP Project ## Copyright (c) 2002-2003 Ralf S. Engelschall ## ## Permission to use, copy, modify, and distribute this software for ## any purpose with or without fee is hereby granted, provided that ## the above copyright notice and this permission notice appear in all ## copies. ## ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ## SUCH DAMAGE. ## =pod =head1 NAME B - OSSP Run-command Processor =head1 SYNOPSIS B [B<-?>|B<--usage>] [B<-D>|B<--debug>] [B<-L>|B<--locate> I[C<:>I[...]]] [B<-V>|B<--version>] [B<-c>|B<--conf> I[C<:>I[...]]] [B<-e>|B<--eval>] [B<-f>|B<--func> I[C<:>I[...]]] [B<-h>|B<--help>] [B<-i>|B<--info>] [B<-l>|B<--labels>] [B<-p>|B<--print>] [B<-q>|B<--query>] I [B<-s>|B<--silent>] [B<-r>|B<--raw>] [B<-t>|B<--tmp> I] [B<-v>|B<--verbose>] [B<-x>|B<--exec>] [B<--RequireUmask umask>] [B<--RequireOwner uid|name>] [B<--RequireGroup gid|name>] [B<--ParseEnvAss regex>] [B<--ParseSectionDef regex>] [B<--ParseSectionRef regex>] [B<--ParseSectionParam regex>] [B<--ParseTerminal regex>] [B<--NameConfig> name] [B<--NameCommon> name] [B<--NameDefault> name] [B<--NameError> name] I<> I<> =head1 DESCRIPTION OSSP rc is a run-command processor. Its primary function is to assemble a temporary file from excerpts of Fs which are built out of text snippets grouped into B
s. The user specifies the desired parts to use and also controls the order of assembly. OSSP rc defaults to Bute the concatenated temporary file, but it can also B it in human readable format or create shell instructions suitable for the calling shell to Buate the temporary file. The Fs contain variables and the command processor has functionality to B their default, set and effective values. The structure of the Fs is simple but the syntax is highly configurable. Included B
s are labeled for identification by the user, while rc uses regular expressions to identifiy their boundaries. The default regular expression leads to identification of section text starting with a percent (%) and any subsequent text until a whitespace identifies the label. Various examples are listed below. Often, only a single B is processed. To process all Bs, substitute the keyword 'all' for the B name. This convenience inhibits 'all' being used as a file name. =head1 OPTIONS =over 4 =item B<-?>|B<--usage> print short usage summary, then exit. =item B<-D>|B<--debug> do not remove temporary files, and output debug messages to stderr. =item B<-L>|B<--locate> I[C<:>I] locations to search for Fs where I can contain regex patterns to filter files. The trailing part (after the ':') is a regex filter used to ignore parts of a file. This option can be specified more than once. =item B<-V>|B<--version> print version and copyright, then exit. =item B<-c>|B<--conf> I[C<:>I[...]] specify the location of the configuration file. If omitted, C<$OSSP_RC_CONF> will be examined. If absent, F will be used. If no F exists at all, then only command line and environment specified options will override B's default values. =item B<-e>|B<--eval> output the commands text in a format suitable for shell evaluation, but do not run it. =item B<-f>|B<--func> I[C<:>I[...]] specify the location of one or more optional function files. They act like libraries, containing commands which are prepended to the sections of their corresponding Fs just before execution. =item B<-h>|B<--help> print help, then exit. =item B<-i>|B<--info> print a comprehensive summary of the rc configuration. =item B<-l>|B<--labels> learn what section labels a F offers. =item B<-p>|B<--print> output the commands text in a format suitable for human reading, but do not run it. =item B<-q>|B<--query> I query the effective value of configuration variables from the %config section and print them using the I string specified in RPM style. =item B<-r>|B<--raw> output text using no terminal control sequences. The rc facility usually tries to improve output text for human readability using terminal control sequences for color, bold and italic rendering. The default is determined at runtime and is automagically disabled if stdout is detached from a terminal. =item B<-s>|B<--silent> be silent, and disable output. =item B<-t>|B<--tmp> I specify the location of the temporary directory. If omitted, the fallback is to look for C<$TMPDIR>, C<$TMPDIR>, try using C<~/tmp> and C, in that order. =item B<-v>|B<--verbose> be verbose, output what is going on. =item B<-x>|B<--exec> execute the command interpreter in a subprocess and actually run the commands. If neither B<--print>, B<--eval>, or B<­-exec> is given, the default is B<--exec> anyway. =item B<--RequireUmask umask> umask a F has to have, otherwise it is ignored. =item B<--RequireOwner uid|name> owner of the F must match uid|name, otherwise it is ignored. =item B<--RequireGroup gid|name> group of the F must match gid|name, otherwise it is ignored. =item B<--ParseConfigAss regex> regex matching the variable assignments in a F. =item B<--ParseSectionDef regex> regex matching a section label in a F. =item B<--ParseSectionRef regex> regex matching a reference in a F. =item B<--ParseSectionParam regex> regex matching a section parameter in a F. =item B<--ParseTerminal regex> regex matching a terminal symbol in a F. See LANGUAGE. =item B<--NameConfig> name name of the config section, defaults to %config. =item B<--NameCommon> name name of the common section, defaults to %common. =item B<--NameDefault> name name of the default section, defaults to %default. =item B<--NameError> name name of the error section, defaults to %error. =back =head1 OPTIONS ORDERING B reads its options from three sources and builds a global configuration which it uses when later processing Fs and B
s. The first source used is the F file (see SEE ALSO). Next, B reads options from the environment (see ENVIRONMENT). Finally, it reads options from the command line. Of course, this means that any option given on the command line overrides that of the other two sources. This allows for flexibility when wishing to set a standard set of OSSP rc options, and override them conditionally. Some option values are mandatory, and if they do not exist in any of the three sources then B supplies a default value. The global configuration being used at any moment can be learned by using the --info switch. =head1 ENVIRONMENT The environment may contain options variables and values as well. Such variable names must begin with 'OSSP_RC_' and follow with a long option name. The value assigned to a environment variable indicates the processing behaviour of B just as it would if given on the command line or in the F file. =head1 COMMAND INTERPRETER As long as a valid interpreter path is specified in the section labels of a F, the run-commands resulting from a --eval, --exec, or --print operation can be written in any runtime-interpreted language. This means that a perl programmer can write run-commands in perl, and specify the perl interpreter path in the corresponding section label of the F. A different programming language can be used for each section, even though this would complicate inclusion of script from the B<%common> section and F sections (because each section is associated with only one interpreter). If the command interpreter in a section label is not specified, then the Bourne shell will be used by default. =head1 RETURN VALUE 0 Success 1 Failure A non-zero return value signals failure, and may indicate such error states as an illegal combination of options or nonexisting locations directory. =head1 ERROR HANDLING Fine-tuned error handling is possible by writing one or both of the following section labels into an F. These sections typically reference the local F's variables ${rc_errcode} and ${rc_errstring} for more information about which error was encountered and its text. B<%error> If an error condition arises during an F's processing, control will pass to the B<%error> section whose commands will begin to run. Should no such B<%error> section exist, rc will stop processing and write error strings to the console and syslog using LOG_USER and LOG_ERR (see syslog(3)). An empty B<%error> section in each F will cause errors to be ignored. In any case of error however, rcfile processing will stop. B<%default> The commands in the B<%default> section are run when the corresponding F contains no section label matching the one(s) specified on the command line. If the appropriate section label does not exist and neither does B<%default>, then nothing happens and processing silently procedes. =head1 EXAMPLES The following are one-line examples of commonly used rc commands with no arguments. Because no run mode option is specified, B will process the commands by executing them directly. /usr/local/bin/rc --info /usr/local/bin/rc --query lmtp2nntp /usr/local/bin/rc httpd reload /usr/local/bin/rc --conf /etc/rc.conf --debug smtpd stop /usr/local/bin/rc ntpd --silent start sync stop start B offers more than just command execution. In the following examples because the 'eval' run mode option is specified, B will prepare the commands by writing a composite script to a tempfile. Then B will print the file's location in a format most conveniently parsable by eval(1) or the bourne shell for evaluation. eval `/usr/local/bin/rc --eval all env` /usr/local/bin/rc --eval sendmail start | sh To read the results of a B operation without executing or evaluting the run-commands, use the 'print' run mode. /usr/local/bin/rc --print --info mico /usr/local/bin/rc --print httpd reload Arguments in the form of name=value pairs may be passed to the B given on the command line. In the F, such arguments will appear as normal configuration variables. They can be referenced as such (by default as ${myarg}). On the command line, the arguments following a section will be local to the section and unusable by the others. If a argument is needed by more than one section, then repeat its definition after each section given on the command line. /usr/local/bin/rc all start sFac="LOG_USER" # pass LOG_USER as argument to 'start' /usr/local/bin/rc lmtp2nntp start nSleep=2 # sleep for 2 seconds before returning /usr/local/bin/rc ftpd start nMax=32 # a maximum of 32 users can connect /usr/local/bin/rc rsyncd restart nSleep=4 # pause 4 seconds between start and stop /usr/local/bin/rc -rdv all stop nSleep=2 start nSleep=4 sLevel="LOG_INFO" bQuiet=1 =head1 FILES F - Master configuration file F - User defined functions library F - Postprocess variable declaration file F - Run-commands for 'foo' application =head1 SEE ALSO OSSP rc integrates concepts taken from other run-command architectures. For more information, inspect the /etc/rc? structures provided by the NetBSD, FreeBSD, Solaris, and Linux distributions. rc-sample(5). rc.conf(5). =head1 AUTHORS Ralf S. Engelschall Michael Schloh von Bennewitz Thomas Lotterer =head1 HISTORY B is a drop-in replacement for the prototype run-command facility used in OpenPKG (http://www.openpkg.org/). The prototype was a slow and less robust Bourne shell script. B is comparitively faster, more robust, and more feature rich. Its generic design and improved flexibility allows for wider range of use, and B can therefore be used in a larger variety of situations. Today, B is not exclusive to the OpenPKG project. =cut @ 1.44 log @Correct and update copyrights and source headers. @ text @d36 1 a36 1 [B<-D>|B<--debug>] d41 1 a41 1 [B<-f>|B<--func> I[C<:>I[...]]] d43 1 a43 1 [B<-i>|B<--info>] d51 1 a51 1 [B<-x>|B<--exec>] d71 10 a80 8 OSSP rc is a run-command processor. Its primary function is to scan F script files for one or more B
s and run the commands listed in each B
. The run-command processor can alternatively C the commands in human readable format or reformat them for shell C input without executing them. The F files contain variables and the command processor has functionality to query their default, set and effective values. d83 9 a91 10 configurable. A F is divided into B
s, clearly identified by applying a regular expression. The default regular expression leads to identification of section text starting with a percent (%) and label (any text). Various examples of this and other syntax possibilities is given in the manpage B. Often, only a single B name is processed. To process all Bs, substitute the keyword 'all' for the B name. The B
s of a B processed match exactly the B
s given on the command line, and even the ordering is kept. d95 2 d134 1 a134 1 print this help, then exit. d157 1 a157 1 sequences for color, bold and italic rendering. The default is determines at d228 2 d302 1 a302 1 /sbin/rc --query lmtp2nntp d304 2 a305 2 /cw/etc/rc --conf /etc/rc.conf --debug smtpd stop /opt/bin/rc ntpd --silent start sync stop start d319 1 a319 1 /opt/binbin/rc --print --info mico d330 5 a334 5 ./rc all start sFac="LOG_USER" # pass LOG_USER as argument to 'start' ./rc lmtp2nntp start nSleep=2 # sleep for 2 seconds before returning /cw/etc/rc/ ftpd start nMax=32 # a maximum of 32 users can connect /bin/rc rsyncd restart nSleep=4 # pause 4 seconds between start and stop /bin/rc -rdv all stop nSleep=2 start nSleep=4 sLevel="LOG_INFO" bQuiet=1 @ 1.43 log @Break off before fully implementing common section run ops, but after reorganization of class data, and additional member functions for section and script manipulation. @ text @d3 3 a5 3 ## Copyright (c) 2000-2002 Cable & Wireless Deutschland GmbH ## Copyright (c) 2000-2002 The OSSP Project ## Copyright (c) 2000-2002 Ralf S. Engelschall @ 1.42 log @Clean up examples and %error %default text. @ text @d117 1 a117 1 options will override the defaults built-in to OSSP rc. @ 1.41 log @Fix missing punctuation. @ text @d276 1 a276 2 =item B<%error> d284 1 a284 2 =item B<%default> d325 5 a329 5 /mybin/rc all start sFac="LOG_USER" # pass LOG_USER as an argument to 'start' /opt/bin/rc lmtp2nntp start nSleep=2 # sleep for 2 seconds before returning /cw/etc/rc/ ftpd start nMax=32 # a maximum of 32 users can connect ./rc rsyncd restart nSleep=4 # pause 4 seconds between start and stop ./rc -rdv all stop nSleep=2 start nSleep=4 sLevel="LOG_INFO" bQuiet=1 @ 1.40 log @Reduce contractions. @ text @d100 1 a100 1 do not remove temporary files, and output debug messages to stderr d110 1 a110 1 print version and copyright, then exit d131 1 a131 1 print this help, then exit d135 1 a135 1 print a comprehensive summary of the rc environment d159 1 a159 1 be silent, and disable output @ 1.39 log @Last text edit of options and their ordering. @ text @d100 1 a100 1 don't remove temporary files, and output debug messages to stderr d169 1 a169 1 be verbose, output what's going on. d179 1 a179 1 umask a F has to have, otherwise it's ignored. d183 1 a183 1 owner of the F must match uid|name, otherwise it's ignored. d187 1 a187 1 group of the F must match gid|name, otherwise it's ignored. d289 1 a289 1 command line. If the appropriate section label doesn't exist and neither does @ 1.38 log @Edit environment and command interpreter text. @ text @d225 14 a238 6 Every command line longoption corresponds to a keyword in the F file. When prefixed with 'OSSP_RC_' and its name in upper case, an option can be set as an environment variable. First, options from the F file are read. Then, options from the environment are read. Last, options from the command line are read. This allows for flexibility when wishing to set a standard set of OSSP rc options, and override them conditionally. d347 1 @ 1.37 log @Edit text on special %error and %default sections. @ text @d234 5 a238 9 The environment contains options just as the command line and F file does. An option's corresponding environment variable name must start with 'OSSP_RC_' and be all upper case. As a security measure, one environment variable exists that is not found as an option elsewhere. This variable deactivates B, and each subsequent usage will return success and write 'No commands run: OSSP_RC_DEACT set to yes' to the console and syslog with LOG_USER and LOG_ERR (see syslog(3)). B - Set to 'yes' or 'true' to totally deactivate B d251 1 a251 1 then the Bourne shell will be used by default. See FILES/rc.foo for details. @ 1.36 log @Conform to original OpenPKG rc behaviour by processing in execute run mode by default, correct and explain return values, and adjust test suite. @ text @d127 1 a127 1 corresponding Cs just before execution. d267 4 a270 4 Rich and fine-tuned error handling is possible by writing one or both of the following sections into F(s). These sections typically reference the local F's variables ${rc_errcode} and ${rc_errstring} for more information about which error was encountered and its text. d276 4 a279 4 B<%error> section exist, rc will stop any rcfile processing and write error strings to the console and syslog using LOG_USER and LOG_ERR (see syslog(3)). An empty B<%error> section in each F is synonymous to a C option (which doesn't exist). d286 1 a286 2 B<%default>, then an error is assumed and control flows to the B<%error> section. d315 1 a315 1 Arguments in the form of name=value pairs may be passed to the section(s) d339 2 a340 2 more information, inspect the /etc/rc structures provided by the NetBSD, FreeBSD, Solaris, and Red Hat distributions. @ 1.35 log @Use term run-command consistently throughout docs. @ text @a258 1 -1 Error in rc d260 4 a263 1 1 Error in command executed by rc @ 1.34 log @Really get the example text right. @ text @d247 1 a247 1 F, the runcommands resulting from a --eval, --exec, or --print d249 1 a249 1 a perl programmer can write runcommands in perl, and specify the perl d309 1 a309 1 the runcommands, use the 'print' run mode. d333 1 a333 1 F - Runcommands for 'foo' application @ 1.33 log @Edit examples and group them according to the three run modes, and improve most basic error message. @ text @d323 4 a326 4 /etc/rc lmtp2nntp start nSleep=2 # sleep for 2 seconds before returning /etc/rc.d/rc.rsyncd restart nSleep=4 # pause 4 seconds between start and stop /cw/etc/rc.d/rc.ftpd start nMax=32 # a maximum of 32 users can connect rc -rdv all stop nSleep=2 start nSleep=4 sLevel="LOG_INFO" bQuiet=1 @ 1.32 log @Remember possible feature, 'activate warnings on rcfile pattern'. @ text @d115 1 a115 1 will be examined. If absent, F<@@l_prefix@@/etc/rc.conf> will be used. If no d289 3 a291 4 A runcommand consists of a single program name and one or more sections. The wildcard 'all' can be given in place of a program name to denote all programs with entries in the rc registry F<$OSSP_RC_ROOT/rc.d>. The following are one-line examples of commonly used rc commands with no arguments. d295 1 d297 16 a312 2 /sfw/etc/rc.d/rc.ntpd --silent start sync stop start /usr/local/bin/rc httpd reload # sends a HUP signal a327 8 To evaluate a runcommand for all programs with an identical section name, a short expression can be written into a F<.profile> file. When the shell initializes itself, the runcommands will execute according to the C command. This is often seen when importing the environment of packages of an B hierarchy, but is always a custom modification made by the user. $ eval `@@l_prefix@@/etc/rc --eval all env` d354 3 a356 3 flexible. This flexibility allows for wider range of use, and B can therefore be used in a larger variety of situations. It is no longer exclusive to the OpenPKG project. @ 1.31 log @Implement eval mode. @ text @d72 2 a73 1 script files for B
(s) and run the commands listed in the section(s). d81 5 a85 3 configurable. A F is divided into B
s and each of them is identified by a label build from the B
name. The distribution contains various examples. d87 4 a90 4 With a single call to rc usually one F may be processed at, although many B can be passed which are executed in given order. The only exception to this rule is when the reserved keyword 'all' is used as F meaning 'all Fs.' @ 1.30 log @Flush the toilet. @ text @d329 2 a330 2 more information, inspect the /etc/rc structures provided by the FreeBSD, Solaris, and Red Hat distributions. d346 2 a347 2 therefore be used in a variety of situations. It is no longer exclusive to the OpenPKG project. @ 1.29 log @Fixed the build, improved the design, improved the configuration and option processing. @ text @d2 1 a2 1 ## rc.pod -- OSSP Run-command processor (manual page) d30 1 a30 1 B - OSSP Runcommand Processor d71 1 a71 1 OSSP rc is a runcommand processor. Its primary function is to scan F d74 1 a74 1 The runcommand processor can alternatively C the commands in human d328 1 a328 1 OSSP rc integrates concepts taken from other runcommand architectures. For d342 1 a342 1 B is a drop-in replacement for the prototype runcommand facility used @ 1.28 log @Cleanup and structuring. @ text @d74 1 a74 1 The runcommand processor can alternatively print the commands in human @ 1.27 log @Fixed copyright. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @d52 1 d65 3 a67 2 I I
@ 1.26 log @Corrections, additions, and moving items from 00TODO to rc.pod. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @d2 1 a2 1 ## rc.pod -- OSSP Runcommand Processor (Manual Page) @ 1.25 log @Add text on section arguments and OSSP_RC_DEACT, improve examples, line up text, remove unneeded =over and =back tags. Prepare for description of control flow and command interpreter logic. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @d55 1 d58 2 d62 2 d184 4 d190 1 a190 1 regex matching a section within a F. d194 9 a202 1 regex matching a reference within a F. d212 8 d234 2 a235 2 print a 'No commands run: OSSP_RC_DEACT set to yes' error message to the standard output. d239 13 d258 24 d292 1 a292 1 /sfw/etc/rc --silent ntpd start sync stop start d295 13 a307 7 Arguments may also be passed in to B, which will forward them to each section as it is called. /mybin/rc sshd start LOG_USER # calls logger(1) and passes LOG_USER /etc/rc lmtp2nntp start 2 # sleep for 2 seconds before returning /etc/rc.d/rc.rsyncd restart 4 # leave a 4 second pause between start and stop /cw/etc/rc.d/rc.ftpd start 32 # a maximum of 32 users can connect d330 1 a330 1 rc-sample(5), rc.conf(1), and rcfile(1). @ 1.24 log @Add ASN.1 example, revise and correct manpages, update todo list. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @a29 2 =over 4 a31 2 =back 4 d34 1 a34 3 =over 4 @@l_prefix@@/etc/rc a61 2 =back 4 a63 2 =over 4 a81 2 =back 4 a83 1 =over 4 a194 2 =back 4 a203 2 =over 4 d206 5 a210 1 'OSSP_RC_' and be all upper case. d212 1 a212 1 =back 4 a215 2 =over 4 a219 2 =back 4 d225 1 a225 1 one-line examples of commonly used rc commands. d227 13 a239 9 /usr/local/bin/rc --info /sbin/rc --query lmtp2nntp /cw/etc/rc --conf /etc/rc.conf --debug smtpd stop /mybin/rc sshd start LOG_USER # calls logger(1) and passes LOG_USER /etc/rc lmtp2nntp start 2 # sleep for 2 seconds before returning /sfw/etc/rc --silent ntpd start sync stop start /usr/local/bin/rc httpd reload # sends a HUP signal /etc/rc.d/rc.rsyncd restart 4 # leave a 4 second pause between start and stop /cw/etc/rc.d/rc.ftpd start 32 # a maximum of 32 users can connect d247 1 a247 1 $ eval `@@l_prefix@@/etc/rc --eval all env` d251 4 a254 8 =over 4 F - Master configuration file F - User defined functions library F - Postprocess variable declaration file F - Runcommands for 'foo' application =back 4 a257 2 =over 4 a263 2 =back 4 d266 3 a268 6 =over 4 Ralf S. Engelschall Michael Schloh von Bennewitz =back 4 @ 1.23 log @Pseudocoded anad small adjustments. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @d2 1 a2 1 ## rc.pod -- OSSP Run Command Processor (Manual Page) d32 1 a32 1 B - OSSP Run Command Processor d74 2 a75 3 OSSP rc is a run command processor. It's primary function is to scan F script files for B
(s) and run the commands listed in the section(s). d77 1 a77 1 The run command processor can alternatively print the commands in human d83 2 a84 2 configurable. A F is divided into B
s and each of them is identified by a label build from the B
name. The distribution d88 3 a90 3 many sections can be passed which are executed in given order. The only exception to this rule is when the reserved keyword `all' is used as F meaning `all Fs.' d108 2 a109 2 filter files and the optional part is a regex to filter out parts of a file. This option can be specified more than once. d117 4 a120 2 specify the location of the configuration file. If omitted, the fallback is to look for C<$OSSP_RC_CONF>, and "@@l_prefix@@/etc/rc.conf", in that order. d155 1 a155 1 output text using no terminal control sequences. The rc facility usually d157 1 a157 1 sequences for color, bold and italic rendering. The default is determines at d166 1 a166 1 specify the location of the temporary directory. If omitted, the fallback is d210 7 d221 3 a223 3 Every command line longoption is also a keyword in the F file and, prefixed with "OSSP_RC_" and it's name in upper case, also available as an environment variable. d239 4 a242 6 =over 4 Some short one line examples include the following. Note that a run command consists of a single program name and one or more sections. The wildcard `all' can be given in place of a program name to denote all programs with entries in the rc registry F<$OSSP_RC_ROOT/rc.d>. d245 4 a248 4 /etc/rc --query lmtp2nntp /mybin/rc sshd start /etc/rc lmtp2nntp start /sfw/etc/rc --conf /etc/rc.conf --debug smtpd stop d250 3 a252 1 /usr/local/bin/rc httpd restart d254 1 a254 1 To evaluate a run command for all programs with an identical section name, a d256 1 a256 1 initializes itself, the run commands will execute according to the C d258 3 a260 1 B hierarchy. d264 8 a271 4 F - Master configuration file F - User defined functions library F - Postprocess variable declaration file F - Run commands for "foo" application d275 1 a275 3 OSSP rc integrates concepts taken from other run command architectures. For more information, inspect the /etc/rc structures provided by FreeBSD, Solaris, and Red Hat distributions. d277 7 a283 1 rc.conf(1), rc.func(1), rc.env(1), rcfile(1), and rc-sample(1). d287 2 d290 1 d292 1 a292 1 Michael Schloh von Bennewitz d296 6 a301 6 B is a replacement for the prototype run command facility used in the OpenPKG project (http://www.openpkg.org/). The prototype was a slow and less robust Bourne shell script. B is intended to faster, more robust, and more flexible. This flexibility allows for wider range of use, however. B can therefore be used in a variety of situations, and is no longer exclusive to the OpenPKG project. @ 1.22 log @remove useless =over @ text @d43 1 a43 1 [B<-F>|B<--force>] a45 1 [B<-d>|B<--dirs> I[C<:>I[...]]] d58 7 d106 1 a106 1 =item B<-F>|B<--force> d108 3 a110 4 Usually F is a fraction of a filename and the run command facility prefixes this name with ${OSSP_RC_PREFIX} and appends ${OSSP_RC_SUFFIX} to it, then searches the file in directories given using --dirs. If the initial F matches the regex '^\.{0,2}/', --force is automagically assumed. a120 4 =item B<-d>|B<--dirs> I[C<:>I[...]] directories to search for Fs. d178 28 @ 1.21 log @unlock @ text @a224 2 =over 4 a229 2 =back 4 a231 2 =over 4 a237 2 =back 4 a239 2 =over 4 a243 2 =back 4 a245 2 =over 4 a251 2 =back 4 @ 1.20 log @set administrative lock @ text @a0 4 -------------------------------------------------------------------------------- DO NOT EDIT. MAJOR REWRITES JOINING OPTIONS, NOTES AND DEFAULTS IN PROGRESS. THL -------------------------------------------------------------------------------- a39 2 =item B d41 15 a55 1 [B<-c>|B<--conf> I[C<:>I[...]]] d57 1 a57 8 [B<-r>|B<--raw>] [B<-v>|B<--verbose>] [B<-D>|B<--debug>] =item B @@l_prefix@@/etc/rc [I] a58 5 [B<-p>|B<--print>] [B<-e>|B<--eval>] [B<-d>|B<--dirs> I[C<:>I[...]] [B<-f>|B<--func> I[C<:>I[...]]] [B<-F>|B<--force>] a60 37 [I
...] =item B @@l_prefix@@/etc/rc [I] B<-q>|B<--query> I [B<-d>|B<--dirs> I[C<:>I[...]] [B<-F>|B<--force>] I =item B [I] <-l>|<--labels> [B<-d>|B<--dirs> I[C<:>I[...]] [B<-F>|B<--force>] I # FIXME Ralf, what's that? # @@l_prefix@@/etc/rc # [I] # [B<-c>|B<--conf>] # [I] =item B @@l_prefix@@/etc/rc [I] [B<-i>|B<--info>] =item B @@l_prefix@@/etc/rc [B<-?>|B<--usage>] [B<-h>|B<--help>] [B<-V>|B<--version>] d68 13 a80 13 OSSP rc is a run command processor. It's primary function is to scan F script files for B
(s) identified by corresponding label(s) and run the commands in the section(s). The run command processor can also only print the commands without executing them or reformat them to C input. The F files contain variables and the command processor has functionality to query their default, set and effective values. To understand the structure and syntax of F script files, an example called F is included in the distribution. The rc environment and behaviour is very configurable, so the syntax may vary and not match exactly the example provided. d83 3 a85 17 many sections can be given to source their corresponding commands, see EXAMPLES below. There is one exception to this rule in which an rc keyword named `all' is reserved to mean `all Fs.' The user may thus give the `all' wildcard in place of the C parameter to process the commands from the given sections of all Cs found. #THL! does "all stop start" mean "a stop stop, a start, b start" or " a stop, #a start, b stop, b start"? #Prioritaeten #Using the `all' wildcard may be risky in some cases, because successful #performance then depends not only on the code written into each program's #sections but also if every single program found has the named section label at #all. For information about the rc exit status after such an operation see #`DIAGNOSTICS.' d92 1 d94 1 a94 27 Inclusive options which may be used with another =item B<-c>, B<--conf> F specify the location of the configuration file. =item B<-f>, B<--func> F[C<:>F[...]] specify the location of one or more optional function files, containing commands which are prepended to the sections of their corresponding Cs. =item B<-F>, B<--force> Disable ${OSSP_RC_PREFIX} and ${OSSP_RC_SUFFIX} expansion on F. Disable searching for F. This mode assumes F is a filename. It is automagically entered when the F matches the regex '^\.{0,2}/'. =item B<-d>, B<--dirs> I[C<:>I[...] override OSSP_RC_DIRS, and use these paths to search for Fs instead. =item B<-t>, B<--tmpdir> I specify the location of the temporary directory =item B<-v>, B<--verbose> d96 1 a96 7 verbosely report processing, including all warnings =item B<-s>, B<--silent> be silent, and disable output =item B<-D>, B<--debug> d100 1 a100 1 =item B<-r>, B<--raw> d102 4 a105 1 output text using no terminal control sequences d107 1 a107 15 =back 4 Mutually exclusive options, i.e. only a single one can be given =over 4 =item B<-h>, B<--help> print this help, then exit =item B<-?>, B<--usage> print short usage summary, then exit. =item B<-V>, B<--version> d111 1 a111 1 =item B<-p>, B<--print> d113 2 a114 2 output the commands as they would by seen by the command interpreter, but do not run them. d116 1 a116 1 =item B<-e>, B<--eval> d118 1 a118 2 output the text for a command suitable for shell evaluation, but do not run it. d120 1 a120 1 =item B<-x>, B<--exec> d122 1 a122 1 execute the command interpreter in a subprocess and actually run the commands. d124 1 a124 1 =item B<-q>, B<--query> d126 3 a128 1 print the value(s) of rc configuration variables defined in the %config section. d130 1 a130 1 =item B<-l>, B<--labels> d132 1 a132 1 learn what section labels a F offers. d134 1 a134 1 =item B<-i>, B<--info> d138 1 a138 1 =back 4 d140 1 a140 1 =head1 NOTES d142 1 a142 1 =over 4 d144 1 a144 2 =item B<-h>, B<--help>, B<-V>, B<--version>, B<-v>, B<--verbose>, and B<-q> B<--silent> d146 1 a146 53 The B<--help>, B<--version>, B<--verbose>, and B<--silent> options are used to control the screen output of B and control the general output of all sections found in the Fs as well. For example, specifying B<--silent> will mute B's output and also all command output that B runs. =item B<-r>, B<--raw> I The option B<-r> or B<--raw> turns on raw output mode. In this case, no formatting is done to the screen output. This mode is different from formatted output mode, in which the output is annotated with terminal control sequences for better readability. =item B<-t>, B<--tmp> I Specifying this option will force B to use the given temporary directory I for all its temporary output. =item B<-e>, B<--eval> and B<-p>, B<--print> With the B<--eval> or B<--print> options, the run command will not be executed. Rather, B will print a command suitable for later evaluation in the current shell. Given alone, this option will cause B to not execute the run command. Used together with B<--exec>, B will execute the run command and print a similar command for later execution as well. The B<--eval> option cannot be used together with B<--print>, because of conflicting output and the way that B constructs the evaluation text. Specifically, most Bourne shells and derivatives report errors with commands spanning multiple lines. Consider using the B<--eval> option for batch evaluation with the Bourne shell C command. Use the B<--print> option for better human readability. See `EXAMPLES' for an example. =item B<-x>, B<--exec> The B<--exec> is the most common option of all, in which B executes a run command made up of a given program and section. Options controlling the flow of execution include B<--print>, B<--eval>, and B<--exec>. =item B<-q>, B<--query> The B<--query> option queries the I value of one or more configuration variables. These variables are set in the C<%config> section of the corresponding F. The B<--query> option reports the I value, and not necessarily that written in the F file, which can be overridden by variable settings in the F file. Used with the B<--query> option, B will expect exactly one command line argument to follow. This must be a I string containing arbitrary text and optionally one or more B variable specifications ("C<${>IC<}>" in its simplest form.) !FIXME what is var here! d148 2 a149 1 =back 4 d151 1 a151 1 =head1 DEFAULT VALUES d153 4 a156 1 =over 4 d158 1 a158 2 In B, all options have a reasonable default value. This allows for a configurationless B installation. d160 1 a160 1 =item B<-r>, B<--raw> d162 1 a162 5 The B<--raw> option determines its default at runtime. If the raw mode option is not specified, B will determine whether F is connected to a terminal. If so, B will run in formatted output mode. If F is not connected to a terminal (such as with most daemons,) B will run in raw output mode even though it was not specified as an option. d164 3 a166 1 =item B<-t>, B<--tmpdir> I d168 1 a168 2 If the B<--dirs> option is not given, B will try to use C<$TMPDIR>, C<$TEMPDIR>, C<~/tmp> and C (in that order.) d170 1 a170 1 =item B<-p>, B<--print>, B<-e>, B<--eval>, B<-x>, B<--exec> d172 1 a172 2 If neither B<--print>, B<--eval>, or B<­-exec> is given B will default to B<--exec>. d174 3 a176 1 =item B<-c>, B<--conf> F d178 1 a178 14 Using F from command line option -c aka --conf, fallback to ${OSSP_RC_CONF}, fallback to "@@l_prefix@@/etc/rc.conf". =item B<-f>, B<--func> F[C<:>F[...]] =item B<-F>, B<--force> =item B<-d>, B<--dirs> I[C<:>I[...] #!FIXME! Sprech mal von Pfad und Dateien defaults wieviel rc.conf erlaubt #!FIXME! sind, und welche genommen wird oder sonst wie gemerged. F F F F d184 1 a184 1 Every command line longoption is also a keyword in the rc.conf file and, a187 17 The environment determines where rc will search before beginning to process run commands. It also influences B behaviour, just as the command line options do. There is no difference between typing an option in the command line, and appending the same option to the OSSP_RC_OPTS variable. #!FIXME! Study this and determine if it is needed #OSSP_RC_IMPLS - Other rc implementations # #The OSSP_RC_IMPLS variable plays a role only when the user has more than one #logical set of run command sections. If rc reads anything but EOL in this #variable, it will assume that more than one rc implementation exists. The #variable should contain a chain of paths where other rc implementations are. #This allows the user to build several OSSP rc hierarchies and then switch from #each... Blah FIXME I don't know if we should be paying attention to the #ENVIRONMENT guys. Maybe this is not a good solution for our dynamic OpenPKG #environment problem after all. d194 1 a194 1 -1 Faulty run command hierarchy d196 1 a196 1 1 One or more run commands failed a222 8 =over 4 $ eval `@@l_prefix@@/etc/rc --eval all env` =back 4 =back 4 d228 1 a228 7 The following filenames are specified in F. Both their names and locations may be different due to user customizations. =over 4 F - User defined functions file d230 1 a230 3 F> - Run command file =back 4 a242 18 =back 4 =head1 DIAGNOSTICS =over 4 If rc fails while processing a run command, the exit status will be 1. If rc failed due to a broken run command configuration, the exit status will be -1. This can happen if a script file is moved or renamed, for example. If the run command configuration is broken, no further action is taken and no run commands are processed. Importantly, if the keyword `all' is given as the program wildcard parameter, then processing will begin and continue until the first error is reached. Should an error arise, processing will stop and the exit status will be 1. There is no way to learn which command caused the error unless it is apparent from the text output of the rc process. @ 1.19 log @start work on aligning longoptions and config file example @ text @d1 4 @ 1.18 log @append does not work in shell @ text @a39 5 #rc [-h|--help] [-V|--version] [-v|--verbose] # [-d|--debug] [-p|--print] [-e|--eval] # [-c|--config] [-q|--query] [-r|--raw] #
[
...] d43 2 a44 5 [B<-f>|B<--rcfile>] [B<-d>|B<--rcdir> I[C<:>I[...]] [B<-C>|B<--rcconf> I[C<:>I[...]]] [B<-F>|B<--rcfunc> I[C<:>I[...]]] [B<-t>|B<--tmpdir> I] a47 3 [I] [I] [I] d52 1 a52 1 [I] d56 4 a59 1 I d66 19 a84 8 [I] [B<-q>|B<--query>] I @@l_prefix@@/etc/rc [I] [B<-c>|B<--config>] [I] d86 1 a86 1 =item B d89 1 a89 1 [I] d92 2 d95 1 d146 1 a146 1 =item B<-c>, B<--config> F d148 1 a148 3 specify the location of the configuration file, overriding the environment variable $OSSP_RC_CONFIG and the built-in hard-coded value (see DEFAULTS.)!FIXME! d150 1 a150 1 =item B<-n>, B<--func> F[C<:>F[...]] d156 1 a156 1 =item B<-f>, B<--file> d178 1 a178 1 =item B<-d>, B<--debug> d196 4 d245 1 a245 1 =item B<-t>, B<--tmpdir> I d252 1 a252 1 =item B<-t>, B<--tmpdir> I d254 1 a254 1 Specifying the option B<--tmpdir> will force B to use the given temporary d320 7 a326 3 =item B<-c>, B<--config> F =item B<-n>, B<--func> F[C<:>F[...]] =item B<-f>, B<--file> F a336 10 #!FIXME! Kein mehr defaults, und sag so =item B<-v>, B<--verbose> =item B<-q>, B<--silent> =item B<-d>, B<--debug> =item B<-h>, B<--help> =item B<-V>, B<--version> =item B<-q>, B<--query> =item B<-l>, B<--labels> =item B<-i>, B<--info> d341 3 a343 3 OSSP_RC_CONFIG - Where to find the F file. OSSP_RC_DIRS - Where to find the F> files. OSSP_RC_OPTIONS - Options, same as the command line ones d348 1 a348 1 line, and appending the same option to the OSSP_RC_OPTIONS variable. d387 1 a387 1 /sfw/etc/rc --config /etc/rc.conf --debug smtpd stop @ 1.17 log @consequent usage of terms "rcfile", "label", "commands" and "sections" @ text @d149 1 a149 1 commands which are prepended /FIXME append?/ to the sections of their corresponding @ 1.16 log @ms and thl manually merged ms' and rse's work @ text @d48 1 a48 1 [B<-f>|B<--rcfile> I] d56 1 a56 1 [I] d67 3 a69 3 I I [I ...] d99 22 a120 18 OSSP rc is a run command processor. It applies the script code associated with one or more given section label to a given program. The program must have an entry in the form rc. including script code grouped into sections. To help understand this file structure and how a section typically looks, an example called F is included in the distribution. OSSP rc references these command entries by reading the configuration file (see FILES) and searching the directory where the program entries reside. Each section of script code offers a type of functionality described by its section label. This label is the same one given on the command line after the desired program name. Only one program may be processed at a time, although many sections can be sourced with the same call to rc. An example of this is given in `EXAMPLES.' There exists one exception to this rule in which an rc keyword named `all' is reserved to mean `all programs.' The user may thus give the `all' wildcard in place of the C parameter to process the given sections of all programs found. d142 3 a144 3 specify the location of the configuration file, overriding the environment variable $OSSP_RC_CONFIG and the built-in hard-coded value (see DEFAULTS.)!FIXME! d148 9 a156 6 specify the location of an optional functions file, containing Bourne shell script code =item B<-f>, B<--file> F use the configuration and section data of a particular file d160 1 a160 1 override OSSP_RC_DIRS, and use these paths instead d198 2 a199 2 output the text as it would be interpreted by the shell, but do not run the commands d203 2 a204 1 output the text for a command suitable for shell evaluation d208 1 a208 1 execute in subshell(s), will actually run the commands d212 1 a212 1 print the value(s) of rc configuration variables d216 1 a216 1 learn what section labels a run command offers d232 3 a234 3 control the screen output of B, but control the general output of all script code found in the F as well. For example, specifying B<--silent> will mute B's output and also all script output that B d275 3 a277 3 the corresponding F> file. The B<--query> option reports the I value, and not necessarily that written in the F> file, which can be overridden by variable settings in the F file. d322 2 a323 2 F F> d415 2 a416 2 F - Postprocess variable declaration file F> - Run command file d430 1 a430 1 rc.conf(1), rc.func(1), rc.config(1), rc.program(1), and rc-sample(1). @ 1.15 log @flush @ text @d2 1 a2 1 ## rc.pod -- OSSP Run Command Facility (Manual Page) a25 103 # ref: %start; %stop # cfg # def --showdefault, --defsetion=config # --dir=dir1:dir2:.. # --rcfile='rc.%s' # --regex-section='(?<=^|\n)%%%s\s*\n(.+?)(?=\n%\S+|$)' # --regex-param='..' # --regex-reference='(?<=^|\n)%%%s\s*(.+?)(?=\n|;)' # --regex-config='(\s+)=(.*)$' # --name-config=config # --name-common=common # RegexSection (?<=^|\n)%%%s\s*\n(.+?)(?=\n%\S+|$) # - instead of separate run-commands use a global one # - temporarily deactivation of run-commands through environment variable # - perhaps: "rc [,[,...]] [- ...] [ ...] # Examples: # rc.foo %config foo=1 bar=2 %start -u root -p 200 /cw/bin/fooctl start $foo %stop -u root -p 200 /cw/bin/fooctl stop $bar %restart -u root %stop sleep 1 %start %foo -c /usr/bin/perl print STDERR "foo"; 1 2 /cw/bin/fooctl start $foo /cw/bin/fooctl stop $bar %stop sleep 1 %start print STDERR "foo"; rc
[
...] foreach sec in
[
...] { foreach dir in --dir=dir1:dir2:.. { search for --rcfile where %s is parse rcfile into blocks according to --regex-section/etc. remember common/
into list } // we now have an unsorted list of common/
sort list of common/
according to their priority (see --regex-param) // execution forearch common/
in list { prepend config section prepend common section expand references accordingf to --regex-reference execute result as user/group (see --regex-param) with interpreter (see --regex-param) } } cd () { eval `rc --eval --rcfunc=$HOME/.cdfunc --rcfile-owner=$USER --rcfile-umask=022 --dir .:..:../..:../../.. --rcfile .cd all leave` builtin cd ${1+"$@@"} eval `rc --eval --rcfunc=$HOME/.cdfunc --rcfile-owner=$USER --rcfile-umask=022 --dir .:..:../..:../../.. --rcfile .cd all enter` } # $HOME/.cdfunc AddPath () { ... } RemPath () { ... } # .cd %enter FOO=1 export FOO AddPath `pwd`/bin %leave unset FOO RemPath `pwd`/bin TODO: - error semantic: imediate faulure or skip failured - security => --rcfile-umask d32 1 a32 1 B - OSSP Run Command Facility d40 5 d99 28 a126 13 B is a generic run-command processor. It applies the script code associated with a given section label to one or more given commands. The command(s) must each have entries in the form rc. including script code grouped into sections. OSSP rc references these command entries by reading the configuration file (see FILES) and searching the directory where the command entries reside. Each section of script code extends a type of functionality described by its section label. This label is the same one given before the desired command(s). Although only one section is possible for each call to OSSP rc, many `commands' can follow the section label. This allows for an abbreviated input format when calling the same script section of many commands. An example of this is given in `EXAMPLES.' a133 2 !FIXME! Remark, difference between PARAMETER OPTIONS and COMMAND OPTIONS d139 2 a140 2 overriding the environment variable C<$OSSP_RC_CONFIG> and the built-in hard-coded value. d153 1 a153 1 override OSSP_RC_ROOT, and use these paths instead d165 1 a165 1 hold silence, and output no text messages whatsoever d175 2 d179 2 d200 1 a200 1 execute in subshell(s), follow with
a213 4 All of these options have reasonable default values, which OSSP rc assumes when no option is otherwise given. For details of some listed option see `NOTES'. d220 2 a221 1 !FIXME! Remark, difference between PARAMETER OPTIONS and COMMAND OPTIONS d223 5 a227 1 =over 4 d229 1 a229 4 As expected, when B has output it will write ASCII text to F for normal output, and F for abnormal output (such as warnings and errors.) The options for controlling the output content are B<--config>, B<--help>, B<--version>, B<--verbose>, and B<--silent>. d232 3 a234 7 formatting is done to output text. This mode contrasts formatted output mode, in which the output is annotated with terminal control sequences for better readability. This option has no single default value. If the raw mode option is not specified, B will determine whether F is connected to a terminal. If so, B will run in formatted output mode. If F is not connected to a terminal (such as with most daemons,) B will run in raw output mode even though it was not specified as an option. d238 2 a239 3 Specifying this option will force B to use the given temporary directory I for all its temporary output. If this option is not given, B will try to use C<$TMPDIR>, C<$TEMPDIR>, C<~/tmp> and C (in that order.) d243 9 a251 8 The run command will not be executed. Rather, B will print a command suitable for later evaluation in the current shell. Given alone, this option will cause B to not execute the run command. Used together with B<--exec>, B will execute the run command and print a similar command for later execution as well. The B<--eval> option cannot be used together with B<--print>, because of conflicting output and the way that B constructs the evaluation text. Specifically, most Bourne shells and derivatives report errors with commands spanning multiple lines. d259 1 a259 1 Exec is the most common option of all, in which B executes a run command d261 1 a261 2 execution include B<--print>, B<--eval>, and B<--exec>. When no option is given, B will default to B<--exec> and execute the run command directly. d265 11 a275 8 Query the value of one or more configuration variables. These variables are set in the C<%config> section of the F<\.rc> file corresponding to a program. The B<--query> option may report a different value, however. It is possible for variable declarations in the F file to override those in the program's own rc file. Used with the B<--query> option, B will expect exactly one command line argument to follow. This must be a I string containing arbitrary text and optionally one or more B variable specifications ("C<${>IC<}>" in its simplest form.) d279 48 d331 20 a350 18 OSSP_RC_ROOT - Where the OSSP rc hierarchy is located OSSP_RC_OPTIONS - Options, same as the command line ones The environment determines where rc will look before beginning to process run commands. It also influences the behaviour, just as the command line options do. There is no difference between typing an option in the command line, and adding the same option to the OSSP_RC_OPTIONS variable. OSSP_RC_IMPLS - Other rc implementations The OSSP_RC_IMPLS variable plays a role only when the user has more than one logical set of run command sections. If rc reads anything but EOL in this variable, it will assume that more than one rc implementation exists. The variable should contain a chain of paths where other rc implementations are. This allows the user to build several OSSP rc hierarchies and then switch from each... Blah FIXME I don't know if we should be paying attention to the ENVIRONMENT guys. Maybe this is not a good solution for our dynamic OpenPKG environment problem after all. d354 1 a354 1 =head1 FILES d358 3 a360 1 /$OSSP_RC_ROOT/rc.conf - Configuration file d366 2 d387 38 a424 1 $ eval `@@l_prefix@@/etc/rc --eval all env` d428 1 a428 22 The exit status is 0 if rc was able to initiate the given section code of the given run command(s). If rc encountered an error during its processing, the exit status is indexed to the first command parameter which failed as ordered by the command line. This means that if rc returns 3, the third run command given on the command line failed. FIXME! Choose one interpretation: 1 This does not mean that only the third run command failed, however. It is possible that the fourth and sixth failed as well, for example. 2 Upon failure of any run command, OSSP rc halts and processes no more. Because of such a failure, a long batch of run commands may not be processed. This may be important with long run command batches or dependencies between run commands, so plan well when constructing the order of run commands on the command line. In case rc fails when only one run command is given, the exit status will be 1 as expected. If rc failed because of a broken run command hierarchy, the exit status will be -1. This can happen if a script file is moved or renamed, for example. If the run command hierarchy is broken, no further action is taken and no run commands are processed. d430 11 a440 1 =head1 SEE ALSO d442 1 a442 3 B integrates concepts taken from other run-command architectures. For more information, inspect the /etc/rc facilities provided by FreeBSD, NetBSD and Solaris. d446 7 a452 2 Ralf S. Engelschall Michael Schloh von Bennewitz d456 10 a465 4 B was born to replace the prototype run-command facility used in the OpenPKG project (http://www.openpkg.org/). The prototype was a slow and less robust Bourne-Shell script. B is intended to replace it with a faster, more robust and flexible facility. a467 1 @ 1.14 log @flush our brainstorming @ text @d41 4 a100 1 @ 1.13 log @more axing... hell\! @ text @d26 100 d151 1 @ 1.12 log @remove too much Bla-Blah... @ text @d93 1 a93 1 OSSP rc is a run command processor. It applies the script code associated with a196 91 =head1 RETURN VALUE =over 4 Returns zero if successful, or nonzero if otherwise. =back 4 =head1 ERRORS =over 4 -1 Faulty run command hierarchy 0 Success 1 First (or only) run command failed 2 Second run command failed N Nth run command failed Positive error values are indexed to their respective run commands by command line ordering. For more information see `DIAGNOSTICS.' =back 4 =head1 EXAMPLES Some short one line examples include the following. Note that a run command consists of a single program name and one or more sections. The wildcard `all' can be given in place of a program name to denote all programs with entries in the rc registry F<$OSSP_RC_ROOT/rc.d>. /usr/local/bin/rc --info /etc/rc --query lmtp2nntp /mybin/rc sshd start /etc/rc lmtp2nntp start /sfw/etc/rc --config /etc/rc.conf --debug smtpd stop /sfw/etc/rc --silent ntpd start sync stop start /usr/local/bin/rc httpd restart To evaluate a run command for all programs with an identical section name, a short expression can be written into a F<.profile> file. When the shell initializes itself, the run commands will execute according to the C command. This is often seen when importing the environment of packages of an B hierarchy. $ eval `@@l_prefix@@/etc/rc --eval all env` =head1 ENVIRONMENT =over 4 OSSP_RC_ROOT - Where the OSSP rc hierarchy is located OSSP_RC_OPTIONS - Options, same as the command line ones The environment determines where rc will look before beginning to process run commands. It also influences the behaviour, just as the command line options do. There is no difference between typing an option in the command line, and adding the same option to the OSSP_RC_OPTIONS variable. OSSP_RC_IMPLS - Other rc implementations The OSSP_RC_IMPLS variable plays a role only when the user has more than one logical set of run command sections. If rc reads anything but EOL in this variable, it will assume that more than one rc implementation exists. The variable should contain a chain of paths where other rc implementations are. This allows the user to build several OSSP rc hierarchies and then switch from each... Blah FIXME I don't know if we should be paying attention to the ENVIRONMENT guys. Maybe this is not a good solution for our dynamic OpenPKG environment problem after all. =back 4 =head1 FILES =over 4 /$OSSP_RC_ROOT/rc.conf - Configuration file =back 4 =head1 SEE ALSO =over 4 OSSP rc integrates concepts taken from other run command architectures. For more information, inspect the /etc/rc structures provided by FreeBSD, Solaris, and Red Hat distributions. biff(1), bagg(1), honk(1), gonk(1), and quatch(1). =back 4 d260 1 a260 1 =head1 WARNINGS d264 18 a281 1 There are no warnings. OSSP rc is perfect ;-) d285 1 a285 1 =head1 DIAGNOSTICS d289 29 d341 5 a345 1 =back 4 @ 1.11 log @move the synopsis back to where it belongs: SYNOPSIS section @ text @a387 20 =head1 BUGS =over 4 !FIXME! To report a bug, please visit the web page http://www.ossp.org/bugdb.html. Be sure to include the word "rc" in the subject field of your bug report. OSSP rc contains no known bugs to date. =back 4 =head1 RESTRICTIONS =over 4 Bugs we don't plan to fix include washing out the bathtub. !FIXME! =back 4 d390 2 a391 6 =over 4 Ralf S. Engelschall Michael Schloh von Bennewitz =back 4 d395 4 a398 1 =over 4 d400 1 a400 11 OSSP rc was born to replace the run command logic used in the OpenPKG project. In the first version of OpenPKG (http://www.openpkg.org), a run command script called `rc' could issue run commands to programs installed under the OpenPKG software hierarchy. This solution had a number of inconveniences, however. As time wore on, developers at Cable & Wireless Deutschland GmbH decided to replace the bourne shell script with a faster, more robust implementation. This is OSSP rc. By the way, an unplanned advantage of this redevelopment is that OSSP rc can be used for any project needing generic run command logic as well as the OpenPKG project as first planned. =back 4 a401 1 =cut @ 1.10 log @Grrr... as I already did last time: fix POD style. all POD =xxx commands are intended to be surrounded by blank lines for correct parsing and results. You can trust me: I usually know what I'm doing ;) @ text @d40 46 a85 4 rc [-h|--help] [-V|--version] [-v|--verbose] [-d|--debug] [-p|--print] [-e|--eval] [-c|--config] [-q|--query] [-r|--raw]
[
...] a221 2 =over 4 a241 48 =item B @@l_prefix@@/etc/rc [B<-f>|B<--rcfile> I] [B<-d>|B<--rcdir> I[C<:>I[...]] [B<-C>|B<--rcconf> I[C<:>I[...]]] [B<-F>|B<--rcfunc> I[C<:>I[...]]] [B<-t>|B<--tmpdir> I] [B<-r>|B<--raw>] [B<-v>|B<--verbose>] [B<-D>|B<--debug>] [I] [I] =item B @@l_prefix@@/etc/rc [I] [B<-x>|B<--exec>] [B<-p>|B<--print>] [B<-e>|B<--eval>] I I =item B @@l_prefix@@/etc/rc [I] [B<-q>|B<--query>] I @@l_prefix@@/etc/rc [I] [B<-c>|B<--config>] [I] =item B @@l_prefix@@/etc/rc [I] [B<-i>|B<--info>] @@l_prefix@@/etc/rc [B<-h>|B<--help>] [B<-V>|B<--version>] =back 4 @ 1.9 log @Removed stray text. Please review this deletion. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @d76 1 d78 2 a79 1 overriding the environment variable $OSSP_RC_ROOT d82 1 d87 1 d91 1 d95 1 d99 1 d103 1 d107 1 d111 1 d117 1 d121 1 d125 1 d130 1 d134 1 d138 1 d142 1 d146 1 @ 1.8 log @Completed draft. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @a281 7 # ref: %start; %stop # cfg # --glob-rcfile='rc.%s' # --regex-section='(?<=^|\n)%%%s\s*\n(.+?)(?=\n%\S+|$)' # --regex-reference='(?<=^|\n)%%%s\s*(.+?)(?=\n|;)' # def --showdefault, --defsetion=config @ 1.7 log @fix POD markup @ text @d30 2 d34 2 d38 2 d45 2 d49 2 d65 2 d71 2 d75 13 a87 1 =item B<-c>, B<--config> d89 2 a90 3 locate the configuration file in the following path, overriding the environment variable $OSSP_RC_ROOT when locating the configuration file a92 1 a95 1 a98 1 a101 1 a106 1 a109 1 a112 1 a116 1 a119 1 a122 1 d126 1 a126 2 learn what section labels a run command extends a128 1 d132 1 a132 1 when no option is otherwise given. For details of each listed option see d139 2 d143 2 d147 2 d158 2 d162 2 a184 44 =head1 ENVIRONMENT OSSP_RC_ROOT - Where the OSSP rc hierarchy is located OSSP_RC_OPTIONS - Options, same as the command line ones The environment determines where rc will look before beginning to process run commands. It also influences the behaviour, just as the command line options do. There is no difference between typing an option in the command line, and adding the same option to the OSSP_RC_OPTIONS variable. OSSP_RC_IMPLS - Other rc implementations The OSSP_RC_IMPLS variable plays a role only when the user has more than one logical set of run command sections. If rc reads anything but EOL in this variable, it will assume that more than one rc implementation exists. The variable should contain a chain of paths where other rc implementations are. This allows the user to build several OSSP rc hierarchies and then switch from each... Blah FIXME I don't know if we should be paying attention to the ENVIRONMENT guys. Maybe this is not a good solution for our dynamic OpenPKG environment problem after all. =head1 FILES /$OSSP_RC_ROOT/rc.conf - Configuration file =head1 SEE ALSO OSSP rc integrates concepts taken from other run command architectures. For more information, inspect the /etc/rc structures provided by FreeBSD, Solaris, and Red Hat distributions. biff(1), bagg(1), honk(1), gonk(1), and quatch(1). =head1 NOTES =nada # ref: %start; %stop # cfg # --glob-rcfile='rc.%s' # --regex-section='(?<=^|\n)%%%s\s*\n(.+?)(?=\n%\S+|$)' # --regex-reference='(?<=^|\n)%%%s\s*(.+?)(?=\n|;)' # def --showdefault, --defsetion=config d229 5 a233 1 [B<-V>|B<--version>] d237 2 a238 1 =item B<-f>, B<--rcfile> I d240 4 a243 1 =item B<-d>, B<--rcdir> I[C<:>I[...] d245 1 a245 1 =item B<-C>, B<--rcconf> I[C<:>I[...]] d247 8 a254 1 =item B<-F>, B<--rcfunc> I[C<:>I[...]] d256 5 a260 1 =item B<-t>, B<--tmpdir> I d262 1 a262 3 Force the use of a particular temporary directory. By default B tries to use (in this order) C<$TMPDIR>, C<$TEMPDIR>, C<~/tmp> and C. d264 1 a264 1 !FIXME! Remark, difference between PARAMETER OPTIONS and COMMAND OPTIONS d266 1 a266 1 =nada d270 18 a287 2 =item B<-v>, B<--verbose> verbosely report processing, including all warnings d289 1 a289 2 =item B<-s>, B<--silent> hold silence, and output no text messages whatsoever d291 1 a291 2 =item B<-d>, B<--debug> don't remove any temporary files, and output debug messages d307 1 a307 4 =item B<-c>, B<--config> locate the configuration file in the following path, overriding the environment variable $OSSP_RC_ROOT when locating the configuration file d309 3 a311 3 =item B<-p>, B<--print> output the text as it would be interpreted by the shell, but do not run the commands d313 1 a313 1 =item B<-e>, B<--eval> d346 5 a350 2 =item B<-l>, B<--labels> learn what section labels a run command extends d352 1 a352 2 =item B<-i>, B<--info> print a comprehensive summary of the rc environment a355 2 =head1 WARNINGS d387 2 d395 2 d399 2 d403 2 d407 2 d412 2 d416 2 d427 2 @ 1.6 log @More editing, markup, and reorder. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @d62 4 a65 3 locate the configuration file in the following path, overriding the environment variable $OSSP_RC_ROOT when locating the configuration file d68 2 a69 1 verbosely report processing, including all warnings d72 2 a73 1 hold silence, and output no text messages whatsoever d76 2 a77 1 don't remove temporary files, and output debug messages to stderr d80 2 a81 1 output text using no terminal control sequences d86 2 a87 1 print this help, then exit d90 2 a91 1 print version and copyright, then exit d94 3 a96 2 output the text as it would be interpreted by the shell, but do not run the commands d99 2 a100 1 output the text for a command suitable for shell evaluation d103 2 a104 1 execute in subshell(s), follow with
d107 2 a108 1 print the value(s) of rc configuration variables d111 2 a112 1 learn what section labels a run command extends d115 2 a116 1 print a comprehensive summary of the rc environment @ 1.5 log @Added text, reorganization, and editing. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @d2 1 a2 1 ## rc.pod -- OpenPKG Run-Command Facility (Manual Page) d4 1 a4 1 ## Copyright (c) 2000-2002 The OpenPKG Project a25 7 # ref: %start; %stop # cfg # --glob-rcfile='rc.%s' # --regex-section='(?<=^|\n)%%%s\s*\n(.+?)(?=\n%\S+|$)' # --regex-reference='(?<=^|\n)%%%s\s*(.+?)(?=\n|;)' # def --showdefault, --defsetion=config d30 1 a30 1 B - OpenPKG Run-Command Facility d53 1 a53 1 this is given in (EXAMPLES.) d57 2 d61 6 a66 1 -v, --verbose d69 1 a69 1 -s, --silent d72 2 a73 2 -d, --debug don't remove any temporary files, and output debug messages d75 1 a75 1 -r, --raw d80 1 a80 1 -h, --help d83 2 a84 2 -V, --version print version number, then exit d86 1 a86 6 -c, --config locate the configuration file in the following path, overriding the environment variable $OSSP_RC_ROOT when locating the configuration file -p, --print d90 1 a90 1 -e, --eval d93 2 a94 2 -x, --exec execute in subshell(s), follow with
d96 1 a96 1 -q, --query d99 1 a99 1 -l, --labels d102 1 a102 1 -i, --info d105 5 a109 2 All of these options have reasonable default values, which OSSP rc assumes when no option is otherwise given. d128 20 a147 4 /myetc/rc start sshd /etc/rc close docview primary httpd sshd radiusd /sfw/etc/rc restart smtpd lmtp2nntp /cw/etc/rc restart apache d184 8 a191 1 =over 4 d257 1 a257 1 =item B<-r>, B<--raw> d259 1 a259 6 Control whether the output controlled by the options B<--config>, B<--help>, B<--version> and B<--verbose> are raw text or annotated with terminal control sequences for better readability. By default B automatically determines whether F is connected to a terminal or not and uses terminal sequences in the output or respectively raw text output only. d262 1 d264 2 a265 1 Enables verbose messages on F. d267 2 a268 1 =item B<-D>, B<--debug> d270 13 a282 1 Enables debugging messages on F. d284 4 a287 12 !FIXME! Remark, difference between PARAMETER OPTIONS and COMMAND OPTIONS These options are mutually exclusive, i.e., you can specify only a single one to select the type of operation. =over 4 =item B<-x>, B<--exec> This is the default where all run-commands are executed in sub-shells. It expects exactly two non-option command line arguments: a I name and a I name. d290 2 a291 3 Instead of (by default) executing the run-commands, print them to F only. d295 12 a306 9 Instead of (by default) executing the run-commands in a sub-shell, return a command suitable for evaluation the run-commands in the current shell. Do not intermix this with option B<--print>, because B<--eval> prepares the run-commands in a temporary file and just outputs the necessary run and cleanup commands on F. This is because most Bourne-Shell flavors dislike to C commands spanning multiple lines. So, B<--print> is for human readability and batch post-processing, while B<--eval> is for batch evaluation through the Bourne-Shell C command. d308 1 a308 2 This is usually used from within F<.profile> files to import the shell environment of the packages of an B hierarchy: d310 15 a324 1 $ eval `@@l_prefix@@/etc/rc --eval all env` d326 2 a327 10 =item B<-q>, B<--query> Query the current (still default or overridden) value of one or more run-command configuration variables (see rc-file section C<%config>). It expects exactly one non-option command line argument: a I string. This is an arbitrary text string which can contain one or more B variable specifications ("C<${>IC<}>" in its simplest form). =item B<-c>, B<--config> d330 1 d332 1 a332 12 Prints a summary of the whole run-command environment of B and exits immediately. =item B<-h>, B<--help> Prints the B usage information and exits immediately. =item B<-V>, B<--version> Prints the B version and copyright information and exits immediately. =back a338 2 An explanation of all possible exit status values @ 1.4 log @More draft quality documentation. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @d46 124 a217 48 =head1 DESCRIPTION OSSP rc is a run command processor. It applies the script code associated with a given section label to one or more given commands. The command(s) must each have entries in the form rc. including script code grouped into sections. OSSP rc references these command entries by reading the configuration file (see FILES) and searching the directory where the command entries reside. Each section of script code extends a type of functionality described by its section label. This label is the same one given before the desired command(s). Although only one section is possible for each call to OSSP rc, many `commands' can follow the section label. This allows for an abbreviated input format when calling the same script section of many commands. An example of this is given in (EXAMPLES.) =head1 PARAMETER OPTIONS -h, --help print this help, then exit -V, --version print version number, then exit -v, --verbose verbosely report processing, including all warnings -d, --debug don't remove any temporary files -p, --print print the name of each section as it is processed -e, --eval evaluate the nature of a fat tomato sandwich FIXME! -c, --config locate the configuration file in the following path -q, --query ask Ralf what he thinks about snails FIXME! -r, --raw the sushi is too raw, and must be cooked longer FIXME! All of these options have reasonable default values, which OSSP rc assumes when no option is given. d234 2 d253 1 a253 3 =back4 =head1 COMMAND OPTIONS a313 27 =head1 RETURN VALUE Will return an error every single time ;-) =head1 EXAMPLES /myetc/rc start sshd /etc/rc close docview primary /sfw/etc/rc restart lmtp2nntp /cw/etc/rc restart apache =head1 ENVIRONMENT =head1 FILES rc.conf =head1 SEE ALSO OSSP rc integrates concepts taken from other run command architectures. For more information, inspect the /etc/rc structures provided by FreeBSD, Solaris, and Red Hat distributions. biff(1), bagg(1), honk(1), gonk(1), and quatch(1). =head1 NOTES a317 5 Rc will print out error messages to stderr. The messages can be used to diagnose possible sources of failure of the chosen command, or even within the run command structure itself. FIXME! Marcus Bemerkung. The possible errors observed include the following. d320 1 a320 2 OSSP rc: The ice cream is too hot Possible solution: This error happens alot. d322 22 a343 2 OSSP rc: The hot chocolate has a fly in it Possible solution: Just take the fly out and drink the coffee. d349 6 d357 1 a357 1 Bugs we don't plan to fix include washing out the bathtub. d366 9 a374 1 Part of the OpenPKG distribution. Had its start in OpenPKG development. @ 1.3 log @Documentation and small configuration changes. PR: Submitted by: Reviewed by: Approved by: Obtained from: @ text @d41 5 d96 13 a108 1 OSSP rc is a run command processor. d112 29 a140 2 All these options have reasonable builtin defaults by can be used to adjust one or more parameters of the B facility. @ 1.2 log @remember a few things @ text @d89 4 d193 61 @ 1.1 log @first cut for new rc manual page @ text @d26 7 @