merging rc and rcS?

J. Jones jjones at darkside.dynup.net
Tue Jul 31 18:04:28 PDT 2001


On Tue, Jul 31, 2001 at 08:01:49PM -0400, Gerard Beekmans wrote:
> Do we really need a seperate rc and rcS script? We could treat rcS as
> what it is: runlevel S, so calling 'rc S' would run all scripts in
> /etc/rcS.d just like 'rc x' would call scripts in /etc/rcx.d (where x is
> a number between 0 and 6).
> 
> I really cannot remember anymore why once upon a time (back in 1998 when
> LFS started) I decided to have a seperate rcS script. Whatever the
> reason was at that time, I don't think it was any solid reasoning.
>

It's quite feasible.. I've got a new rc script with the new stuff you've seen
in it working.. i was looking for you but I killed my box testing the new rc
script out. :)

I'd like you to take a look at what I have now.  There are quite possibly
still some bugs in it, but it is properly starting/stopping my init scripts
as-is.

Check it out.

Jeremy
 
-------------- next part --------------
#!/bin/sh

# I intend to set this in /etc/init.d/functions.. we're going for flexibility
# here aren't we? ;)
DIR_RUNLVL=/etc/init.d/rc.d/

# Uncomment below for debugging.
#debug=echo

source /etc/init.d/functions

startup()
{
  case "$1" in
    *.sh) $debug sh "$@" ;;
    *) $debug "$@" ;;
  esac
  if [ "$?" != 0 ]; then
    echo
    $FAILURE
    echo -n "You should not see this message.  It means that an "
    echo "unforseen error "
    echo -n "occured and the subscript, $i, exited with a return "
    echo "value of $error_value for an unknown reason."
    $NORMAL
    echo
    echo
    echo "Press enter to continue"
    echo
    read
  fi 
}

trap ":" INT QUIT TSTP

[ "$1" != "" ] && runlevel=$1 || runlevel=$RUNLEVEL
if [ "$runlevel" = "" ]; then
  echo "Usage:  $0 <runlevel>" >&2
  exit 1
fi
[ "$PREVLEVEL" = "" ] && previous=N || previous=$PREVLEVEL
export runlevel previous

rc_path="$DIR_RUNLVL/rc$runlevel.d"
if [ -d $rc_path ]; then
  cd $rc_path
  for i in `ls K* S* 2>/dev/null | sed \
    's/^\([S|K]\)\(.*[0-9]\)\(.*\)/\1\2-\3/' | sort -g`
  do
    eval `echo $i | sed 's/^[S|K]\(.*[0-9]\)-\(.*\)/suffix=\1\2/'`
    previous_start=$DIR_RUNLVL/rc$prevlevel.d/S$suffix
    sysinit_start=$DIR_RUNLVL/rcS.d/S$suffix
    stop=$rc_path/K$suffix
    start=$rc_path/S$suffix

    if [ "$prevlevel" != "N" -a ! -f $start -a -f $stop ]; then
      startup $stop stop
    fi
    if [ ! -f $previous_start -a ! -f $stop -a -f $start ]; then
      startup $start start
    fi
  done
fi


More information about the lfs-dev mailing list