Mon, 28 Jan 2013 17:37:18 +0100
Correct socket error reporting improvement with IPv6 portable code,
after helpful recommendation by Saúl Ibarra Corretgé on OSips devlist.
michael@13 | 1 | ## |
michael@13 | 2 | ## rc.pod -- RPM Auxiliary Tool (Manual Page) |
michael@428 | 3 | ## Copyright (c) 2000-2012 OpenPKG GmbH <http://openpkg.com/> |
michael@13 | 4 | ## |
michael@428 | 5 | ## This software is property of the OpenPKG GmbH, DE MUC HRB 160208. |
michael@428 | 6 | ## All rights reserved. Licenses which grant limited permission to use, |
michael@428 | 7 | ## copy, modify and distribute this software are available from the |
michael@428 | 8 | ## OpenPKG GmbH. |
michael@13 | 9 | ## |
michael@428 | 10 | ## THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED |
michael@13 | 11 | ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
michael@13 | 12 | ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
michael@13 | 13 | ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR |
michael@13 | 14 | ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
michael@13 | 15 | ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
michael@13 | 16 | ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
michael@13 | 17 | ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
michael@13 | 18 | ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
michael@13 | 19 | ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
michael@13 | 20 | ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
michael@13 | 21 | ## SUCH DAMAGE. |
michael@13 | 22 | ## |
michael@13 | 23 | |
michael@13 | 24 | =pod |
michael@13 | 25 | |
michael@13 | 26 | =head1 NAME |
michael@13 | 27 | |
michael@428 | 28 | B<@l_prefix@/bin/openpkg rc> - OpenPKG Run-Command Processor |
michael@13 | 29 | |
michael@13 | 30 | =head1 SYNOPSIS |
michael@13 | 31 | |
michael@428 | 32 | B<@l_prefix@/bin/openpkg rc> [B<-s>|B<--silent>] [B<-v>|B<--verbose>] [B<-d>|B<--debug>] [B<-k>|B<--keep>] [B<-D>|B<--define> I<name>=I<value>] I<package> I<command> [I<command> ...] |
michael@13 | 33 | |
michael@13 | 34 | B<@l_prefix@/bin/openpkg rc> B<-p>|B<--print> I<package> I<command> [I<command> ...] |
michael@13 | 35 | |
michael@13 | 36 | eval `B<@l_prefix@/bin/openpkg rc> B<-e>|B<--eval> I<package> I<command> [I<command> ...]` |
michael@13 | 37 | |
michael@13 | 38 | B<@l_prefix@/bin/openpkg rc> B<-q>|B<--query> I<variable> [I<variable> ...] |
michael@13 | 39 | |
michael@13 | 40 | B<@l_prefix@/bin/openpkg rc> B<-c>|B<--config> |
michael@13 | 41 | |
michael@13 | 42 | B<@l_prefix@/bin/openpkg rc> B<-h>|B<--help> |
michael@13 | 43 | |
michael@13 | 44 | =head1 DESCRIPTION |
michael@13 | 45 | |
michael@13 | 46 | The B<@l_prefix@/bin/openpkg rc> program is the run-command (rc) processor |
michael@13 | 47 | of the B<OpenPKG> instance C<@l_prefix@>. It allows querying the rc |
michael@13 | 48 | configuration variables and the execution of rc command scripts of one |
michael@13 | 49 | or more installed B<OpenPKG> packages. The implemented run-command |
michael@13 | 50 | facility is partly modeled after the classical UNIX(tm) System V |
michael@13 | 51 | run-command facility plus ideas taken from the FreeBSD and NetBSD |
michael@13 | 52 | run-command facilities. It mainly merges the classical startup/shutdown |
michael@13 | 53 | procedures with periodical procedures into a single approach. |
michael@13 | 54 | |
michael@13 | 55 | =head1 USAGE |
michael@13 | 56 | |
michael@13 | 57 | =over 4 |
michael@13 | 58 | |
michael@428 | 59 | =item B<@l_prefix@/bin/openpkg rc> [B<-s>|B<--silent>] [B<-v>|B<--verbose>] [B<-d>|B<--debug>] [B<-k>|B<--keep>] [B<-D>|B<--define> I<name>=I<value>] I<package> I<command> [I<command> ...] |
michael@13 | 60 | |
michael@428 | 61 | B<Run-Command Execution.> This executes one or more specified |
michael@13 | 62 | I<command>s in a particular I<package> or in all installed packages if |
michael@13 | 63 | I<package> is "C<all>". Option B<--silent> can be used to explicitly |
michael@13 | 64 | disable progress messages on C<stderr>. Option B<--verbose> can be used |
michael@13 | 65 | to explicitly enable progress messages on C<stderr>. By default, B<rc> |
michael@13 | 66 | automatically determines whether progress messages should be displayed |
michael@13 | 67 | or not depending on whether C<stderr> is connected to a terminal device. |
michael@13 | 68 | Option B<--keep> can be used for debugging purposes to keep the |
michael@428 | 69 | temporary files were generated during internal processing. Option |
michael@428 | 70 | B<--define> can be used to on-the-fly re-define a configuration variable |
michael@428 | 71 | I<name> with I<value>. |
michael@13 | 72 | |
michael@13 | 73 | =item B<@l_prefix@/bin/openpkg rc> B<-p>|B<--print> I<package> I<command> [I<command> ...] |
michael@13 | 74 | |
michael@428 | 75 | B<Run-Command Printing.> This is like the run-command execution (see |
michael@13 | 76 | above), but instead of immediately executing all involved individual |
michael@13 | 77 | run-command scripts, they are concatenated (but with all configuration |
michael@13 | 78 | parts reduced to a single configuration part) and printed to C<stdout>. |
michael@13 | 79 | Use this for debugging or post-processing purposes. |
michael@13 | 80 | |
michael@13 | 81 | =item eval `B<@l_prefix@/bin/openpkg rc> B<-e>|B<--eval> I<package> I<command> [I<command> ...]` |
michael@13 | 82 | |
michael@428 | 83 | B<Run-Command Evaluation.> This is like the run-command execution |
michael@13 | 84 | (see above), but the resulting exported shell environment variables |
michael@13 | 85 | are output to a temporary file as a (Bourne-Shell or C-Shell syntax) |
michael@13 | 86 | shell script, suitable for evaluation within the shell environment |
michael@13 | 87 | of the caller. A one-line script is printed to C<stdout> which then |
michael@13 | 88 | "sources" (and immediately removes) this temporary file. This is |
michael@13 | 89 | slightly different from printing the temporary script directly to |
michael@13 | 90 | C<stdout>, because not all shell implementations like to "B<eval>" |
michael@13 | 91 | large multi-line scripts. Hence, use this for executing the "C<env>" |
michael@13 | 92 | run-commands within the current shell. |
michael@13 | 93 | |
michael@13 | 94 | =item B<@l_prefix@/bin/openpkg rc> B<-q>|B<--query> I<variable> [I<variable> ...] |
michael@13 | 95 | |
michael@13 | 96 | B<Configuration Variable Querying.> This queries the effective values |
michael@13 | 97 | (see B<RUN-COMMAND CONFIGURATION> section below) of one or more |
michael@13 | 98 | run-command configuration I<variable>s. Use this within a shell script |
michael@13 | 99 | to selectively query a particular variable. |
michael@13 | 100 | |
michael@13 | 101 | =item B<@l_prefix@/bin/openpkg rc> B<-c>|B<--config> |
michael@13 | 102 | |
michael@13 | 103 | B<Configuration Variable Summary.> This displays on C<stdout> a |
michael@13 | 104 | three-column table showing the name, default and effective values of |
michael@13 | 105 | all run-command configuration variables. If C<stdout> is connected to |
michael@13 | 106 | terminal device, variables where the default and effective values differ |
michael@13 | 107 | are shown in bold mode. |
michael@13 | 108 | |
michael@13 | 109 | =item B<@l_prefix@/bin/openpkg rc> B<-h>|B<--help> |
michael@13 | 110 | |
michael@13 | 111 | B<Requesting Help.> This just displays a short summary of |
michael@13 | 112 | the usage for this program. |
michael@13 | 113 | |
michael@13 | 114 | =back |
michael@13 | 115 | |
michael@13 | 116 | =head1 FILES |
michael@13 | 117 | |
michael@13 | 118 | =head2 RUN-COMMAND FILES (C<@l_prefix@/bin/openpkg rc.d/rc.*>) |
michael@13 | 119 | |
michael@13 | 120 | The foundation of the B<OpenPKG> run-command facility are the individual |
michael@13 | 121 | run-command files C<rc.*> of the installed packages. They are all |
michael@13 | 122 | located in the directory C<@l_prefix@/bin/openpkg rc.d/> and are named |
michael@13 | 123 | "C<rc.>I<package>". They consist of one or more sections, each starting |
michael@13 | 124 | with a section header "C<%>I<name> [I<options>]" and following a GNU |
michael@13 | 125 | Bash compatible shell script. There are three classes of sections: |
michael@13 | 126 | |
michael@13 | 127 | =over 4 |
michael@13 | 128 | |
michael@13 | 129 | =item B<Special Sections> |
michael@13 | 130 | |
michael@13 | 131 | There are 2 sections which have a special meaning to the B<rc> program |
michael@13 | 132 | and cannot be used for different purposes. |
michael@13 | 133 | |
michael@13 | 134 | =over 4 |
michael@13 | 135 | |
michael@13 | 136 | =item C<%config> |
michael@13 | 137 | |
michael@13 | 138 | This section has to consist of run-command configuration |
michael@13 | 139 | variable default settings in Bourne-Shell syntax only, i.e., |
michael@13 | 140 | it has to contain one or more lines, each of exactly the form |
michael@13 | 141 | "I<package>C<_>I<variable>C<=>I<value>". Notice that in section |
michael@13 | 142 | "C<%config>" of run-command file "C<rc.foo>" the variables all have |
michael@13 | 143 | to be prefixed (by convention) with "C<foo_>". It is allowed that the |
michael@13 | 144 | I<value>s reference other variables defined before in the same section |
michael@13 | 145 | or from the "C<%config>" section of the bootstrap package "C<openpkg>". |
michael@13 | 146 | Additionally, by convention all lines have to be indented by 4 spaces. |
michael@13 | 147 | |
michael@13 | 148 | NOTICE: All sections of all run-command scripts see all C<%config> |
michael@13 | 149 | sections of all packages. |
michael@13 | 150 | |
michael@13 | 151 | =item C<%common> |
michael@13 | 152 | |
michael@13 | 153 | This section can consist of an arbitrary shell script |
michael@13 | 154 | which is automatically prepended to the shell scripts |
michael@13 | 155 | of all other sections on execution. It is usually used |
michael@13 | 156 | to define common and local variables and functions. |
michael@13 | 157 | |
michael@13 | 158 | =back |
michael@13 | 159 | |
michael@13 | 160 | =item B<Conventional Sections> |
michael@13 | 161 | |
michael@13 | 162 | There are 9 sections which have no special meaning to the B<rc> program, |
michael@13 | 163 | but are used in B<OpenPKG> by convention for standard purposes. Hence, |
michael@13 | 164 | do not use them for arbitrary things instead. |
michael@13 | 165 | |
michael@13 | 166 | Throughout these sections it is possible to specify the user to be |
michael@13 | 167 | switched to before the code is executed. |
michael@13 | 168 | |
michael@13 | 169 | A priority can be given for each section to control execution sequence |
michael@13 | 170 | if "C<all>" packages are given. Higher priority leads to earlier |
michael@13 | 171 | starting and later stopping. The priority is a number where low numbers |
michael@13 | 172 | mean high priority (numerically sorted for starting). If omitted, the |
michael@13 | 173 | priority defaults to 500. |
michael@13 | 174 | |
michael@13 | 175 | Output generated on F<stdout> and F<stderr> is captured and normally |
michael@13 | 176 | suppressed. In case the sections script exits with a non-zero return |
michael@13 | 177 | value, the intercepted messages are consolidated, reformatted with a |
michael@13 | 178 | surrounding ASCII-art border and printed to F<stderr>. If the section |
michael@13 | 179 | is tagged with option B<-o>, F<stdout> messages are passed through |
michael@13 | 180 | verbatim, even if the section script exists with a zero return value. |
michael@13 | 181 | |
michael@13 | 182 | =over 4 |
michael@13 | 183 | |
michael@13 | 184 | =item C<%start> [B<-u> I<user>] [B<-p> I<priority>] |
michael@13 | 185 | |
michael@13 | 186 | This section should start daemons or initialize components. |
michael@13 | 187 | It is especially executed by B<OpenPKG> during system startup. |
michael@13 | 188 | |
michael@13 | 189 | =item C<%stop> [B<-u> I<user>] [B<-p> I<priority>] |
michael@13 | 190 | |
michael@13 | 191 | This section should stop daemons or cleaning up components. It is |
michael@13 | 192 | especially executed by B<OpenPKG> during system shutdown and package |
michael@13 | 193 | deinstallation. |
michael@13 | 194 | |
michael@13 | 195 | =item C<%restart> [B<-u> I<user>] [B<-p> I<priority>] |
michael@13 | 196 | |
michael@13 | 197 | This section should restart daemons. |
michael@13 | 198 | It is especially executed by B<OpenPKG> during package upgrades. |
michael@13 | 199 | |
michael@13 | 200 | =item C<%status -o> [B<-u> I<user>] [B<-p> I<priority>] |
michael@13 | 201 | |
michael@13 | 202 | This section has to provide status information for a package |
michael@13 | 203 | by printing to C<stdout> (hence the B<-o> option is always required), |
michael@13 | 204 | in Bourne-Shell syntax, the definition of three variables: |
michael@13 | 205 | |
michael@13 | 206 | =over 4 |
michael@13 | 207 | |
michael@13 | 208 | =item I<package>C<_enable> |
michael@13 | 209 | |
michael@13 | 210 | Whether package is enabled, i.e., whether it accepts run-commands. This |
michael@13 | 211 | variable just has to be printed, because is already set in current |
michael@13 | 212 | script environment. |
michael@13 | 213 | |
michael@13 | 214 | =item I<package>C<_usable> |
michael@13 | 215 | |
michael@13 | 216 | Whether package is usable, i.e., whether it is already correctly |
michael@13 | 217 | configured, etc. This variable has to be individually determined. |
michael@13 | 218 | |
michael@13 | 219 | =item I<package>C<_active> |
michael@13 | 220 | |
michael@13 | 221 | Whether package is active, i.e., whether it is already running. |
michael@13 | 222 | This variable has to be individually determined. |
michael@13 | 223 | |
michael@13 | 224 | =back |
michael@13 | 225 | |
michael@13 | 226 | =item C<%monthly> [B<-u> I<user>] [B<-p> I<priority>] |
michael@13 | 227 | |
michael@13 | 228 | =item C<%weekly> [B<-u> I<user>] [B<-p> I<priority>] |
michael@13 | 229 | |
michael@13 | 230 | =item C<%hourly> [B<-u> I<user>] [B<-p> I<priority>] |
michael@13 | 231 | |
michael@13 | 232 | =item C<%quarterly> [B<-u> I<user>] [B<-p> I<priority>] |
michael@13 | 233 | |
michael@13 | 234 | These sections should perform periodical tasks for a package and |
michael@13 | 235 | are executed on a monthly, weekly, hourly or quarterly basis. |
michael@13 | 236 | |
michael@13 | 237 | =item C<%env> |
michael@13 | 238 | |
michael@13 | 239 | This section is intended to export one or more environment variables |
michael@13 | 240 | which are imported into the shell environment of the caller through the |
michael@13 | 241 | B<--eval> command line option. |
michael@13 | 242 | |
michael@13 | 243 | =back |
michael@13 | 244 | |
michael@13 | 245 | =item B<Custom Sections> |
michael@13 | 246 | |
michael@13 | 247 | All other sections are custom ones and can be fully individual to each |
michael@13 | 248 | package. Some often seen sections are C<%reload> (just reload the |
michael@13 | 249 | configuration without full stop and start procedure), C<%info> (output |
michael@13 | 250 | arbitrary information about package), etc. |
michael@13 | 251 | |
michael@13 | 252 | =back |
michael@13 | 253 | |
michael@13 | 254 | =head2 RUN-COMMAND CONFIGURATION (C<@l_prefix@/bin/openpkg rc.conf>) |
michael@13 | 255 | |
michael@13 | 256 | The run-command configuration variables defined in the "C<%config>" |
michael@13 | 257 | sections of all installed packages can be overridden by the |
michael@13 | 258 | administrator in the global file C<@l_prefix@/bin/openpkg rc.conf>. This file is |
michael@13 | 259 | usually empty, but can be filled with Bourne-Shell compatible variable |
michael@13 | 260 | assignment statements like "I<package>C<_>I<variable>=I<value>". |
michael@13 | 261 | |
michael@13 | 262 | =head2 RUN-COMMAND FUNCTIONS (C<@l_prefix@/bin/openpkg rc.func>) |
michael@13 | 263 | |
michael@13 | 264 | The file C<@l_prefix@/bin/openpkg rc.func> is prepended to the scripts of all |
michael@13 | 265 | executed run-command sections and provides reusable functions. |
michael@13 | 266 | Currently the following functions are defined: |
michael@13 | 267 | |
michael@13 | 268 | =over 4 |
michael@13 | 269 | |
michael@13 | 270 | =item B<rcMsg> [B<-e>] [B<-w>] I<message> |
michael@13 | 271 | |
michael@13 | 272 | Print a message to the output device of the run-command caller. The |
michael@13 | 273 | message is printed to the captured F<stderr> (but are visible to |
michael@13 | 274 | the caller of the run-command script only if the script fails). All |
michael@13 | 275 | messages are prefixed with "C<rc:>". If option B<-e> is given, the |
michael@13 | 276 | prefix is "C<rc:ERROR:>". If option B<-w> is given, the prefix is |
michael@13 | 277 | "C<rc:WARNING:>". |
michael@13 | 278 | |
michael@13 | 279 | =item B<rcPath> [B<-a>] [B<-r>] [B<-p>] [B<-e>] I<variable> I<dir> [I<dir> ...] |
michael@13 | 280 | |
michael@13 | 281 | Add (option B<-a>) or remove (option B<-r>) one or more I<dir>ectories |
michael@13 | 282 | to/from the colon-separated value of a I<var>able. By default, on |
michael@13 | 283 | addition, the directory is appended to the end, if option B<-p> is used |
michael@13 | 284 | the directory is prepended to the start. If option B<-e> is used, the |
michael@13 | 285 | directories are added only if they exist on the underlying filesystem. |
michael@13 | 286 | Use this function for conveniently manipulating C<PATH>, C<MANPATH>, |
michael@13 | 287 | C<INFOPATH>, C<LD_LIBRARY_PATH> and similar variables. |
michael@13 | 288 | |
michael@13 | 289 | =item B<rcTmp> [B<-i>] [B<-f>] [B<-n> I<name>] [B<-k>] |
michael@13 | 290 | |
michael@13 | 291 | Convenience interface to secure temporary file handling. Option B<-i> |
michael@13 | 292 | first has to be used to initialize a secure temporary directory (option |
michael@13 | 293 | B<-k> later will kill this again). Under option B<-f> you then can get |
michael@13 | 294 | reasonable temporary filenames under the created temporary directory. By |
michael@13 | 295 | default, the temporary filename is just "C<tmp>", but can be specified |
michael@13 | 296 | with option B<-n> to be I<name>. |
michael@13 | 297 | |
michael@13 | 298 | =item B<rcService> I<package> I<status> I<value> |
michael@13 | 299 | |
michael@13 | 300 | Convenience interface to checking the C<%status> variables |
michael@13 | 301 | I<package>C<_>I<status> which have to be provided by the C<%config> (if |
michael@13 | 302 | I<status> is "C<enable>" this is enough) and C<%status> (if I<status> is |
michael@13 | 303 | "C<enable>", "C<usable>" and "C<active>"). The B<rcService> especially |
michael@13 | 304 | caches the resolving of the variable values. Returns 0 if the resolved |
michael@13 | 305 | value is I<value>, else returns 1. |
michael@13 | 306 | |
michael@13 | 307 | =item B<rcVarIsYes> I<name> |
michael@13 | 308 | |
michael@13 | 309 | Checks whether variable I<name> has a value of "C<yes>", "C<true>", |
michael@13 | 310 | "C<on>", or "C<1>" (with arbitrary lower or upper case letters). Returns |
michael@13 | 311 | 0 if value is one of these positive ones, else returns 1. |
michael@13 | 312 | |
michael@13 | 313 | =back |
michael@13 | 314 | |
michael@13 | 315 | =head1 EXAMPLES |
michael@13 | 316 | |
michael@13 | 317 | First, an example run-command script C<@l_prefix@/bin/openpkg rc.d/rc.foo> for a |
michael@13 | 318 | fictional daemon package "C<foo>": |
michael@13 | 319 | |
michael@13 | 320 | %config |
michael@13 | 321 | foo_enable="${openpkg_rc_def}" |
michael@13 | 322 | foo_listen="127.0.0.1" |
michael@13 | 323 | foo_log_prolog="true" |
michael@13 | 324 | foo_log_epilog="true" |
michael@13 | 325 | foo_log_numfiles="10" |
michael@13 | 326 | foo_log_minsize="1M" |
michael@13 | 327 | foo_log_complevel="9" |
michael@13 | 328 | |
michael@13 | 329 | %common |
michael@13 | 330 | foo_homedir="@l_prefix@/share/foo" |
michael@13 | 331 | foo_cfgfile="@l_prefix@/etc/foo/foo.cfg" |
michael@13 | 332 | foo_pidfile="@l_prefix@/var/foo/foo.pid" |
michael@13 | 333 | foo_logfile="@l_prefix@/var/foo/foo.log" |
michael@13 | 334 | foo_signal () { |
michael@13 | 335 | if [ -f ${foo_pidfile} ]; then |
michael@13 | 336 | kill -$1 `cat ${foo_pidfile}` |
michael@13 | 337 | return $? |
michael@13 | 338 | else |
michael@13 | 339 | return 1 |
michael@13 | 340 | fi |
michael@13 | 341 | } |
michael@13 | 342 | |
michael@13 | 343 | %status |
michael@13 | 344 | foo_usable="no" |
michael@13 | 345 | if [ ".`grep '<<PASSWORD>>' ${foo_cfgfile}`" = . ]; then |
michael@13 | 346 | foo_usable="yes" |
michael@13 | 347 | fi |
michael@13 | 348 | foo_active="no" |
michael@13 | 349 | if [ -f ${foo_pidfile} ]; then |
michael@13 | 350 | foo_signal 0 |
michael@13 | 351 | if [ $? -eq 0 ]; then |
michael@13 | 352 | foo_active="yes" |
michael@13 | 353 | fi |
michael@13 | 354 | fi |
michael@13 | 355 | echo "foo_enable=${foo_enable}" |
michael@13 | 356 | echo "foo_usable=${foo_usable}" |
michael@13 | 357 | echo "foo_active=${foo_active}" |
michael@13 | 358 | |
michael@13 | 359 | %start |
michael@13 | 360 | rcService foo enable yes || exit 0 |
michael@13 | 361 | rcService foo active yes && exit 0 |
michael@13 | 362 | @l_prefix@/sbin/foo --listen ${foo_listen} |
michael@13 | 363 | |
michael@13 | 364 | %stop |
michael@13 | 365 | rcService foo enable yes || exit 0 |
michael@13 | 366 | rcService foo active yes || exit 0 |
michael@13 | 367 | foo_signal TERM |
michael@13 | 368 | |
michael@13 | 369 | %restart |
michael@13 | 370 | rcService foo enable yes || exit 0 |
michael@13 | 371 | rcService foo active yes || exit 0 |
michael@13 | 372 | rc foo stop start |
michael@13 | 373 | |
michael@13 | 374 | %daily |
michael@13 | 375 | rcService foo enable yes || exit 0 |
michael@13 | 376 | shtool rotate -f \ |
michael@13 | 377 | -n ${foo_log_numfiles} -s ${foo_log_minsize} -d \ |
michael@13 | 378 | -z ${foo_log_complevel} -o @l_rusr@ -g @l_rgrp@ -m 644 \ |
michael@13 | 379 | -P "${foo_log_prolog}" -E "${foo_log_epilog}" \ |
michael@13 | 380 | ${foo_logfile} |
michael@13 | 381 | |
michael@13 | 382 | %env |
michael@13 | 383 | if rcService foo enable yes; then |
michael@13 | 384 | FOO_HOME="$foo_homedir" |
michael@13 | 385 | export FOO_HOME |
michael@13 | 386 | fi |
michael@13 | 387 | |
michael@13 | 388 | Now, show all run-command configuration variables, their |
michael@13 | 389 | default values and their effective values of package "C<foo>": |
michael@13 | 390 | |
michael@13 | 391 | $ @l_prefix@/bin/openpkg rc --config | grep "^foo_" |
michael@13 | 392 | |
michael@13 | 393 | Override the default value of a run-command configuration |
michael@13 | 394 | variable C<foo_listen>: |
michael@13 | 395 | |
michael@13 | 396 | $ echo 'foo_listen="192.168.0.1"' >>@l_prefix@/bin/openpkg rc.conf |
michael@13 | 397 | |
michael@13 | 398 | Stop and start from scratch the package "C<foo>": |
michael@13 | 399 | |
michael@13 | 400 | $ @l_prefix@/bin/openpkg rc foo stop start |
michael@13 | 401 | |
michael@13 | 402 | Query the effective value of run-command configuration |
michael@13 | 403 | variable C<foo_enable> in a script: |
michael@13 | 404 | |
michael@13 | 405 | if [ ".`@l_prefix@/bin/openpkg rc -q foo_enable`" = .yes ]; then ... |
michael@13 | 406 | |
michael@13 | 407 | Import all environment settings from all (including "C<foo>") installed |
michael@13 | 408 | packages into the current Bourne-Shell environment: |
michael@13 | 409 | |
michael@13 | 410 | $ eval `@l_prefix@/bin/openpkg rc --eval all env` |
michael@13 | 411 | $ echo $FOO_HOME |
michael@13 | 412 | |
michael@13 | 413 | =head1 SEE ALSO |
michael@13 | 414 | |
michael@13 | 415 | B<OpenPKG> http://www.openpkg.org/ |
michael@13 | 416 | |
michael@13 | 417 | =head1 HISTORY |
michael@13 | 418 | |
michael@13 | 419 | The B<OpenPKG> run-command facility consisting of the scripts C<rc> |
michael@13 | 420 | and C<rc.func> were originally invented in November 2000 by Ralf S. |
michael@13 | 421 | Engelschall for B<OpenPKG>. They were completely worked off from scratch |
michael@13 | 422 | in July 2003 for B<OpenPKG 1.3>. |
michael@13 | 423 | |
michael@13 | 424 | =head1 AUTHOR |
michael@13 | 425 | |
michael@13 | 426 | Ralf S. Engelschall |
michael@13 | 427 | rse@engelschall.com |
michael@13 | 428 | www.engelschall.com |
michael@13 | 429 | |
michael@13 | 430 | =cut |
michael@13 | 431 |