#
# end of /etc/inittab
6.3.4. Create /etc/init.d/rc script
Use a text editor to create the following file and save it as
~/staging/etc/init.d/rc
#!/bin/sh
#
# /etc/init.d/rc − runlevel change script
#
PATH=/sbin:/bin
SCRIPT_DIR="/etc/rc$1.d"
#
# Check that the rcN.d directory really exists.
if [ −d $SCRIPT_DIR ]; then
#
# Execute the kill scripts first.
for SCRIPT in $SCRIPT_DIR/K*; do
if [ −x $SCRIPT ]; then
$SCRIPT stop;
fi;
done;
#
# Do the Start scripts last.
for SCRIPT in $SCRIPT_DIR/S*; do
if [ −x $SCRIPT ]; then
$SCRIPT start;
fi;
done;
fi
#
# end of /etc/init.d/rc
Make the file executable.
bash# chmod +x ~/staging/etc/init.d/rc
6.3.5. Modify /etc/init.d/local_fs script
A case statement is added to allow the script to either mount or unmount local filesystems depending on the
command−line argument given. The original script is contained inside the "start" portion of the case
statement. The "stop" portion is new.
#!/bin/sh
#
# local_fs − check and mount local filesystems
#
PATH=/sbin:/bin ; export PATH
case $1 in
start)
echo "Checking local filesystem integrity."
fsck −ATCp
if [ $? −gt 1 ]; then
echo "Filesystem errors still exist! Manual intervention required."
/bin/sh
Pocket Linux Guide
Chapter 6. Automating Startup & Shutdown
31