Re: What about breaking rc.sysint up into an rc.sysinit.d

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Robin Holt wrote:

> Some of the pieces I am building and adding to my RedHat installation are
> requiring modifications to the /etc/rc.d/rc.sysinit script.
> 
> What would be the response to creating an rc.sysinit.d, breaking the 
> rc.sysinit
> script into smaller scripts that live in rc.sysinit.d and modifying 
> rc.sysinit to
> just loop through each of the scripts in numerical order?
> 
> Thanks,
> Robin Holt
> 


I broke the rc.sysinit script up as described in this thread of
messages.  I created a subdir /etc/rc.d/rc.sysinit.d and placed
each of the individual scripts in there.  I then modified rc.sysinit
to source each file individually.  The reason for sourcing them was
some provide environ variables that others depend upon.

I did have to make one minor modification.  There is an open brace
(whatever you want to call the '{' character) that falls in the
middle of the rm commands.  The close to this is at approx the
fifth line from the bottom.  I moved the open to fairly close to the
closing brace.  This allowed me to break the last pieces into
many scripts instead of just one large script.  The downside is that
the boot time is slowed by a small amount.  Measured using a serial
console on a P-II 350 with a slow IDE drive it averaged approx 0.1 
seconds on 20 boots.  Since the variability of the timings was 0.25 
seconds, I took this to statistically insignificant.

I used a slightly different scheme for numbering files in the 
rc.sysinit.d directory.  Instead of using the S## and K## that is used 
in the rc[0-6].d directories, I used a ### format.  This should help 
make a clear distinction to future developers between the function of 
the two directories.  Whereas the rc[0-6].d dirs are used for starting 
and stopping services, the rc.sysinit.d dir scripts are all always run.

A closer look:


The modified rc.sysinit script:

--------------------------------- rc.sysinit  -------------------------

#!/bin/bash
#
# /etc/rc.sysinit - run once at boot time
#
# Taken in part from Miquel van Smoorenburg's bcheckrc.
#

# Rerun ourselves through initlog
if [ -z "$IN_INITLOG" ]; then
 [ -f /sbin/initlog ] && exec /sbin/initlog $INITLOG_ARGS -r /etc/rc.sysinit
fi

# Set the path
PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH

if [ -d /etc/rc.d/rc.sysinit.d ]; then
        for i in /etc/rc.d/rc.sysinit.d/*; do
                # Check if the script is there.
                [ ! -f $i ] && continue

                # Don't run ???foo.{rpmsave,rpmorig} scripts
                [ "${i%.rpmsave}" != "${i}" ] && continue
                [ "${i%.rpmorig}" != "${i}" ] && continue
                [ "${i%.rpmnew}" != "${i}" ] && continue

                . ${i}
        done
fi

--------------------------------- rc.sysinit  -------------------------


The rc.sysinit.d directory:

# ls -1 rc.sysinit.d/
010hostname
020functions
030banner
030dmesg
030mount_proc
040clock
040keyboard
040sysctl
040umount_initrd
050swap
060hostname
070usb
080fsck_options
250fsck_root
260root_quota
300pnp
310remount_root
320lvm_init
330mtab_init
340initlog
400module_dependencies
410modprobe
410sound
410var_modules
420raid
430lvm_on_raid
500fsck
510mount_local
550quota
600config_machine
700cleanup
750swap
800serial
850ide-scsi
850scsi_tape
850usb_storage
900ide_optimizations
910system_map
920libredhat
990save_ksyms
999finalize

I welcome any comments.

Thanks,
Robin Holt



_______________________________________________
Redhat-devel-list mailing list
Redhat-devel-list@redhat.com
https://listman.redhat.com/mailman/listinfo/redhat-devel-list

[Index of Archives]     [Kernel Newbies]     [Red Hat General]     [Fedora]     [Red Hat Install]     [Linux Kernel Development]     [Yosemite News]

  Powered by Linux