OpenPKG CVS Repository
  http://cvs.openpkg.org/
  ____________________________________________________________________________

  Server: cvs.openpkg.org                  Name:   Ralf S. Engelschall
  Root:   /e/openpkg/cvs                   Email:  [EMAIL PROTECTED]
  Module: openpkg-src openpkg-web          Date:   18-Jul-2003 22:34:10
  Branch: HEAD                             Handle: 2003071821340602

  Added files:
    openpkg-src/openpkg     pod2man.sh rc.8 rc.pod
  Modified files:
    openpkg-src/openpkg     HISTORY lsync.8 openpkg.spec rc rc.func rc.openpkg
                            rpmtool.8
    openpkg-web             news.txt

  Log:
    Ok, now break everything ;-)
    
    rc.func:
       replace old Bourne-Shell opXXX functions with GNU Bash rcXXX
       functions and merge functionalities into less functions. Stubs for
       the old opXXX functions (mapping onto rcXXX) are still provided for
       backward compatibility reasons.
    
    rc.pod, rc.8:
       provide a new rc(8) manual page which documents rc, rc.func, rc.conf,
       rc.d/rc.*, etc.
    
    pod2man.sh:
       provide a small script for recreating the .8 files
    
    openpkg.spec:
       fix the warnings we get from RPMs build procedure
       about the missing perl/ subdirectory.
    
    rc:
       speed up run-time by using more GNU Bash features
       instead of fiddling around in 100% portable way.

  Summary:
    Revision    Changes     Path
    1.17        +1  -0      openpkg-src/openpkg/HISTORY
    1.3         BLOB        openpkg-src/openpkg/lsync.8
    1.177       +11 -1      openpkg-src/openpkg/openpkg.spec
    1.1         +4  -0      openpkg-src/openpkg/pod2man.sh
    1.40        +73 -66     openpkg-src/openpkg/rc
    1.1         +516 -0     openpkg-src/openpkg/rc.8
    1.9         +166 -113   openpkg-src/openpkg/rc.func
    1.13        +20 -22     openpkg-src/openpkg/rc.openpkg
    1.1         +413 -0     openpkg-src/openpkg/rc.pod
    1.6         +8  -8      openpkg-src/openpkg/rpmtool.8
    1.5658      +1  -0      openpkg-web/news.txt
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/HISTORY
  ============================================================================
  $ cvs diff -u -r1.16 -r1.17 HISTORY
  --- openpkg-src/openpkg/HISTORY       17 Jul 2003 09:35:15 -0000      1.16
  +++ openpkg-src/openpkg/HISTORY       18 Jul 2003 20:34:08 -0000      1.17
  @@ -2,6 +2,7 @@
   2003
   ====
   
  +20030718 rc.func: opXXX replaced by rcXXX; add rc(8) manual page; add pod2man.sh; 
fix perl/ warnings under building
   20030717 rc.func: add opService, switch to Bash; rc: rewrite --eval to use Bash; 
rpmmacros: add l_tmp{dir,file}
   20030716 cleaned and enhanced "rc" again; added %{l_value} killer macro
   20030715 work-off "rc" again: add -o/--output options, better cleanup, global 
return code
  @@ .
  (cd openpkg-src/openpkg && \
   uudecode <<'@@ .' && \
   mv lsync.8 lsync.8.orig && \
   xdelta patch lsync.8.xdelta lsync.8.orig lsync.8 && \
   rm -f lsync.8.orig lsync.8.xdelta)
  Index: openpkg-src/openpkg/lsync.8
  ============================================================================
  begin 664 lsync.8.xdelta
  M)5A$6C`P-"4````(`!``$`````````````````````!S:&EE;&$N,3$T,#$N
  M;VQD<VAI96QA+C$Q-#`Q+FYE=Q^+"`````````,#````````````'XL(````
  M`````V-@:&!F8&`PN"+;<[.?81/+RP;.&[EMAIL PROTECTED]/>#\OQP```````!4
  ()5A$6C`P-"4`
  `
  end
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/openpkg.spec
  ============================================================================
  $ cvs diff -u -r1.176 -r1.177 openpkg.spec
  --- openpkg-src/openpkg/openpkg.spec  17 Jul 2003 09:35:15 -0000      1.176
  +++ openpkg-src/openpkg/openpkg.spec  18 Jul 2003 20:34:08 -0000      1.177
  @@ -39,7 +39,7 @@
   #   o any cc(1)
   
   #   the package version/release
  -%define       V_openpkg 20030717
  +%define       V_openpkg 20030718
   
   #   the used software versions
   %define       V_rpm     4.0.2
  @@ -114,6 +114,9 @@
   Source45:     ftp://ftp.gnu.org/gnu/config/config.sub
   Source46:     make.patch
   Source47:     HISTORY
  +Source48:     pod2man.sh
  +Source49:     rc.8
  +Source50:     rc.pod
   
   #   build information
   Prefix:       %{l_prefix}
  @@ -492,6 +495,9 @@
           echo "ac_cv_path___PYTHON=true"
           echo "ac_cv_path___DOXYGEN=true"
         ) >config.cache
  +      mkdir perl >/dev/null 2>&1 || true
  +      touch perl/Makefile.in
  +      touch perl/Makefile.PL.in
         case `sh ./config.guess` in
             *-*-linux* ) nlsopt="--disable-nls" ;;
             *          ) nlsopt="--enable-nls --with-included-gettext" ;;
  @@ -704,6 +710,9 @@
         echo "exec %{l_prefix}/etc/rc \${1+\"[EMAIL PROTECTED]"}"
       ) >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rc
       chmod 755 $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rc
  +    sed -e "s:@l_prefix@:%{l_prefix}:g" \
  +        <`SOURCE rc.8` \
  +        >$RPM_BUILD_ROOT%{l_prefix}/man/man8/rc.8
   
       #   hard-code RPM tool for installation hierarchy
       #   and adjust RPM configuration files
  @@ -841,6 +850,7 @@
       %dir %{l_prefix}/man/cat9
       %{l_prefix}/man/man8/rpm.8
       %{l_prefix}/man/man8/rpm2cpio.8
  +    %{l_prefix}/man/man8/rc.8
       %{l_prefix}/man/man8/lsync.8
       %dir %{l_prefix}/sbin
       %dir %{l_prefix}/pub
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/pod2man.sh
  ============================================================================
  $ cvs diff -u -r0 -r1.1 pod2man.sh
  --- /dev/null 2003-07-18 22:34:09.000000000 +0200
  +++ pod2man.sh        2003-07-18 22:34:09.000000000 +0200
  @@ -0,0 +1,4 @@
  +#!/bin/sh
  +pod2man --section=8 --center="OpenPKG" --release="RC(8)"      --date="OpenPKG" 
--quotes=none rc.pod      >rc.8
  +pod2man --section=8 --center="OpenPKG" --release="RPMTOOL(8)" --date="OpenPKG" 
--quotes=none rpmtool.pod >rpmtool.8
  +pod2man --section=8 --center="OpenPKG" --release="LSYNC(8)"   --date="OpenPKG" 
--quotes=none lsync.pod   >lsync.8
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/rc
  ============================================================================
  $ cvs diff -u -r1.39 -r1.40 rc
  --- openpkg-src/openpkg/rc    17 Jul 2003 12:32:36 -0000      1.39
  +++ openpkg-src/openpkg/rc    18 Jul 2003 20:34:08 -0000      1.40
  @@ -1,6 +1,6 @@
   [EMAIL PROTECTED]@/lib/openpkg/bash --noprofile
   ##
  -##  @l_prefix@/etc/rc -- Run-Command Handling for OpenPKG Hierarchy
  +##  rc -- OpenPKG Run-Command Processor
   ##  Copyright (c) 2000-2003 The OpenPKG Project <http://www.openpkg.org/>
   ##  Copyright (c) 2000-2003 Ralf S. Engelschall <[EMAIL PROTECTED]>
   ##  Copyright (c) 2000-2003 Cable & Wireless <http://www.cw.com/>
  @@ -24,21 +24,37 @@
   ##  SUCH DAMAGE.
   ##
   
  -#   provide hook for "openpkg-rc" package which contains the
  -#   new OSSP rc implementation as a replacement for this script.
  -if [ -f @l_prefix@/lib/openpkg/rcng ]; then
  -    exec @l_prefix@/lib/openpkg/rcng ${1+"$@"}
  -fi
  +##
  +##  configuration
  +##
   
   #   program name, version and date
   progname="rc"
   progvers="1.2.0"
   progdate="16-Jul-2003"
   
  +#   path to OpenPKG instance
  +prefix="@l_prefix@"
  +
  +#   path to GNU bash and GNU shtool
  +bash="$prefix/lib/openpkg/bash"
  +shtool="$prefix/lib/openpkg/shtool"
  +
  +#   path to rc.d, rc.conf and rc.func
  +rcdir="$prefix/etc/rc.d"
  +rcconf="$prefix/etc/rc.conf"
  +rcfunc="$prefix/etc/rc.func"
  +
   #   helper variables
   NL="
   "
   
  +#   provide hook for "openpkg-rc" package which contains the
  +#   new OSSP rc implementation as a replacement for this script.
  +if [ -f "$prefix/lib/openpkg/rcng" ]; then
  +    exec "$prefix/lib/openpkg/rcng" ${1+"$@"}
  +fi
  +
   ##
   ##  command line option parsing
   ##
  @@ -52,13 +68,12 @@
   eval=0
   config=0
   query=0
  -rcdir="@l_prefix@/etc/rc.d"
   
   #   iterate over argument line
   while [ $# -gt 0 ]; do
       opt=$1
       case $opt in
  -        -*=*) arg=`echo "$opt" | sed 's/^[-_a-zA-Z0-9]*=//'` ;;
  +        -*=*) arg=${opt/-*=/} ;;
              *) arg='' ;;
       esac
       case $opt in
  @@ -70,7 +85,6 @@
           -e|--eval    ) eval=1        ;;
           -c|--config  ) config=1      ;;
           -q|--query   ) query=1       ;;
  -        --rcdir=*    ) rcdir=$arg    ;;
           -*           ) help="Invalid option \`$opt'"; break ;;
           *            ) break         ;;
       esac
  @@ -106,25 +120,18 @@
       fi
   fi
   
  -#   determine path to rc.conf and rc.func
  -rcconf="`echo $rcdir | sed -e 's;/rc.d$;/rc.conf;'`"
  -rcfunc="`echo $rcdir | sed -e 's;/rc.d$;/rc.func;'`"
  -
  -#   path to GNU Bash
  -bash="@l_prefix@/lib/openpkg/bash"
  -
   #   extend run-time environment with local OpenPKG tools (shtool, rpmtool, etc)
   PATH_ORIG="$PATH"
  -PATH="@l_prefix@/bin:$PATH"
  -PATH="@l_prefix@/sbin:$PATH"
  -PATH="@l_prefix@/lib/openpkg:$PATH"
  +PATH="$prefix/bin:$PATH"
  +PATH="$prefix/sbin:$PATH"
  +PATH="$prefix/lib/openpkg:$PATH"
   
   #   establish secure temporary directory
   i=0
   while [ $i -lt 10 ]; do
      tmpdir="${TMPDIR:-/tmp}/rc-`date '+%Y%m%d%H%M%S'`-$$"
      (umask 022; mkdir $tmpdir >/dev/null 2>&1) && break
  -   i=`expr $i + 1`
  +   i=$(($i + 1))
      sleep 1
   done
   if [ $i -eq 10 ]; then
  @@ -191,8 +198,8 @@
       #   determine how to print in bold mode in case output
       #   is connected to a terminal device
       if [ -t 1 ]; then
  -        [EMAIL PROTECTED]@/lib/openpkg/shtool echo -e '%B'`
  -        [EMAIL PROTECTED]@/lib/openpkg/shtool echo -e '%b'`
  +        begin_bold=`$shtool echo -e '%B'`
  +        end_bold=`$shtool echo -e '%b'`
       else
           begin_bold=""
           end_bold=""
  @@ -213,8 +220,7 @@
               begin=""
               end=""
           fi
  -        echo dummy | awk '{ printf("%s%-24s %-25s %s %-25s%s\n", begin, var, val, 
tag, def, end); }' \
  -            begin="$begin" var="$var" tag="$tag" val="\"$val\"" def="\"$def\"" 
end="$end"
  +        printf "%s%-24s %-25s %s %-25s%s\n" "$begin" "$var" "\"$val\"" "$tag" 
"\"$def\"" "$end"
       done
   
       #   stop processing immediately
  @@ -230,7 +236,7 @@
       echo "openpkg:rc:ERROR: no command(s) specified for package" 1>&2
       exit 1
   fi
  -scripts=`echo "$1" | sed -e 's;^.*rc\.;;'`
  +scripts="${1/*rc./}"
   shift
   isall=0
   if [ ".$scripts" = ".all" ]; then
  @@ -282,39 +288,39 @@
           enable=yes
   
           #   check for upgraded package with unresolved configuration file conflicts
  -        if [ -d @l_prefix@/etc/$s_name ]; then
  -            if [ ".`find @l_prefix@/etc/$s_name -print 2>/dev/null | egrep 
'.*\.rpm(new|orig|save)$'`" != . ]; then
  +        if [ -d "$prefix/etc/$s_name" -a ".$eval" != .1 ]; then
  +            if [ ".`find $prefix/etc/$s_name -print 2>/dev/null | egrep 
'.*\.rpm(new|orig|save)$'`" != . ]; then
                   echo "openpkg:rc:WARNING: package \"$s_name\" has unresolved 
configuration file conflicts" 1>&2
  -                echo "openpkg:rc:WARNING: indicated by \"*.rpm(new|orig|save)\" 
files in \"@l_prefix@/etc/$s_name\"" 1>&2
  +                echo "openpkg:rc:WARNING: indicated by \"*.rpm(new|orig|save)\" 
files in \"$prefix/etc/$s_name\"" 1>&2
               fi
           fi
   
           #   parse global script options
           #   (currently unused in OpenPKG)
  -        shebangline=`head -1 $rcdir/rc.$s_name | grep "^#!rc"`
  -        if [ ".$shebangline" != . ]; then
  -            shebangopts=`echo "$shebangline" | sed -e "s;^#!rc *;;"`
  -            set -- $shebangopts;
  -            prev=''
  -            for opt
  -            do
  -                if [ ".$prev" != . ]; then
  -                    opt="$prev$opt"
  -                    prev=''
  -                fi
  -                case $opt in
  -                    -*=*       ) arg=`echo "$opt" | sed 's/^[-_a-zA-Z0-9]*=//'` ;;
  -                    -[a-zA-Z]* ) arg=`echo "$opt" | sed 's/^-[a-zA-Z0-9]//'`    ;;
  -                              *) arg='' ;;
  -                esac
  -                case $opt in
  -                    -e|--enable  ) enable=yes ;;
  -                    -d|--disable ) enable=no  ;;
  -                    *            ) echo "openpkg:rc:WARNING: invalid global option 
\"$opt\" in \"$rcdir/rc.$s_name:#!rc\""; break ;;
  -                esac
  -                shift
  -            done
  -        fi
  +        #shebangline=`head -1 $rcdir/rc.$s_name | grep "^#!rc"`
  +        #if [ ".$shebangline" != . ]; then
  +        #    shebangopts=`echo "$shebangline" | sed -e "s;^#!rc *;;"`
  +        #    set -- $shebangopts;
  +        #    prev=''
  +        #    for opt
  +        #    do
  +        #        if [ ".$prev" != . ]; then
  +        #            opt="$prev$opt"
  +        #            prev=''
  +        #        fi
  +        #        case $opt in
  +        #            -*=*       ) arg=`echo "$opt" | sed 's/^[-_a-zA-Z0-9]*=//'` ;;
  +        #            -[a-zA-Z]* ) arg=`echo "$opt" | sed 's/^-[a-zA-Z0-9]//'`    ;;
  +        #                      *) arg='' ;;
  +        #        esac
  +        #        case $opt in
  +        #            -e|--enable  ) enable=yes ;;
  +        #            -d|--disable ) enable=no  ;;
  +        #            *            ) echo "openpkg:rc:WARNING: invalid global option 
\"$opt\" in \"$rcdir/rc.$s_name:#!rc\""; break ;;
  +        #        esac
  +        #        shift
  +        #    done
  +        #fi
   
           #   check whether command exists in script at all
           cmdline=`grep "^%$cmd" $rcdir/rc.$s_name`
  @@ -333,8 +339,8 @@
                       prev=''
                   fi
                   case $opt in
  -                    -*=*       ) arg=`echo "$opt" | sed 's/^[-_a-zA-Z0-9]*=//'` ;;
  -                    -[a-zA-Z]* ) arg=`echo "$opt" | sed 's/^-[a-zA-Z0-9]//'`    ;;
  +                    -*=*       ) arg=${opt/-*=/} ;;
  +                    -[a-zA-Z]* ) arg=${opt/-[a-zA-Z0-9]/} ;;
                                 *) arg='' ;;
                   esac
                   case $opt in
  @@ -408,8 +414,9 @@
           #   because by design all command scripts see the %config
           #   section of all(!) scripts. Because of $openpkg_rc_def the
           #   variable, we place the %config section of "openpkg" to the front.
  -        l_scripts=`/bin/ls $rcdir/rc.* | sed -e "s;^$rcdir/rc\.;;" | egrep -v 
'^openpkg$' | sort`
  +        l_scripts=`/bin/ls $rcdir/rc.* | sed -e "s;^$rcdir/rc\.;;" | egrep -v 
'^openpkg$'`
           l_scripts="openpkg $l_scripts"
  +        cat $l_scripts |\
           for l_name in $l_scripts; do
               sed <$rcdir/rc.$l_name >>$tmpfile -e "1,/^%config/d" -e '/^%.*/,$d'
           done
  @@ -424,7 +431,7 @@
       fi
   
       #   iterate over all packages (in priority order!) where the command
  -    #   iwas found n order to execute, print, or evaluate their scripts
  +    #   was found n order to execute, print, or evaluate their scripts
       verbose_pos=0
       for entry in `echo $list | tr ',' '\012' | sort -n`; do
           [ ".$entry" = . ] && continue
  @@ -444,16 +451,16 @@
   
               #   display verbose message parts: prefix (on first), separator and 
package
               if [ $verbose_pos -eq 0 ]; then
  -                echo . | awk '{ printf("OpenPKG: %s: ", cmd); }' cmd="$cmd" 1>&2
  -                l=`echo . | awk '{ printf("OpenPKG: %s: ", cmd); }' cmd="$cmd" | wc 
-c | awk '{ print $1; }'`
  -                verbose_pos=`expr $verbose_pos + $l`
  -                prefix=""
  +                output=$(printf "OpenPKG: %s: " "$cmd")
  +                echo -n "$output" 1>&2
  +                verbose_pos=$(($verbose_pos + ${#output}))
  +                output_prefix=""
               else
  -                prefix=", "
  +                output_prefix=", "
               fi
  -            echo . | awk '{ printf("%s%s", prefix, s_name); }' prefix="$prefix" 
s_name="$s_name" 1>&2
  -            l=`echo . | awk '{ printf("%s%s", prefix, s_name); }' prefix="$prefix" 
s_name="$s_name" | wc -c | awk '{ print $1; }'`
  -            verbose_pos=`expr $verbose_pos + $l`
  +            output=$(printf "%s%s" "$output_prefix" "$s_name")
  +            echo -n "$output" 1>&2
  +            verbose_pos=$(($verbose_pos + ${#output}))
           fi
   
           #   now operate on the particular script
  @@ -495,7 +502,7 @@
               #   because by design all command scripts see the %config
               #   section of all(!) scripts. Because of $openpkg_rc_def the
               #   variable, we place the %config section of "openpkg" to the front.
  -            l_scripts=`/bin/ls $rcdir/rc.* | sed -e "s;^$rcdir/rc\.;;" | egrep -v 
'^openpkg$' | sort`
  +            l_scripts=`/bin/ls $rcdir/rc.* | sed -e "s;^$rcdir/rc\.;;" | egrep -v 
'^openpkg$'`
               l_scripts="openpkg $l_scripts"
               for l_name in $l_scripts; do
                   sed <$rcdir/rc.$l_name >>$tmpfile -e "1,/^%config/d" -e '/^%.*/,$d'
  @@ -525,7 +532,7 @@
                       verbose_pos=0
                   fi
                   #   give details of execution failure
  -                ( echo "openpkg:rc:WARNING: @l_prefix@:$s_name:%$cmd: failed with 
return code $rc" 1>&2
  +                ( echo "openpkg:rc:WARNING: $prefix:$s_name:%$cmd: failed with 
return code $rc" 1>&2
                     if [ ".`cat $outfile $errfile`" != . ]; then
                         echo 
"+----Log:--------------------------------------------------------------"
                         cat $outfile $errfile | sed -e 's;^;| ;'
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/rc.8
  ============================================================================
  $ cvs diff -u -r0 -r1.1 rc.8
  --- /dev/null 2003-07-18 22:34:09.000000000 +0200
  +++ rc.8      2003-07-18 22:34:09.000000000 +0200
  @@ -0,0 +1,516 @@
  +.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
  +.\"
  +.\" Standard preamble:
  +.\" ========================================================================
  +.de Sh \" Subsection heading
  +.br
  +.if t .Sp
  +.ne 5
  +.PP
  +\fB\\$1\fR
  +.PP
  +..
  +.de Sp \" Vertical space (when we can't use .PP)
  +.if t .sp .5v
  +.if n .sp
  +..
  +.de Vb \" Begin verbatim text
  +.ft CW
  +.nf
  +.ne \\$1
  +..
  +.de Ve \" End verbatim text
  +.ft R
  +.fi
  +..
  +.\" Set up some character translations and predefined strings.  \*(-- will
  +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
  +.\" double quote, and \*(R" will give a right double quote.  | will give a
  +.\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
  +.\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
  +.\" expand to `' in nroff, nothing in troff, for use with C<>.
  +.tr \(*W-|\(bv\*(Tr
  +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
  +.ie n \{\
  +.    ds -- \(*W-
  +.    ds PI pi
  +.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
  +.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
  +.    ds L" ""
  +.    ds R" ""
  +.    ds C` 
  +.    ds C' 
  +'br\}
  +.el\{\
  +.    ds -- \|\(em\|
  +.    ds PI \(*p
  +.    ds L" ``
  +.    ds R" ''
  +'br\}
  +.\"
  +.\" If the F register is turned on, we'll generate index entries on stderr for
  +.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
  +.\" entries marked with X<> in POD.  Of course, you'll have to process the
  +.\" output yourself in some meaningful fashion.
  +.if \nF \{\
  +.    de IX
  +.    tm Index:\\$1\t\\n%\t"\\$2"
  +..
  +.    nr % 0
  +.    rr F
  +.\}
  +.\"
  +.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
  +.\" way too many mistakes in technical documents.
  +.hy 0
  +.if n .na
  +.\"
  +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
  +.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
  +.    \" fudge factors for nroff and troff
  +.if n \{\
  +.    ds #H 0
  +.    ds #V .8m
  +.    ds #F .3m
  +.    ds #[ \f1
  +.    ds #] \fP
  +.\}
  +.if t \{\
  +.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
  +.    ds #V .6m
  +.    ds #F 0
  +.    ds #[ \&
  +.    ds #] \&
  +.\}
  +.    \" simple accents for nroff and troff
  +.if n \{\
  +.    ds ' \&
  +.    ds ` \&
  +.    ds ^ \&
  +.    ds , \&
  +.    ds ~ ~
  +.    ds /
  +.\}
  +.if t \{\
  +.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
  +.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
  +.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
  +.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
  +.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
  +.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
  +.\}
  +.    \" troff and (daisy-wheel) nroff accents
  +.ds : 
\\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
  +.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
  +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
  +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
  +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
  +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
  +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
  +.ds ae a\h'-(\w'a'u*4/10)'e
  +.ds Ae A\h'-(\w'A'u*4/10)'E
  +.    \" corrections for vroff
  +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
  +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
  +.    \" for low resolution devices (crt and lpr)
  +.if \n(.H>23 .if \n(.V>19 \
  +\{\
  +.    ds : e
  +.    ds 8 ss
  +.    ds o a
  +.    ds d- d\h'-1'\(ga
  +.    ds D- D\h'-1'\(hy
  +.    ds th \o'bp'
  +.    ds Th \o'LP'
  +.    ds ae ae
  +.    ds Ae AE
  +.\}
  +.rm #[ #] #H #V #F C
  +.\" ========================================================================
  +.\"
  +.IX Title "RC 8"
  +.TH RC 8 "OpenPKG" "RC(8)" "OpenPKG"
  +.SH "NAME"
  +\&[EMAIL PROTECTED]@/etc/rc\fR \- OpenPKG Run\-Command Processor
  +.SH "SYNOPSIS"
  +.IX Header "SYNOPSIS"
  +\&[EMAIL PROTECTED]@/etc/rc\fR [\fB\-s\fR|\fB\-\-silent\fR] 
[\fB\-v\fR|\fB\-\-verbose\fR] [\fB\-d\fR|\fB\-\-debug\fR] \fIpackage\fR \fIcommand\fR 
[\fIcommand\fR ...]
  +.PP
  +\&[EMAIL PROTECTED]@/etc/rc\fR \fB\-p\fR|\fB\-\-print\fR \fIpackage\fR 
\fIcommand\fR [\fIcommand\fR ...]
  +.PP
  +eval [EMAIL PROTECTED]@/etc/rc\fR \fB\-e\fR|\fB\-\-eval\fR \fIpackage\fR 
\fIcommand\fR [\fIcommand\fR ...]`
  +.PP
  +\&[EMAIL PROTECTED]@/etc/rc\fR \fB\-q\fR|\fB\-\-query\fR \fIvariable\fR 
[\fIvariable\fR ...]
  +.PP
  +\&[EMAIL PROTECTED]@/etc/rc\fR \fB\-c\fR|\fB\-\-config\fR
  +.PP
  +\&[EMAIL PROTECTED]@/etc/rc\fR \fB\-h\fR|\fB\-\-help\fR
  +.SH "DESCRIPTION"
  +.IX Header "DESCRIPTION"
  +The [EMAIL PROTECTED]@/etc/rc\fR program is the run-command (rc) processor
  +of the \fBOpenPKG\fR instance \f(CW\*([EMAIL PROTECTED]@\*(C'\fR. It allows 
querying the rc
  +configuration variables and the execution of rc command scripts of one
  +or more installed \fBOpenPKG\fR packages. The implemented run-command
  +facility is partly modelled after the classical \s-1UNIX\s0(tm) System V
  +run-command facility plus ideas taken from the FreeBSD and NetBSD
  +run-command facilities. It mainly merges the classical startup/shutdown
  +procedures with periodical procedures into a single approach.
  +.SH "USAGE"
  +.IX Header "USAGE"
  +.IP "[EMAIL PROTECTED]@/etc/rc\fR [\fB\-s\fR|\fB\-\-silent\fR] 
[\fB\-v\fR|\fB\-\-verbose\fR] [\fB\-d\fR|\fB\-\-debug\fR] \fIpackage\fR \fIcommand\fR 
[\fIcommand\fR ...]" 4
  +.IX Item "@l_prefix@/etc/rc [-s|--silent] [-v|--verbose] [-d|--debug] package 
command [command ...]"
  +\&\fBRun-Command Execution.\fR This executes one or more specified
  +\&\fIcommand\fRs in a particular \fIpackage\fR or in all installed packages if
  +\&\fIpackage\fR is "\f(CW\*(C`all\*(C'\fR". Option \fB\-\-silent\fR can be used to 
explicitly
  +disable progress messages on \f(CW\*(C`stderr\*(C'\fR. Option \fB\-\-verbose\fR can 
be used
  +to explicitly enable progress messages on \f(CW\*(C`stderr\*(C'\fR. By default, 
\fBrc\fR
  +automatically determines whether progress messages should be displayed
  +or not depending on whether \f(CW\*(C`stderr\*(C'\fR is connected to a terminal 
device.
  +.IP "[EMAIL PROTECTED]@/etc/rc\fR \fB\-p\fR|\fB\-\-print\fR \fIpackage\fR 
\fIcommand\fR [\fIcommand\fR ...]" 4
  +.IX Item "@l_prefix@/etc/rc -p|--print package command [command ...]"
  +\&\fBRun-Command Printing.\fR This is like the run-command execution (see
  +above), but instead of immediately executing all involved individual
  +run-command scripts, they are concatenated (but with all configuration
  +parts reduced to a single configuration part) and printed to 
\f(CW\*(C`stdout\*(C'\fR.
  +Use this for debugging or post-processing purposes.
  +.IP "eval [EMAIL PROTECTED]@/etc/rc\fR \fB\-e\fR|\fB\-\-eval\fR \fIpackage\fR 
\fIcommand\fR [\fIcommand\fR ...]`" 4
  +.IX Item "eval [EMAIL PROTECTED]@/etc/rc -e|--eval package command [command ...]`"
  +\&\fBRun-Command Evaluation.\fR This is like the run-command execution
  +(see above), but the resulting exported shell environment variables
  +are output to a temporary file as a (Bourne\-Shell or C\-Shell syntax)
  +shell script, suitable for evaluation within the shell environment
  +of the caller. A one-line script is printed to \f(CW\*(C`stdout\*(C'\fR which then
  +\&\*(L"sources\*(R" (and immediately removes) this temporary file. This is
  +slightly different from printing the temporary script directly to
  +\&\f(CW\*(C`stdout\*(C'\fR, because not all shell implementations like to 
"\fBeval\fR\*(L"
  +large multi-line scripts. Hence, use this for executing the 
\*(R"\f(CW\*(C`env\*(C'\fR"
  +run-commands within the current shell.
  +.IP "[EMAIL PROTECTED]@/etc/rc\fR \fB\-q\fR|\fB\-\-query\fR \fIvariable\fR 
[\fIvariable\fR ...]" 4
  +.IX Item "@l_prefix@/etc/rc -q|--query variable [variable ...]"
  +\&\fBConfiguration Variable Querying.\fR This queries the effective values
  +(see \fBRUN-COMMAND \s-1CONFIGURATION\s0\fR section below) of one or more
  +run-command configuration \fIvariable\fRs. Use this within a shell script
  +to selectively query a particular variable.
  +.IP "[EMAIL PROTECTED]@/etc/rc\fR \fB\-c\fR|\fB\-\-config\fR" 4
  +.IX Item "@l_prefix@/etc/rc -c|--config"
  +\&\fBConfiguration Variable Summary.\fR This displays on \f(CW\*(C`stdout\*(C'\fR a
  +three-column table showing the name, default and effective values of
  +all run-command configuration variables. If \f(CW\*(C`stdout\*(C'\fR is connected to
  +terminal device, variables where the default and effective values differ
  +are shown in bold mode.
  +.IP "[EMAIL PROTECTED]@/etc/rc\fR \fB\-h\fR|\fB\-\-help\fR" 4
  +.IX Item "@l_prefix@/etc/rc -h|--help"
  +\&\fBRequesting Help.\fR This just displays a short summary of
  +the usage for this program.
  +.SH "FILES"
  +.IX Header "FILES"
  +.ie n .Sh "RUN-COMMAND \s-1FILES\s0 (\*([EMAIL PROTECTED]@/etc/rc.d/rc.*\*(C')"
  +.el .Sh "RUN-COMMAND \s-1FILES\s0 (\f(CW\*([EMAIL 
PROTECTED]@/etc/rc.d/rc.*\*(C'\fP)"
  +.IX Subsection "RUN-COMMAND FILES (@l_prefix@/etc/rc.d/rc.*)"
  +The foundation of the \fBOpenPKG\fR run-command facility are the individual
  +run-command files \f(CW\*(C`rc.*\*(C'\fR of the installed packages. They are all
  +located in the directory \f(CW\*([EMAIL PROTECTED]@/etc/rc.d/\*(C'\fR and are named
  +"\f(CW\*(C`rc.\*(C'\fR\fIpackage\fR\*(L". They consist of one or more sections, 
each starting
  +with a section header \*(R"\f(CW\*(C`%\*(C'\fR\fIname\fR [\fIoptions\fR]" and 
following a \s-1GNU\s0
  +Bash compatible shell script. There are three classes of sections:
  +.IP "\fBSpecial Sections\fR" 4
  +.IX Item "Special Sections"
  +There are 2 sections which have a special meaning to the \fBrc\fR program
  +and cannot be used for different purposes.
  +.RS 4
  +.ie n .IP "%config" 4
  +.el .IP "\f(CW%config\fR" 4
  +.IX Item "%config"
  +This section has to consist of run-command configuration
  +variable default settings in Bourne-Shell syntax only, i.e.,
  +it has to contain one or more lines, each of exactly the form
  +"\fIpackage\fR\f(CW\*(C`_\*(C'\fR\fIvariable\fR\f(CW\*(C`=\*(C'\fR\fIvalue\fR\*(L". 
Notice that in section
  +\&\*(R"\f(CW%config\fR\*(L" of run-command file \*(R"\f(CW\*(C`rc.foo\*(C'\fR\*(L" 
the variables all have
  +to be prefixed (by convention) with \*(R"\f(CW\*(C`foo_\*(C'\fR". It is allowed 
that the
  +\&\fIvalue\fRs reference other variables defined before in the same section
  +or from the "\f(CW%config\fR\*(L" section of the bootstrap package 
\*(R"\f(CW\*(C`openpkg\*(C'\fR".
  +Additionally, by convention all lines have to be indented by 4 spaces.
  +.Sp
  +\&\s-1NOTICE:\s0 All sections of all run-command scripts see all \f(CW%config\fR
  +sections of all packages.
  +.ie n .IP "%common" 4
  +.el .IP "\f(CW%common\fR" 4
  +.IX Item "%common"
  +This section can consist of an arbitrary shell script
  +which is automatically prepended to the shell scripts
  +of all other sections on execution. It is usually used
  +to define common and local variables and functions.
  +.RE
  +.RS 4
  +.RE
  +.IP "\fBConventional Sections\fR" 4
  +.IX Item "Conventional Sections"
  +There are 9 sections which have no special meaning to the \fBrc\fR program,
  +but are used in \fBOpenPKG\fR by convention for standard purposes. Hence,
  +do not use them for arbitrary things instead.
  +.RS 4
  +.ie n .IP "%start\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority]" 4
  +.el .IP "\f(CW%start\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
  +.IX Item "%start [-u user] [-p priority]"
  +This section should start daemons or initialize components.
  +It is especially executed by \fBOpenPKG\fR during system startup.
  +.ie n .IP "%stop\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority]" 4
  +.el .IP "\f(CW%stop\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
  +.IX Item "%stop [-u user] [-p priority]"
  +This section should stop daemons or cleaning up components. It is
  +especially executed by \fBOpenPKG\fR during system shutdown and package
  +deinstallation.
  +.ie n .IP "%restart\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority]" 4
  +.el .IP "\f(CW%restart\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
  +.IX Item "%restart [-u user] [-p priority]"
  +This section should restart daemons.
  +It is especially executed by \fBOpenPKG\fR during package upgrades.
  +.ie n .IP "\*(C`%status \-o\*(C'\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority]" 
4
  +.el .IP "\f(CW\*(C`%status \-o\*(C'\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR 
\fIpriority\fR]" 4
  +.IX Item "%status -o [-u user] [-p priority]"
  +This section has to provide status information for a package
  +by printing to \f(CW\*(C`stdout\*(C'\fR (hence the \fB\-o\fR option is always 
required),
  +in Bourne-Shell syntax, the definition of three variables:
  +.RS 4
  +.ie n .IP "\fIpackage\fR\*(C`_enable\*(C'" 4
  +.el .IP "\fIpackage\fR\f(CW\*(C`_enable\*(C'\fR" 4
  +.IX Item "package_enable"
  +Whether package is enabled, i.e., whether it accepts run\-commands. This
  +variable just has to be printed, because is already set in current
  +script environment.
  +.ie n .IP "\fIpackage\fR\*(C`_usable\*(C'" 4
  +.el .IP "\fIpackage\fR\f(CW\*(C`_usable\*(C'\fR" 4
  +.IX Item "package_usable"
  +Whether package is usable, i.e., whether it is already correctly
  +configured, etc. This variable has to be individually determined.
  +.ie n .IP "\fIpackage\fR\*(C`_active\*(C'" 4
  +.el .IP "\fIpackage\fR\f(CW\*(C`_active\*(C'\fR" 4
  +.IX Item "package_active"
  +Whether package is active, i.e., whether it is already running.
  +This variable has to be individually determined.
  +.RE
  +.RS 4
  +.RE
  +.ie n .IP "%monthly\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority]" 4
  +.el .IP "\f(CW%monthly\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
  +.IX Item "%monthly [-u user] [-p priority]"
  +.PD 0
  +.ie n .IP "%weekly\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority]" 4
  +.el .IP "\f(CW%weekly\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
  +.IX Item "%weekly [-u user] [-p priority]"
  +.ie n .IP "%hourly\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority]" 4
  +.el .IP "\f(CW%hourly\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
  +.IX Item "%hourly [-u user] [-p priority]"
  +.ie n .IP "%quarterly\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority]" 4
  +.el .IP "\f(CW%quarterly\fR [\fB\-u\fR \fIuser\fR] [\fB\-p\fR \fIpriority\fR]" 4
  +.IX Item "%quarterly [-u user] [-p priority]"
  +.PD
  +These sections should perform periodical tasks for a package and
  +are executed on a monthly, weekly, hourly or quarterly basis.
  +.ie n .IP "%env" 4
  +.el .IP "\f(CW%env\fR" 4
  +.IX Item "%env"
  +This section is intended to export one or more environment variables
  +which are imported into the shell environment of the caller through the
  +\&\fB\-\-eval\fR command line option.
  +.RE
  +.RS 4
  +.RE
  +.IP "\fBCustom Sections\fR" 4
  +.IX Item "Custom Sections"
  +All other sections are custom ones and can be fully individual to each
  +package. Some often seen sections are \f(CW%reload\fR (just reload the
  +configuratio without full stop and start procedure), \f(CW%info\fR (output
  +arbitrary information about package), etc.
  +.ie n .Sh "RUN-COMMAND \s-1CONFIGURATION\s0 (\*([EMAIL 
PROTECTED]@/etc/rc.conf\*(C')"
  +.el .Sh "RUN-COMMAND \s-1CONFIGURATION\s0 (\f(CW\*([EMAIL 
PROTECTED]@/etc/rc.conf\*(C'\fP)"
  +.IX Subsection "RUN-COMMAND CONFIGURATION (@l_prefix@/etc/rc.conf)"
  +The run-command configuration variables defined in the "\f(CW%config\fR"
  +sections of all installed packages can be overridden by the
  +administrator in the global file \f(CW\*([EMAIL PROTECTED]@/etc/rc.conf\*(C'\fR. 
This file is
  +usually empty, but can be filled with Bourne-Shell compatible variable
  +assignment statements like 
"\fIpackage\fR\f(CW\*(C`_\*(C'\fR\fIvariable\fR=\fIvalue\fR".
  +.ie n .Sh "RUN-COMMAND \s-1FUNCTIONS\s0 (\*([EMAIL PROTECTED]@/etc/rc.func\*(C')"
  +.el .Sh "RUN-COMMAND \s-1FUNCTIONS\s0 (\f(CW\*([EMAIL 
PROTECTED]@/etc/rc.func\*(C'\fP)"
  +.IX Subsection "RUN-COMMAND FUNCTIONS (@l_prefix@/etc/rc.func)"
  +The file \f(CW\*([EMAIL PROTECTED]@/etc/rc.func\*(C'\fR is prepended to the scripts 
of all
  +executed run-command sections and provides reusable functions.
  +Currently the following functions are defined:
  +.IP "\fBrcMsg\fR [\fB\-e\fR] [\fB\-w\fR] \fImessage\fR" 4
  +.IX Item "rcMsg [-e] [-w] message"
  +Print a message to the output device of the run-command caller. The
  +message is printed to the original \fIstderr\fR of the \fBrc\fR command, not
  +to the redirected and captured one (which is displayed on run-command
  +script failure only). All messages are prefixed with "\f(CW\*(C`rc:\*(C'\fR". If 
option
  +\&\fB\-e\fR is given, the prefix is "\f(CW\*(C`rc:ERROR:\*(C'\fR". If option 
\fB\-w\fR is given,
  +the prefix is "\f(CW\*(C`rc:WARNING:\*(C'\fR". Use this function for very important
  +messages only.
  +.IP "\fBrcPath\fR [\fB\-a\fR] [\fB\-r\fR] [\fB\-p\fR] [\fB\-e\fR] \fIvariable\fR 
\fIdir\fR [\fIdir\fR ...]" 4
  +.IX Item "rcPath [-a] [-r] [-p] [-e] variable dir [dir ...]"
  +Add (option \fB\-a\fR) or remove (option \fB\-r\fR) one or more \fIdir\fRectories
  +to/from the colon-seperated value of a \fIvar\fRable. By default, on
  +addition, the directory is appended to the end, if option \fB\-p\fR is used
  +the directory is prepended to the start. If option \fB\-e\fR is used, the
  +directories are added only if they exist on the underlying filesystem.
  +Use this function for conviniently manipulating \f(CW\*(C`PATH\*(C'\fR, 
\f(CW\*(C`MANPATH\*(C'\fR,
  +\&\f(CW\*(C`INFOPATH\*(C'\fR, \f(CW\*(C`LD_LIBRARY_PATH\*(C'\fR and similar 
variables.
  +.IP "\fBrcTmp\fR [\fB\-i\fR] [\fB\-f\fR] [\fB\-n\fR \fIname\fR] [\fB\-k\fR]" 4
  +.IX Item "rcTmp [-i] [-f] [-n name] [-k]"
  +Convinience interface to secure temporary file handling. Option \fB\-i\fR
  +first has to be used to initialize a secure temporary directory (option
  +\&\fB\-k\fR later will kill this again). Under option \fB\-f\fR you then can get
  +reasonable temporary filenames under the created temporary directory. By
  +default, the temporary filename is just "\f(CW\*(C`tmp\*(C'\fR", but can be 
specified
  +with option \fB\-n\fR to be \fIname\fR.
  +.IP "\fBrcService\fR \fIpackage\fR \fIstatus\fR \fIvalue\fR" 4
  +.IX Item "rcService package status value"
  +Convinience interface to checking the \f(CW%status\fR variables
  +\&\fIpackage\fR\f(CW\*(C`_\*(C'\fR\fIstatus\fR which have to be provided by the 
\f(CW%config\fR (if
  +\&\fIstatus\fR is "\f(CW\*(C`enable\*(C'\fR" this is enough) and \f(CW%status\fR 
(if \fIstatus\fR is
  +"\f(CW\*(C`enable\*(C'\fR\*(L", \*(R"\f(CW\*(C`usable\*(C'\fR\*(L" and 
\*(R"\f(CW\*(C`active\*(C'\fR"). The \fBrcService\fR especially
  +caches the resolving of the variable values. Returns 0 if the resolved
  +value is \fIvalue\fR, else return 1.
  +.IP "\fBrcVarIsYes\fR \fIname\fR" 4
  +.IX Item "rcVarIsYes name"
  +Checks whether variable \fIname\fR has a value of "\f(CW\*(C`yes\*(C'\fR\*(L", 
\*(R"\f(CW\*(C`true\*(C'\fR\*(L",
  +\&\*(R"\f(CW\*(C`on\*(C'\fR\*(L", or \*(R"\f(CW1\fR" (with arbitrary lower or upper 
case letters). Returns
  +0 if value is one of these positive ones, else returns 0.
  +.SH "EXAMPLES"
  +.IX Header "EXAMPLES"
  +First, an example run-command script \f(CW\*([EMAIL 
PROTECTED]@/etc/rc.d/rc.foo\*(C'\fR for a
  +fictional daemon package "\f(CW\*(C`foo\*(C'\fR":
  +.PP
  +.Vb 8
  +\& %config
  +\&    foo_enable="${openpkg_rc_def}"
  +\&    foo_listen="127.0.0.1"
  +\&    foo_log_prolog="true"
  +\&    foo_log_epilog="true"
  +\&    foo_log_numfiles="10"
  +\&    foo_log_minsize="1M"
  +\&    foo_log_complevel="9"
  +.Ve
  +.PP
  +.Vb 13
  +\& %common
  +\&    foo_homedir="@l_prefix@/share/foo"
  +\&    foo_cfgfile="@l_prefix@/etc/foo/foo.cfg"
  +\&    foo_pidfile="@l_prefix@/var/foo/foo.pid"
  +\&    foo_logfile="@l_prefix@/var/foo/foo.log"
  +\&    foo_signal () {
  +\&        if [ -f ${foo_pidfile} ]; then
  +\&            kill -$1 `cat ${foo_pidfile}`
  +\&            return $?
  +\&        else
  +\&            return 1
  +\&        fi
  +\&    }
  +.Ve
  +.PP
  +.Vb 15
  +\& %status
  +\&     foo_usable="no"
  +\&     if [ ".`grep '<<PASSWORD>>' ${foo_cfgfile}`" = . ]; then
  +\&         foo_usable="yes"
  +\&     fi
  +\&     foo_active="no"
  +\&     if [ -f ${foo_pidfile} ]; then
  +\&         foo_signal 0
  +\&         if [ $? -eq 0 ]; then
  +\&             foo_active="yes"
  +\&         fi
  +\&     fi
  +\&     echo "foo_enable=${foo_enable}"
  +\&     echo "foo_usable=${foo_usable}"
  +\&     echo "foo_active=${foo_active}"
  +.Ve
  +.PP
  +.Vb 4
  +\& %start
  +\&     rcService foo enable yes || exit 0
  +\&     rcService foo active yes && exit 0
  +\&     @l_prefix@/sbin/foo --listen ${foo_listen}
  +.Ve
  +.PP
  +.Vb 4
  +\& %stop
  +\&     rcService foo enable yes || exit 0
  +\&     rcService foo active yes || exit 0
  +\&     foo_signal TERM
  +.Ve
  +.PP
  +.Vb 4
  +\& %restart
  +\&     rcService foo enable yes || exit 0
  +\&     rcService foo active yes || exit 0
  +\&     rc foo stop start
  +.Ve
  +.PP
  +.Vb 7
  +\& %daily
  +\&     rcService foo enable yes || exit 0
  +\&     shtool rotate -f \e
  +\&         -n ${foo_log_numfiles} -s ${foo_log_minsize} -d \e
  +\&         -z ${foo_log_complevel} -o @l_rusr@ -g @l_rgrp@ -m 644 \e
  +\&         -P "${foo_log_prolog}" -E "${foo_log_epilog}" \e
  +\&         ${foo_logfile}
  +.Ve
  +.PP
  +.Vb 5
  +\& %env
  +\&     if rcService foo enable yes; then
  +\&         FOO_HOME="$foo_homedir"
  +\&         export FOO_HOME
  +\&     fi
  +.Ve
  +.PP
  +Now, show all run-command configuration variables, their
  +default values and their effective values of package "\f(CW\*(C`foo\*(C'\fR":
  +.PP
  +.Vb 1
  +\& $ @l_prefix@/etc/rc --config | grep "^foo_"
  +.Ve
  +.PP
  +Override the default value of a run-command configuration
  +variable \f(CW\*(C`foo_listen\*(C'\fR:
  +.PP
  +.Vb 1
  +\& $ echo 'foo_listen="192.168.0.1"' >>@l_prefix@/etc/rc.conf
  +.Ve
  +.PP
  +Stop and start from scratch the package "\f(CW\*(C`foo\*(C'\fR":
  +.PP
  +.Vb 1
  +\& $ @l_prefix@/etc/rc foo stop start
  +.Ve
  +.PP
  +Query the effective value of run-command configuration
  +variable \f(CW\*(C`foo_enable\*(C'\fR in a script:
  +.PP
  +.Vb 1
  +\& if [ "[EMAIL PROTECTED]@/etc/rc -q foo_enable`" = .yes ]; then ...
  +.Ve
  +.PP
  +Import all environment settings from all (including "\f(CW\*(C`foo\*(C'\fR") 
installed
  +packages into the current Bourne-Shell environment:
  +.PP
  +.Vb 2
  +\& $ eval [EMAIL PROTECTED]@/etc/rc --eval all env`
  +\& $ echo $FOO_HOME
  +.Ve
  +.SH "SEE ALSO"
  +.IX Header "SEE ALSO"
  +\&\fBOpenPKG\fR http://www.openpkg.org/
  +.SH "HISTORY"
  +.IX Header "HISTORY"
  +The \fBOpenPKG\fR run-command facility consisting of the scripts 
\f(CW\*(C`rc\*(C'\fR
  +and \f(CW\*(C`rc.func\*(C'\fR were originally invented in November 2000 by Ralf S.
  +Engelschall for \fBOpenPKG\fR. They were completely worked off from scratch
  +in July 2003 for \fBOpenPKG 1.3\fR.
  +.SH "AUTHOR"
  +.IX Header "AUTHOR"
  +.Vb 3
  +\& Ralf S. Engelschall
  +\& [EMAIL PROTECTED]
  +\& www.engelschall.com
  +.Ve
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/rc.func
  ============================================================================
  $ cvs diff -u -r1.8 -r1.9 rc.func
  --- openpkg-src/openpkg/rc.func       17 Jul 2003 09:35:15 -0000      1.8
  +++ openpkg-src/openpkg/rc.func       18 Jul 2003 20:34:08 -0000      1.9
  @@ -23,171 +23,224 @@
   ##  SUCH DAMAGE.
   ##
   
  -#
  -#   display an error message.
  -#
  -#   Usage:   opErr <message>
  -#   Example: opErr "invalid command line"
  -#
  -opErr () {
  -    echo "OpenPKG:ERROR: $*" 1>&2
  -    exit 1
  -}
  +##
  +##  NOTICE: This script is a collection of reusable shell functions
  +##  running under GNU Bash during the execution of OpenPKG run-command
  +##  sections.
  +##
   
   #
  -#   display a warning message.
  +#   rcMsg (display message)
   #
  -#   Usage:   opWarn <message>
  -#   Example: opWarn "unknown variable"
  +#   Usage:       rcMsg [-e] [-w] <message>
  +#   Example:     rcMsg -e "invalid command line"
  +#   Description: display a regular/warning/error message.
   #
  -opWarn () {
  -    echo "OpenPKG:WARNING: $*" 1>&2
  +rcMsg () {
  +    local prefix="rc:"
  +    while [ $# -gt 0 ]; do
  +        case $1 in
  +            -e ) prefix="${prefix}ERROR:";   shift ;;
  +            -w ) prefix="${prefix}WARNING:"; shift ;;
  +            *  ) break ;;
  +        esac
  +    done
  +    echo "${prefix} $*"
  +    return 0
   }
   
   #
  -#   append (or optionally prepend) one or more directories (optionally
  -#   have to be existing) to a colon-separated path variable. In case a
  -#   directory already exists, it is first removed.
  +#   rcPath (manipulate colon-separated PATH-style variable)
   #
  -#   Usage:   opPathAdd [-p] [-e] <variable> <dir> [<dir> ...]
  -#   Example: opPathAdd -e PATH /bin /sbin /usr/bin /usr/sbin /usr/ccs/bin
  +#   Usage:       rcPath [-a] [-r] [-p] [-e] <var> <dir> [<dir> ...]
  +#   Example:     rcPathAdd -a -e PATH /bin /sbin /usr/bin /usr/sbin /usr/ccs/bin
  +#   Description: removes (-r) or adds (-a) by appending or prepending
  +#                (-p) one or more directories <dir> (optionally have
  +#                to be existing if -e is given) to a colon-separated
  +#                PATH-style variable <var>. In case a directory already
  +#                exists, it is first removed.
   #
  -opPathAdd () {
  +rcPath () {
  +    local mode=""
       local prepend=0
       local exists=0
       while [ $# -gt 0 ]; do
           case $1 in
  -            -p ) prepend=1; shift ;;
  -            -e ) exists=1;  shift ;;
  -            *  ) break ;;
  +            -a ) mode="add";    shift ;;
  +            -r ) mode="remove"; shift ;;
  +            -p ) prepend=1;     shift ;;
  +            -e ) exists=1;      shift ;;
  +            *  ) break                ;;
           esac
       done
       local var="$1"
       shift
  -    local edit_del=""
  -    local edit_add=""
  -    local dir
  -    for dir in "$@"; do
  -        if [ ".${exists}" = .1 ] && [ ! -d "${dir}" ]; then
  -            continue
  +    if [ ".${mode}" = .add ]; then
  +        local edit_del=""
  +        local edit_add=""
  +        local dir
  +        for dir in "$@"; do
  +            if [ ".${exists}" = .1 ] && [ ! -d "${dir}" ]; then
  +                continue
  +            fi
  +            edit_del="${edit_del} -e 's;^${dir}\$;;' -e 's;^${dir}:;;'"
  +            edit_del="${edit_del} -e 's;:${dir}:;:;' -e 's;:${dir}\$;;'"
  +            if [ ".${prepend}" = .0 ]; then
  +                edit_add="${edit_add} -e 's;\$;:${dir};'"
  +            else
  +                edit_add="-e 's;^;${dir}:;' ${edit_add}"
  +            fi
  +        done
  +        if [ ".${edit_del}${edit_add}" != . ]; then
  +            eval "${var}=\`echo \"\$${var}\" | sed ${edit_del} ${edit_add}\`"
           fi
  -        edit_del="${edit_del} -e 's;^${dir}\$;;' -e 's;^${dir}:;;'"
  -        edit_del="${edit_del} -e 's;:${dir}:;:;' -e 's;:${dir}\$;;'"
  -        if [ ".${prepend}" = .0 ]; then
  -            edit_add="${edit_add} -e 's;\$;:${dir};'"
  +        return 0
  +    elif [ ".${mode}" = .remove ]; then
  +        local edit=""
  +        local dir
  +        for dir in "$@"; do
  +            edit="${edit} -e 's;^${dir}\$;;' -e 's;^${dir}:;;'"
  +            edit="${edit} -e 's;:${dir}:;:;' -e 's;:${dir}\$;;'"
  +        done
  +        eval "${var}=\`echo \"\$${var}\" | sed ${edit}\`"
  +        return 0
  +    else
  +        rcMsg -e "rcPath: neither add (-a) nor remove (-r) operation specified"
  +        return 1
  +    fi
  +}
  +
  +#
  +#   rcTmp (temporary file handling)
  +#
  +#   Usage:       rcTmp [-i] [-f [-n <name>]] [-k]
  +#   Example:     rcTmp -i; tmpfile=`rcTmp -f -n tmp`; ...; rcTmp -k
  +#   Description: 
  +#
  +rcTmp () {
  +    local mode=""
  +    local name=""
  +    while [ $# -gt 0 ]; do
  +        case $1 in
  +            -i ) mode="init"; shift        ;;
  +            -f ) mode="file"; shift        ;;
  +            -k ) mode="kill"; shift        ;;
  +            -n ) name="$2";   shift; shift ;;
  +            *  ) break                     ;;
  +        esac
  +    done
  +    if [ ".${mode}" = .init ]; then
  +        if [ ".${RC_TMPDIR}" = . ]; then
  +            local i=0
  +            while [ ${i} -lt 10 ]; do
  +               RC_TMPDIR="@l_prefix@/RPM/TMP/rc-`date '+%Y%m%d%H%M%S'`-$$"
  +               (umask 022; mkdir ${RC_TMPDIR} >/dev/null 2>&1) && break
  +               i=$((${i} + 1))
  +               sleep 1
  +            done
  +            if [ ${i} -eq 10 ]; then
  +                rcMsg -e "rcTmp: unable to establish secure temporary directory" 
1>&2
  +                return 1
  +            fi
  +            declare -r RC_TMPDIR
  +        fi
  +        return 0
  +    elif [ ".${mode}" = .file ]; then
  +        return "${RC_TMPDIR}/${name:-tmp}"
  +    elif [ ".${mode}" = .kill ]; then
  +        if [ ".${RC_TMPDIR}" = . ]; then
  +            rcMsg -e "rcTmp: no secure temporary directory known"
  +            return 1
           else
  -            edit_add="-e 's;^;${dir}:;' ${edit_add}"
  +            rm -rf ${RC_TMPDIR}
  +            return 0
           fi
  -    done
  -    if [ ".${edit_del}${edit_add}" != . ]; then
  -        eval "${var}=\`echo \"\$${var}\" | sed ${edit_del} ${edit_add}\`"
  +    else
  +        rcMsg -e "rcTmp: neither init (-i), file (-f) nor kill (-k) operation 
specified"
  +        return 1
       fi
   }
   
   #
  -#   remove one or more directories from a colon-separated path variable
  +#   rcService (check for service status enable/active/usable)
   #
  -#   Usage:   opPathDel <variable> <dir> [<dir> ...]
  -#   Example: opPathDel PATH /bin /sbin /usr/bin /usr/sbin /usr/ccs/bin
  +#   Usage:       rcService <pkg> <service> <val>
  +#   Example:     if rcService openssh enable yes; then ...
  +#   Description: check <service> of package <pkg> against value <val>.
  +#                <service> has to be one of "enable", "active" or "usable".
  +#                <val> has to be either "no", "yes", or "unknown".
   #
  -opPathDel () {
  -    local var="$1"
  -    shift
  -    local edit=""
  -    local dir
  -    for dir in "$@"; do
  -        edit="${edit} -e 's;^${dir}\$;;' -e 's;^${dir}:;;'"
  -        edit="${edit} -e 's;:${dir}:;:;' -e 's;:${dir}\$;;'"
  -    done
  -    eval "${var}=\`echo \"\$${var}\" | sed ${edit}\`"
  +rcService () {
  +    local pkg="`echo ${1} | sed -e 's;-;_;g'`"
  +    local var="${pkg}_${2}"
  +    local chk="${3}"
  +    eval "local val=\$${var}"
  +    if [ ".${val}" = . ]; then
  +        eval `rc ${1} status`
  +        eval "local val=\$${var}"
  +    fi
  +    if [ ".${val}" = ".${chk}" ]; then
  +        return 0
  +    else
  +        return 1
  +    fi
   }
   
   #
  -#   check whether a variable contains a positive "Yes" value.
  +#   rcVarIsYes (check variable for positive value)
   #
  -#   Usage:   opVarIsYes <variable>
  -#   Example: if opVarIsYes foo; then ...
  +#   Usage:       rcVarIsYes <var>
  +#   Example:     if rcVarIsYes foo; then ...
  +#   Description: check whether a variable <var> contains a positive
  +#                value, i.e., the values "yes", "true", "on" or "1" in
  +#                arbitrary lower or upper case.
   #
  -opVarIsYes () {
  +rcVarIsYes () {
       local var="${1}"
       eval "local val=\"\$${var}\""
       case "${val}" in
           [Yy][Ee][Ss] | [Tt][Rr][Uu][Ee] | [Oo][Nn] | 1 )
               return 0
               ;;
  -        [Nn][Oo] | [Ff][Aa][Ll][Ss][Ee] | [Oo][Ff][Ff] | 0 )
  -            return 1
  -            ;;
  -        *)
  -            opWarn "variable \$${var} is not set properly."
  +        * )
               return 1
               ;;
       esac
   }
   
   #
  -#   FIXME: this function is now already deprecated!
  -#
  -#   check whether a service is enabled.
  -#
  -#   Usage:   opServiceEnabled <variable>
  -#   Example: if opServiceEnabled openssh; then ...
  +#   BACKWARD COMPATIBILITY FOR OPENPKG 1.2 ONLY:
  +#   Mapping between old opXXX and new rcXXX functions.
   #
  +
  +opWarn () {
  +    rcMsg -w "$*"
  +}
  +opErr () {
  +    rcMsg -e "$*"
  +}
  +opPathAdd () {
  +    rcPath -a "$@"
  +}
  +opPathDel () {
  +    rcPath -r "$@"
  +}
   opServiceEnabled () {
  -    opVarIsYes "`echo ${1} | sed -e 's;-;_;g'`_enable"
  +    rcService ${1} enable yes
   }
  -
  -#
  -#   check for service status enable/active/usable.
  -#
  -#   Usage:   opService <pkg> <var> <val>
  -#   Example: if opService openssh enable yes; then ...
  -#
   opService () {
  -    local pkg="`echo ${1} | sed -e 's;-;_;g'`"
  -    local var="${pkg}_${2}"
  -    local chk="${3}"
  -    eval "local val=\$${var}"
  -    if [ ".$val" = . ]; then
  -        eval `rc ${1} status`
  -        eval "local val=\$${var}"
  -    fi
  -    test ".$val" = ".$chk"
  -    return $?
  +    rcService "$@"
   }
  -
  -#
  -#   generate temporary file directory
  -#
  -#   Usage:   opTmpDirGen <program>
  -#   Example: opTmpDirGen openssh
  -#
   opTmpDirGen () {
  -    local tmpdir="@l_prefix@/RPM/TMP/${1}"
  -    rm -rf ${tmpdir} >/dev/null 2>&1 || true
  -    (umask 077; mkdir ${tmpdir} >/dev/null 2>&1 || true)
  +    rcTmp -i -p ${1}
   }
  -
  -#
  -#   set filename of temporary file
  -#
  -#   Usage:   opTmpDirFile <program> <filename> <variable>
  -#   Example: opTmpDirFile openssh 0 tmpfile
  -#
   opTmpDirFile () {
  -    local tmpdir="@l_prefix@/RPM/TMP/${1}"
  -    eval "${3}=\"${tmpdir}/${2}\""
  -    (umask 077; touch "${tmpdir}/${2}" >/dev/null 2>&1 || true)
  +    eval "${3}=\$(rcTmp -f -n ${2})"
   }
  -
  -#
  -#   delete temporary file directory
  -#
  -#   Usage:   opTmpDirDel <program>
  -#   Example: opTmpDirDel openssh
  -#
   opTmpDirDel () {
  -    local tmpdir="@l_prefix@/RPM/TMP/${1}"
  -    rm -rf ${tmpdir} >/dev/null 2>&1 || true
  +    rcTmp -k
  +}
  +opVarIsYes () {
  +    rcVarIsYes "$@"
   }
   
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/rc.openpkg
  ============================================================================
  $ cvs diff -u -r1.12 -r1.13 rc.openpkg
  --- openpkg-src/openpkg/rc.openpkg    17 Jul 2003 21:34:54 -0000      1.12
  +++ openpkg-src/openpkg/rc.openpkg    18 Jul 2003 20:34:08 -0000      1.13
  @@ -10,42 +10,40 @@
       openpkg_envprio="high"
   
   %env -p0
  -    opService openpkg enable yes || exit 0
  +    rcService openpkg enable yes || exit 0
  +
       #   determine append (low prio) or prepend (high prio) mode
  -    opt_prepend=""
  +    local opt_prepend=""
       if [ ".$openpkg_envprio" = ".high" ]; then
           opt_prepend="-p"
       fi
   
       #   make sure the software package executables are found
       export PATH
  -    opPathAdd -e PATH \
  -              /bin /sbin /usr/bin /usr/sbin
  -    opPathAdd ${opt_prepend} PATH \
  -              @l_prefix@/bin @l_prefix@/sbin \
  -              @l_prefix@/local/bin @l_prefix@/local/sbin
  +    rcPath -a -e PATH \
  +        /bin /sbin /usr/bin /usr/sbin
  +    rcPath -a ${opt_prepend} PATH \
  +        @l_prefix@/bin @l_prefix@/sbin \
  +        @l_prefix@/local/bin @l_prefix@/local/sbin
   
       #   make sure the software package manual pages are found
       export MANPATH
  -    opPathAdd -e MANPATH \
  -              /usr/man /usr/share/man
  -    opPathAdd ${opt_prepend} MANPATH \
  -              @l_prefix@/man @l_prefix@/local/man
  +    rcPath -a -e MANPATH \
  +        /usr/man /usr/share/man
  +    rcPath -a ${opt_prepend} MANPATH \
  +        @l_prefix@/man @l_prefix@/local/man
   
       #   make sure the software package info pages are found
       export INFOPATH
  -    opPathAdd -e INFOPATH \
  -              /usr/info /usr/share/info
  -    opPathAdd ${opt_prepend} INFOPATH \
  -              @l_prefix@/info @l_prefix@/local/info
  +    rcPath -a -e INFOPATH \
  +        /usr/info /usr/share/info
  +    rcPath -a ${opt_prepend} INFOPATH \
  +        @l_prefix@/info @l_prefix@/local/info
   
       #   make sure the software package libraries are found
       export LD_LIBRARY_PATH
  -    opPathAdd -e LD_LIBRARY_PATH \
  -              /lib /usr/lib
  -    opPathAdd ${opt_prepend} LD_LIBRARY_PATH \
  -              @l_prefix@/lib @l_prefix@/local/lib
  -
  -    #   cleanup environment
  -    unset opt_prepend
  +    rcPath -a -e LD_LIBRARY_PATH \
  +        /lib /usr/lib
  +    rcPath -a ${opt_prepend} LD_LIBRARY_PATH \
  +        @l_prefix@/lib @l_prefix@/local/lib
   
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/rc.pod
  ============================================================================
  $ cvs diff -u -r0 -r1.1 rc.pod
  --- /dev/null 2003-07-18 22:34:09.000000000 +0200
  +++ rc.pod    2003-07-18 22:34:09.000000000 +0200
  @@ -0,0 +1,413 @@
  +##
  +##  rc.pod -- RPM Auxiliary Tool (Manual Page)
  +##  Copyright (c) 2000-2003 The OpenPKG Project <http://www.openpkg.org/>
  +##  Copyright (c) 2000-2003 Ralf S. Engelschall <[EMAIL PROTECTED]>
  +##  Copyright (c) 2000-2003 Cable & Wireless <http://www.cw.com/>
  +##
  +##  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<@l_prefix@/etc/rc> - OpenPKG Run-Command Processor
  +
  +=head1 SYNOPSIS
  +
  +B<@l_prefix@/etc/rc> [B<-s>|B<--silent>] [B<-v>|B<--verbose>] [B<-d>|B<--debug>] 
I<package> I<command> [I<command> ...]
  +
  +B<@l_prefix@/etc/rc> B<-p>|B<--print> I<package> I<command> [I<command> ...]
  +
  +eval `B<@l_prefix@/etc/rc> B<-e>|B<--eval> I<package> I<command> [I<command> ...]`
  +
  +B<@l_prefix@/etc/rc> B<-q>|B<--query> I<variable> [I<variable> ...]
  +
  +B<@l_prefix@/etc/rc> B<-c>|B<--config>
  +
  +B<@l_prefix@/etc/rc> B<-h>|B<--help>
  +
  +=head1 DESCRIPTION
  +
  +The B<@l_prefix@/etc/rc> program is the run-command (rc) processor
  +of the B<OpenPKG> instance C<@l_prefix@>. It allows querying the rc
  +configuration variables and the execution of rc command scripts of one
  +or more installed B<OpenPKG> packages. The implemented run-command
  +facility is partly modeled after the classical UNIX(tm) System V
  +run-command facility plus ideas taken from the FreeBSD and NetBSD
  +run-command facilities. It mainly merges the classical startup/shutdown
  +procedures with periodical procedures into a single approach.
  +
  +=head1 USAGE
  +
  +=over 4
  +
  +=item B<@l_prefix@/etc/rc> [B<-s>|B<--silent>] [B<-v>|B<--verbose>] 
[B<-d>|B<--debug>] I<package> I<command> [I<command> ...]
  +
  +B<Run-Command Execution.> This executes one or more specified
  +I<command>s in a particular I<package> or in all installed packages if
  +I<package> is "C<all>". Option B<--silent> can be used to explicitly
  +disable progress messages on C<stderr>. Option B<--verbose> can be used
  +to explicitly enable progress messages on C<stderr>. By default, B<rc>
  +automatically determines whether progress messages should be displayed
  +or not depending on whether C<stderr> is connected to a terminal device.
  +
  +=item B<@l_prefix@/etc/rc> B<-p>|B<--print> I<package> I<command> [I<command> ...]
  +
  +B<Run-Command Printing.> This is like the run-command execution (see
  +above), but instead of immediately executing all involved individual
  +run-command scripts, they are concatenated (but with all configuration
  +parts reduced to a single configuration part) and printed to C<stdout>.
  +Use this for debugging or post-processing purposes.
  +
  +=item eval `B<@l_prefix@/etc/rc> B<-e>|B<--eval> I<package> I<command> [I<command> 
...]`
  +
  +B<Run-Command Evaluation.> This is like the run-command execution
  +(see above), but the resulting exported shell environment variables
  +are output to a temporary file as a (Bourne-Shell or C-Shell syntax)
  +shell script, suitable for evaluation within the shell environment
  +of the caller. A one-line script is printed to C<stdout> which then
  +"sources" (and immediately removes) this temporary file. This is
  +slightly different from printing the temporary script directly to
  +C<stdout>, because not all shell implementations like to "B<eval>"
  +large multi-line scripts. Hence, use this for executing the "C<env>"
  +run-commands within the current shell.
  +
  +=item B<@l_prefix@/etc/rc> B<-q>|B<--query> I<variable> [I<variable> ...]
  +
  +B<Configuration Variable Querying.> This queries the effective values
  +(see B<RUN-COMMAND CONFIGURATION> section below) of one or more
  +run-command configuration I<variable>s. Use this within a shell script
  +to selectively query a particular variable.
  +
  +=item B<@l_prefix@/etc/rc> B<-c>|B<--config>
  +
  +B<Configuration Variable Summary.> This displays on C<stdout> a
  +three-column table showing the name, default and effective values of
  +all run-command configuration variables. If C<stdout> is connected to
  +terminal device, variables where the default and effective values differ
  +are shown in bold mode.
  +
  +=item B<@l_prefix@/etc/rc> B<-h>|B<--help>
  +
  +B<Requesting Help.> This just displays a short summary of
  +the usage for this program.
  +
  +=back
  +
  +=head1 FILES
  +
  +=head2 RUN-COMMAND FILES (C<@l_prefix@/etc/rc.d/rc.*>)
  +
  +The foundation of the B<OpenPKG> run-command facility are the individual
  +run-command files C<rc.*> of the installed packages. They are all
  +located in the directory C<@l_prefix@/etc/rc.d/> and are named
  +"C<rc.>I<package>". They consist of one or more sections, each starting
  +with a section header "C<%>I<name> [I<options>]" and following a GNU
  +Bash compatible shell script. There are three classes of sections:
  +
  +=over 4
  +
  +=item B<Special Sections>
  +
  +There are 2 sections which have a special meaning to the B<rc> program
  +and cannot be used for different purposes.
  +
  +=over 4
  +
  +=item C<%config>
  +
  +This section has to consist of run-command configuration
  +variable default settings in Bourne-Shell syntax only, i.e.,
  +it has to contain one or more lines, each of exactly the form
  +"I<package>C<_>I<variable>C<=>I<value>". Notice that in section
  +"C<%config>" of run-command file "C<rc.foo>" the variables all have
  +to be prefixed (by convention) with "C<foo_>". It is allowed that the
  +I<value>s reference other variables defined before in the same section
  +or from the "C<%config>" section of the bootstrap package "C<openpkg>".
  +Additionally, by convention all lines have to be indented by 4 spaces.
  +
  +NOTICE: All sections of all run-command scripts see all C<%config>
  +sections of all packages.
  +
  +=item C<%common>
  +
  +This section can consist of an arbitrary shell script
  +which is automatically prepended to the shell scripts
  +of all other sections on execution. It is usually used
  +to define common and local variables and functions.
  +
  +=back
  +
  +=item B<Conventional Sections>
  +
  +There are 9 sections which have no special meaning to the B<rc> program,
  +but are used in B<OpenPKG> by convention for standard purposes. Hence,
  +do not use them for arbitrary things instead.
  +
  +=over 4
  +
  +=item C<%start> [B<-u> I<user>] [B<-p> I<priority>]
  +
  +This section should start daemons or initialize components.
  +It is especially executed by B<OpenPKG> during system startup.
  +
  +=item C<%stop> [B<-u> I<user>] [B<-p> I<priority>]
  +
  +This section should stop daemons or cleaning up components. It is
  +especially executed by B<OpenPKG> during system shutdown and package
  +deinstallation.
  +
  +=item C<%restart> [B<-u> I<user>] [B<-p> I<priority>]
  +
  +This section should restart daemons.
  +It is especially executed by B<OpenPKG> during package upgrades.
  +
  +=item C<%status -o> [B<-u> I<user>] [B<-p> I<priority>]
  +
  +This section has to provide status information for a package
  +by printing to C<stdout> (hence the B<-o> option is always required),
  +in Bourne-Shell syntax, the definition of three variables:
  +
  +=over 4
  +
  +=item I<package>C<_enable>
  +
  +Whether package is enabled, i.e., whether it accepts run-commands. This
  +variable just has to be printed, because is already set in current
  +script environment.
  +
  +=item I<package>C<_usable>
  +
  +Whether package is usable, i.e., whether it is already correctly
  +configured, etc. This variable has to be individually determined.
  +
  +=item I<package>C<_active>
  +
  +Whether package is active, i.e., whether it is already running.
  +This variable has to be individually determined.
  +
  +=back
  +
  +=item C<%monthly> [B<-u> I<user>] [B<-p> I<priority>]
  +
  +=item C<%weekly> [B<-u> I<user>] [B<-p> I<priority>]
  +
  +=item C<%hourly> [B<-u> I<user>] [B<-p> I<priority>]
  +
  +=item C<%quarterly> [B<-u> I<user>] [B<-p> I<priority>]
  +
  +These sections should perform periodical tasks for a package and
  +are executed on a monthly, weekly, hourly or quarterly basis.
  +
  +=item C<%env>
  +
  +This section is intended to export one or more environment variables
  +which are imported into the shell environment of the caller through the
  +B<--eval> command line option.
  +
  +=back
  +
  +=item B<Custom Sections>
  +
  +All other sections are custom ones and can be fully individual to each
  +package. Some often seen sections are C<%reload> (just reload the
  +configuration without full stop and start procedure), C<%info> (output
  +arbitrary information about package), etc.
  +
  +=back
  +
  +=head2 RUN-COMMAND CONFIGURATION (C<@l_prefix@/etc/rc.conf>)
  +
  +The run-command configuration variables defined in the "C<%config>"
  +sections of all installed packages can be overridden by the
  +administrator in the global file C<@l_prefix@/etc/rc.conf>. This file is
  +usually empty, but can be filled with Bourne-Shell compatible variable
  +assignment statements like "I<package>C<_>I<variable>=I<value>".
  +
  +=head2 RUN-COMMAND FUNCTIONS (C<@l_prefix@/etc/rc.func>)
  +
  +The file C<@l_prefix@/etc/rc.func> is prepended to the scripts of all
  +executed run-command sections and provides reusable functions.
  +Currently the following functions are defined:
  +
  +=over 4
  +
  +=item B<rcMsg> [B<-e>] [B<-w>] I<message>
  +
  +Print a message to the output device of the run-command caller. The
  +message is printed to the captured F<stderr> (but are visible to
  +the caller of the run-command script only if the script fails). All
  +messages are prefixed with "C<rc:>". If option B<-e> is given, the
  +prefix is "C<rc:ERROR:>". If option B<-w> is given, the prefix is
  +"C<rc:WARNING:>".
  +
  +=item B<rcPath> [B<-a>] [B<-r>] [B<-p>] [B<-e>] I<variable> I<dir> [I<dir> ...]
  +
  +Add (option B<-a>) or remove (option B<-r>) one or more I<dir>ectories
  +to/from the colon-separated value of a I<var>able. By default, on
  +addition, the directory is appended to the end, if option B<-p> is used
  +the directory is prepended to the start. If option B<-e> is used, the
  +directories are added only if they exist on the underlying filesystem.
  +Use this function for conveniently manipulating C<PATH>, C<MANPATH>,
  +C<INFOPATH>, C<LD_LIBRARY_PATH> and similar variables.
  +
  +=item B<rcTmp> [B<-i>] [B<-f>] [B<-n> I<name>] [B<-k>]
  +
  +Convinience interface to secure temporary file handling. Option B<-i>
  +first has to be used to initialize a secure temporary directory (option
  +B<-k> later will kill this again). Under option B<-f> you then can get
  +reasonable temporary filenames under the created temporary directory. By
  +default, the temporary filename is just "C<tmp>", but can be specified
  +with option B<-n> to be I<name>.
  +
  +=item B<rcService> I<package> I<status> I<value>
  +
  +Convinience interface to checking the C<%status> variables
  +I<package>C<_>I<status> which have to be provided by the C<%config> (if
  +I<status> is "C<enable>" this is enough) and C<%status> (if I<status> is
  +"C<enable>", "C<usable>" and "C<active>"). The B<rcService> especially
  +caches the resolving of the variable values. Returns 0 if the resolved
  +value is I<value>, else return 1.
  +
  +=item B<rcVarIsYes> I<name>
  +
  +Checks whether variable I<name> has a value of "C<yes>", "C<true>",
  +"C<on>", or "C<1>" (with arbitrary lower or upper case letters). Returns
  +0 if value is one of these positive ones, else returns 0.
  +
  +=back
  +
  +=head1 EXAMPLES
  +
  +First, an example run-command script C<@l_prefix@/etc/rc.d/rc.foo> for a
  +fictional daemon package "C<foo>":
  +
  + %config
  +    foo_enable="${openpkg_rc_def}"
  +    foo_listen="127.0.0.1"
  +    foo_log_prolog="true"
  +    foo_log_epilog="true"
  +    foo_log_numfiles="10"
  +    foo_log_minsize="1M"
  +    foo_log_complevel="9"
  +
  + %common
  +    foo_homedir="@l_prefix@/share/foo"
  +    foo_cfgfile="@l_prefix@/etc/foo/foo.cfg"
  +    foo_pidfile="@l_prefix@/var/foo/foo.pid"
  +    foo_logfile="@l_prefix@/var/foo/foo.log"
  +    foo_signal () {
  +        if [ -f ${foo_pidfile} ]; then
  +            kill -$1 `cat ${foo_pidfile}`
  +            return $?
  +        else
  +            return 1
  +        fi
  +    }
  +
  + %status
  +     foo_usable="no"
  +     if [ ".`grep '<<PASSWORD>>' ${foo_cfgfile}`" = . ]; then
  +         foo_usable="yes"
  +     fi
  +     foo_active="no"
  +     if [ -f ${foo_pidfile} ]; then
  +         foo_signal 0
  +         if [ $? -eq 0 ]; then
  +             foo_active="yes"
  +         fi
  +     fi
  +     echo "foo_enable=${foo_enable}"
  +     echo "foo_usable=${foo_usable}"
  +     echo "foo_active=${foo_active}"
  +
  + %start
  +     rcService foo enable yes || exit 0
  +     rcService foo active yes && exit 0
  +     @l_prefix@/sbin/foo --listen ${foo_listen}
  +
  + %stop
  +     rcService foo enable yes || exit 0
  +     rcService foo active yes || exit 0
  +     foo_signal TERM
  +
  + %restart
  +     rcService foo enable yes || exit 0
  +     rcService foo active yes || exit 0
  +     rc foo stop start
  +
  + %daily
  +     rcService foo enable yes || exit 0
  +     shtool rotate -f \
  +         -n ${foo_log_numfiles} -s ${foo_log_minsize} -d \
  +         -z ${foo_log_complevel} -o @l_rusr@ -g @l_rgrp@ -m 644 \
  +         -P "${foo_log_prolog}" -E "${foo_log_epilog}" \
  +         ${foo_logfile}
  +
  + %env
  +     if rcService foo enable yes; then
  +         FOO_HOME="$foo_homedir"
  +         export FOO_HOME
  +     fi
  +
  +Now, show all run-command configuration variables, their
  +default values and their effective values of package "C<foo>":
  +
  + $ @l_prefix@/etc/rc --config | grep "^foo_"
  +
  +Override the default value of a run-command configuration
  +variable C<foo_listen>:
  +
  + $ echo 'foo_listen="192.168.0.1"' >>@l_prefix@/etc/rc.conf
  +
  +Stop and start from scratch the package "C<foo>":
  +
  + $ @l_prefix@/etc/rc foo stop start
  +
  +Query the effective value of run-command configuration
  +variable C<foo_enable> in a script:
  +
  + if [ "[EMAIL PROTECTED]@/etc/rc -q foo_enable`" = .yes ]; then ...
  +
  +Import all environment settings from all (including "C<foo>") installed
  +packages into the current Bourne-Shell environment:
  +
  + $ eval [EMAIL PROTECTED]@/etc/rc --eval all env`
  + $ echo $FOO_HOME
  +
  +=head1 SEE ALSO
  +
  +B<OpenPKG> http://www.openpkg.org/
  +
  +=head1 HISTORY
  +
  +The B<OpenPKG> run-command facility consisting of the scripts C<rc>
  +and C<rc.func> were originally invented in November 2000 by Ralf S.
  +Engelschall for B<OpenPKG>. They were completely worked off from scratch
  +in July 2003 for B<OpenPKG 1.3>.
  +
  +=head1 AUTHOR
  +
  + Ralf S. Engelschall
  + [EMAIL PROTECTED]
  + www.engelschall.com
  +
  +=cut
  +
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/rpmtool.8
  ============================================================================
  $ cvs diff -u -r1.5 -r1.6 rpmtool.8
  --- openpkg-src/openpkg/rpmtool.8     8 Jul 2003 12:19:09 -0000       1.5
  +++ openpkg-src/openpkg/rpmtool.8     18 Jul 2003 20:34:08 -0000      1.6
  @@ -38,8 +38,8 @@
   .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
   .    ds L" ""
   .    ds R" ""
  -.    ds C` ""
  -.    ds C' ""
  +.    ds C` 
  +.    ds C' 
   'br\}
   .el\{\
   .    ds -- \|\(em\|
  @@ -128,8 +128,8 @@
   .rm #[ #] #H #V #F C
   .\" ========================================================================
   .\"
  -.IX Title "RPMTOOL 1"
  -.TH RPMTOOL 1 "2003-07-08" "perl v5.8.0" "User Contributed Perl Documentation"
  +.IX Title "RPMTOOL 8"
  +.TH RPMTOOL 8 "OpenPKG" "RPMTOOL(8)" "OpenPKG"
   .SH "NAME"
   \&\fBrpmtool\fR \- RPM Auxiliary Tool
   .SH "SYNOPSIS"
  @@ -184,8 +184,8 @@
   .Vb 1
   \& CC="$CC" CFLAGS=`rpmtool mflags -O $CC` ./configure ...
   .Ve
  -.ie n .IP "\fBcppflags\fR [\fB\-p\fR \fIprefix\fR] [[""+|\-""\fR\fIsubdir ...]" 4
  -.el .IP "\fBcppflags\fR [\fB\-p\fR \fIprefix\fR] [[\f(CW+|\-\fR\fIsubdir\fR ...]" 4
  +.ie n .IP "\fBcppflags\fR [\fB\-p\fR \fIprefix\fR] [[\*(C`+|\-\*(C'\fR\fIsubdir 
...]" 4
  +.el .IP "\fBcppflags\fR [\fB\-p\fR \fIprefix\fR] 
[[\f(CW\*(C`+|\-\*(C'\fR\fIsubdir\fR ...]" 4
   .IX Item "cppflags [-p prefix] [[+|-subdir ...]"
   This command output \fIcpp\fR\|(1) \f(CW\*(C`\-I\*(C'\fR options for the OpenPKG 
instance
   \&\fIprefix\fR. It optionally can prefix or suffix with one or more \fIsubdir\fR
  @@ -198,8 +198,8 @@
   .Vb 1
   \& rpmtool cppflags -p /foo bar -baz +quux
   .Ve
  -.ie n .IP "\fBldflags\fR [\fB\-p\fR \fIprefix\fR] [[""+|\-""\fR\fIsubdir ...]" 4
  -.el .IP "\fBldflags\fR [\fB\-p\fR \fIprefix\fR] [[\f(CW+|\-\fR\fIsubdir\fR ...]" 4
  +.ie n .IP "\fBldflags\fR [\fB\-p\fR \fIprefix\fR] [[\*(C`+|\-\*(C'\fR\fIsubdir 
...]" 4
  +.el .IP "\fBldflags\fR [\fB\-p\fR \fIprefix\fR] 
[[\f(CW\*(C`+|\-\*(C'\fR\fIsubdir\fR ...]" 4
   .IX Item "ldflags [-p prefix] [[+|-subdir ...]"
   This command output \fIld\fR\|(1) \f(CW\*(C`\-L\*(C'\fR options for the OpenPKG 
instance
   \&\fIprefix\fR. It optionally can prefix or suffix with one or more \fIsubdir\fR
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-web/news.txt
  ============================================================================
  $ cvs diff -u -r1.5657 -r1.5658 news.txt
  --- openpkg-web/news.txt      18 Jul 2003 17:42:35 -0000      1.5657
  +++ openpkg-web/news.txt      18 Jul 2003 20:34:06 -0000      1.5658
  @@ -1,3 +1,4 @@
  +18-Jul-2003: Upgraded package: P<openpkg-20030718-20030718>
   18-Jul-2003: Upgraded package: P<uvscan-4.1.6.4278-20030718>
   18-Jul-2003: Upgraded package: P<perl-util-20030718-20030718>
   18-Jul-2003: Upgraded package: P<valgrind-20030716-20030718>
  @@ .
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     [EMAIL PROTECTED]

Reply via email to