Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
#!/bin/sh
# $Id: linuxrc,v 1.70.2.4 2005/11/06 21:28:58 smiley73 Exp $
#
# $Source: /cvsroot/devil-linux/build/config/etc/initrd/linuxrc,v $
# $Revision: 1.70.2.4 $
# $Date: 2005/11/06 21:28:58 $
#
# http://www.devil-linux.org
#
# system bootstrap loader
#   - loads config from floppy
#   - detects the cdrom and loads the system into ramdisk (/dev/shm)
#   - starts up the real system
#

NORMAL="echo -en \\033[0;39m"
GREEN="echo -en \\033[1;32m"
YELLOW="echo -en \\033[1;33m"
RED="echo -en \\033[1;31m"
BLUE="echo -en \\033[1;34m"
alias beep='echo -en "\007"'

alias l="ls -la"

$RED
echo
echo "********************************************************************************"
echo "*                                                                              *"
echo "*                           Welcome to Devil-Linux                             *"
echo "*                                                                              *"
echo "********************************************************************************"
echo "                          http://www.devil-linux.org/                           "
echo
$NORMAL

export PATH=$PATH:/sbin:/usr/sbin

scan_devices_for_config() {
	# $1 = filename
	# $... = list of devices
	FILE=$1
	shift
	for SRC in "$@"
	do	
		echo -n "Checking for \"$FILE\" on \"$SRC\" ... "
		if mount -n -t auto $SRC /floppy >/dev/null 2>&1  ; then
			if [ -e /floppy/$FILE ] ; then
				$GREEN
				echo "success!"
				$NORMAL
				DL_CONFIG_SOURCE=$SRC
				DL_CONFIG_FILE=$FILE
				return 0
			else
				$YELLOW
				echo "file not found"
				$NORMAL
				umount /floppy # in case user swaps floppy when we are accepting input
			fi
		else
			$RED
			echo "mount failed"
			$NORMAL
		fi
	done
	return 1
}

parse_config_cmdline() {
	# $1 = cmdline
	CMD="$1"
	# split at ','
	OIFS=$IFS
	IFS=,
	for CONFIG_USER in $CMD
	do
		IFS=$OIFS
		CONFIG_USER_ERROR=0
		CONFIG_USER_SRC=""
		CONFIG_USER_FILE=""
		if [ "$CONFIG_USER" != "" ]; then
			case `echo $CONFIG_USER | awk -v FS=: '{ print NF-1 }'` in
				0 )
		    			CONFIG_USER_SRC=`echo $CONFIG_USER | grep "/dev/"`
					CONFIG_USER_FILE=`echo $CONFIG_USER | grep -v "/dev/"`
				;;
				1 )
					CONFIG_USER_SRC=`echo ${CONFIG_USER%:*}`
					CONFIG_USER_FILE=`echo ${CONFIG_USER#*:}`    
				;;
				* )
					CONFIG_USER_ERROR=1
				;;
			esac	
			# sanity checks
			[ "$CONFIG_USER_SRC" != "" ] && CONFIG_USER_ERROR=`echo $CONFIG_USER_SRC | grep -c -v "^/dev/"`
			[ "$CONFIG_USER_FILE" != "" ] && CONFIG_USER_ERROR=`echo $CONFIG_USER_FILE | grep -c "/dev/"`
			[ "$CONFIG_USER" = ":" ] && CONFIG_USER_ERROR=1 # just in case...
		else
			CONFIG_USER_ERROR=1		
		fi
		case $CONFIG_USER_ERROR in
			0 )
				$BLUE
				echo -n "Trying to load configuration "
				$GREEN
				if [ "$CONFIG_USER_FILE" = "" ]; then
					CONFIG_USER_FILE=$CONFIG_FILE
				fi
	    			echo -n "\"$CONFIG_USER_FILE\" "
				$BLUE
				if [ "$CONFIG_USER_SRC" != "" ]; then
					echo -n "from device "
					$GREEN
					echo -n "\"$CONFIG_USER_SRC\""
					$BLUE
				else
					CONFIG_USER_SRC=$CONFIG_SRC_LIST
					echo -n "from any device"				
			    	fi
				echo "."
				$NORMAL
				scan_devices_for_config $CONFIG_USER_FILE $CONFIG_USER_SRC
				if [ $? = 0 ]; then
					return 0
				else
					$YELLOW
			    		echo "Sorry, could not load your configuration. Continuing searching..."
					$NORMAL
				fi	
			;;
			* )
			    	$RED
				echo -n "Improper config parameter : \"$CONFIG_USER\". Ignored."
			    	beep; sleep 1; echo -n "."; sleep 1; beep; echo "."
				$NORMAL
			;;
		esac
	done
	return 1
}

mod_config() {
	[ ! -e /etc/sysconfig/config.org ] && cp /etc/sysconfig/config /etc/sysconfig/config.org
	rm -f /etc/sysconfig/config.tmp
	cp /etc/sysconfig/config /etc/sysconfig/config.tmp
	sed "s/$1/$2/" /etc/sysconfig/config.tmp > /etc/sysconfig/config
	rm -f /etc/sysconfig/config.tmp
}

ask_yes_no()
{
        ANS=""
        read -p " (y/n) " -r ANS
        echo
        [ ${ANS:-n} = "y" -o ${ANS:-n} = "Y" ] && return 0
        return 1
}

# make sure all kernel warnings get lost (seriously!)
klogd -c 1

# get version info
DLVERSION=$(cat VERSION)

# mount proc
mount -n -t proc none /proc

# mount usb
mount -n -t usbdevfs none /proc/bus/usb

echo Kernel $(uname -r)

# mount shared memory filesystem with a limit of 40GB (for now)
echo "Mounting SHM FS on /shm"
mount -n -t shm shmfs /shm 2> /dev/null || mount -n -t tmpfs none /shm

# get rid of modprobe warnings
mkdir -p /shm/etc

echo "waiting until usb-storage driver has initialized all devices ..."
sleep 15

#grep usb-storage /proc/bus/usb/devices

echo -e "Loading loop-AES module";
modprobe loop 2> /dev/null

# save loaded config
DL_CONFIG_SOURCE=""
DL_CONFIG_FILE=""

$GREEN
echo "Searching for configuration media"
$NORMAL

# parse user config
CONFIG_USER=`awk -v RS=' ' -v FS='=' '/^DL_config=/ { print $2 }' /proc/cmdline`
CONFIG_USER_ONLY=`grep -c DL_config_no_scan /proc/cmdline`

if [ "$CONFIG_USER_ONLY" != "0" ]; then
	$RED
	echo "Disabling automatic scanning for Devil-Linux configuration archive! Good Luck."
	$NORMAL
fi

# generate the device list we need to search for the configuration information
CDROM_IDE=`find /dev/ide/ -name "cd*" 2> /dev/null`
CDROM_SCSI=`find /dev/scsi/ -name "cd*" 2> /dev/null`
PARTITIONS_IDE=`find /dev/ide/ -name "part*" 2> /dev/null`
PARTITIONS_SCSI=`find /dev/scsi/ -name "part*" 2> /dev/null`
DISCS_SCSI=`find /dev/scsi/ -name "disc" 2> /dev/null`
FLOPPIES=`find /dev/floppy/ -name "?" 2> /dev/null`
CONFIG_SRC_LIST="$PARTITIONS_SCSI $PARTITIONS_IDE $DISCS_SCSI $CDROM_IDE $CDROM_SCSI $FLOPPIES"
CONFIG_FILE="etc.tar.bz2"

until [ "$DL_CONFIG_SOURCE" != "" ] ; do
	if [ "$CONFIG_USER" != "" ]; then
		parse_config_cmdline $CONFIG_USER && continue
	fi
	if [ "$CONFIG_USER_ONLY" = "0" ]; then
		# scan for etc.tar.bz2 on all devices
		scan_devices_for_config $CONFIG_FILE $CONFIG_SRC_LIST && continue
	fi

	# no configuration has been found yet
	for CFG_SRC in $CONFIG_SRC_LIST
	do
		echo -e "Looking for empty configuation media on $CFG_SRC"
		if mount -n -t auto $CFG_SRC /floppy >/dev/null 2>&1 ; then
			umount /floppy # in case user swaps floppy when we are accepting input
			# offer to copy the configuration file if device is not a CD
			if [ ! "${CFG_SRC##/*/}" = "cd" ];then
				beep;
				$YELLOW
				echo -e "\n*** Found empty configuration media. ***"
				$NORMAL
				echo -n "Should I copy default configuration to it?"
				if ask_yes_no ; then
					echo -n "Would you like to probe for SCSI controllers now?"
					if ask_yes_no ; then
						/probe_all_scsi_modules
					fi
					if ! /mount_cdrom /cdrom noreboot ; then
						$RED
						echo -e "Cannot find CD drive - try probing for SCSI controllers"
						$NORMAL
						continue
					fi
					mount -n -t auto $CFG_SRC /floppy >/dev/null 2>&1 || continue
					cp -i /cdrom/config/etc.tar.bz2 /floppy/ || continue
					umount /cdrom
					sync
					DL_CONFIG_SOURCE=$CFG_SRC
					DL_CONFIG_FILE="etc.tar.bz2"
					continue 2
				fi
			fi
		fi
	done

	beep; sleep 1; beep; sleep 1; beep;
	$RED
	echo -e "Please insert Configuration Media and press 'ENTER'"
	$NORMAL
	read ANS
	echo
done
unset ANS RET

echo $DL_CONFIG_SOURCE > /shm/DL_CONFIG_SOURCE
echo $DL_CONFIG_FILE > /shm/DL_CONFIG_FILE
export DL_CONFIG_SOURCE
export DL_CONFIG_FILE

mkdir -p /shm/root

# check if the DL ISO got upgraded
if [ -e /shm/dl_iso_replaced ]; then
    cd /cdrom
    #change to new root
    pivot_root . initrd
    $RED
    echo "Rebooting..."
    $NORMAL
    exec /usr/sbin/chroot . /sbin/reboot -f
fi			

echo "loading configuration"
tar -C /shm -xjf /floppy/$DL_CONFIG_FILE

# create mtab for mount
cat /proc/mounts > /etc/mtab

# load modules
/load_modules

# check to see if cdrom has already been mounted
if [ ! -e /cdrom/DEVIL-LINUX ] ; then
    # find the CDROM
    /mount_cdrom /cdrom
fi

DL_DEVICE=$(cat /shm/DL_DEVICE)
export DL_DEVICE

if [ -f /cdrom/config/pubring.gpg ]; then
	$YELLOW
	echo "checking PGP signature of configuration"
	$NORMAL
	if ! /bin/gpgv --homedir /cdrom/config --keyring /cdrom/config/pubring.gpg --ignore-time-conflict -q /floppy/$DL_CONFIG_FILE.sig ;then
		$RED
		echo
		echo "********************************************************************************"
		echo "*      !!!  WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!!        *"
		echo "*                                                                              *"
		echo "*           The verification of the configuration signature failed !           *"
		echo "*                                                                              *"
		echo "*   There is a strong possibility that somebody tempered with your system !    *"
		echo "*                                                                              *"
		echo "*      !!!  WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!!        *"
		echo "********************************************************************************"
		beep; sleep 1; beep; sleep 1; beep; sleep 1; beep; sleep 1; beep; sleep 1; beep;
		$NORMAL
		echo
		echo -n "Do you want to continue? "
		if ! ask_yes_no ; then
			exit
		fi
	fi
fi

# unmount config media
umount /floppy

# Update modules for SCSI CD (if any)
if [ -s /shm/.probed_modules ] ; then
	echo "Updating /etc/sysconfig/config for SCSI modules."
	mod_config '^INITRD_MODULES=\"\"$' 'INITRD_MODULES=\"'$(cat /shm/.probed_modules)'\"'
	rm -f /shm/.probed_modules
fi

# remove uneeded modules
modprobe -r 2> /dev/null
sleep 1
modprobe -r 2> /dev/null

# kill our klogd
kill `ps ax | grep klogd | cut -f 1 -d 0` 2> /dev/null

# mount shared memory filesystem
echo "Mounting SHM FS on /cdrom/shm"
mount -n -o bind /shm /cdrom/shm
umount /shm

echo "Mounting DEV FS on /cdrom/dev"
mount -n -t devfs none /cdrom/dev

# unmount usb
umount /proc/bus/usb

# unmount proc because the final system will mount it again
umount /proc

# start the system by swapping /dev/ram0 and /shm
echo 'Starting up final system...'
cd /cdrom

#change to new root and start up the real system
pivot_root . initrd
exec /usr/sbin/chroot . /sbin/pre_init $DL_CONFIG_SOURCE $DL_CONFIG_FILE $@ <dev/console >dev/console 2>&1

# something went wrong
echo
echo 'Starting the system failed!'
echo 'Please mail a bug report to bugs@devil-linux.org'
echo
exit