Proper way to autoload modules (/etc/rc.modules)?

Ville Skyttä ville.skytta at iki.fi
Mon Apr 4 20:13:07 UTC 2005


On Mon, 2005-04-04 at 10:36 +0200, Axel Thimm wrote:
> On Sun, Apr 03, 2005 at 12:16:42PM -0400, Ignacio Vazquez-Abrams wrote:
> > On Sun, 2005-04-03 at 13:26 +0200, Axel Thimm wrote:
>
> > > If there is no better mechanism, then please consider shipping an
> > > /etc/rc.modules that sources in /etc/rc.modules.d/* or similar, so
> > > packages can simply drop in a module loading script.
> > 
> > +1

+1

> Then how about
> 
> /etc/rc.modules:
> 
> #! /bin/sh
> 
> # Don't modify this file, instead create a module loading script
> # under /etc/rc.modules.d
> 
> for x in `ls /etc/rc.modules.d/* 2>/dev/null | \
>           LC_ALL=C grep -v '~$'`; do

Whitelisting filenames in cases like this is better than blacklisting.
The above fails to ignore for example *.rpmsave, *.rpmorig, *.rpmnew,
#*, core(.\d+)?, etc.  Maybe "LC_ALL=C grep '.sh$'; do".  Also, the
order of the snippet loading should be predictable, so LC_ALL or
LC_COLLATE should be set to eg. "C" before "ls".

>   test -x $x && $x

Testing that $x is a file (or at least not a directory) would be nice
for completeness.

> done





More information about the devel mailing list