#!/bin/bash # # /linuxrc.loop # # # For More Ramdisk Options ... # ---------------------------- # linuxrc.Commands.Help.txt # # # # 06-Nov-04 amo Date-of-Birth # 13-Nov-04 amo Split off ramdisk options into linuxrc.Commands.Help.txt # # # # Define the path # export PATH="/sbin:/bin:/usr/sbin:/usr/bin" # # # # linuxrc.loop cannot call init --> causes /dev/initctl errors # docmd "chroot / /sbin/init 3" # # We have to simulate/emulate /sbin/init 3 # # # We can only run this script while on the rootfs. # ------------------------------------------------ # # if [ ` ls -a "/..RootFS*" | wc -l ` != 1 ]; # then # echo "#" # echo "# ERROR: linuxrc.loop can only be invoked while in rootfs.img " # echo "#" # # # exit 1 # # # fi # # # # Exit if the Commands fails # ========================== # function docmd { cmd="$1" # ERR="" # # check for the mount commands mnt=`echo "$cmd" | grep ^mount | cut -d ' ' -f 1` # # check for comments com=`echo "$cmd" | grep ^# | cut -d ' ' -f 1` # # if [ "$com" = "#" ]; then # # not a command echo "$cmd" # else echo "" echo "$cmd" $cmd # stat=$? # if [ $stat != 0 ]; then echo "" echo "ERROR: Failed: ${stat}: $cmd " # # mount and df fails depending on /proc being mounted or not # 32 == it wants " mount -t type " if [ "$mnt" = "mount" -a $stat != 32 ]; then echo " already mounted" echo "" else echo "#" echo "# Aborting: /linuxrc.loop " echo "#" # ERR="1" fi fi # # show what's mounted after the mount command # if [ "$mnt" = "mount" ]; then docmd "cat /proc/mounts" # ls -la /etc/mtab docmd "cat /etc/mtab" docmd "df" fi # if [ ! -z "$ERR" ]; then exit 1 fi fi # } # docmd # # # # Flush and reset first # # umount /dev/hda1 # umount /dev/ram0 # umount /proc # # docmd "#" docmd "# Executing /linurc.loop" docmd "#" # # # leave a " " in front of mount, to avoid the premature output of an empty /proc/mounts # ----------------------------- # # # Check /proc # =========== # if [ ! -f /proc/mounts ]; then # # Mount /proc filesystem # ---------------------- #ocmd "mount -n -t proc proc /proc" # # knoppix uses none and /dev/pts docmd " mount -n -t proc none /proc" #ocmd " mount -n -t devfs none /dev/pts" # else # echo "#" echo "# /proc already mounted " echo "#" # fi # # # Make / writable ( need "-n" for /etc/mtab ) # --------------- docmd " mount -n -o rw,remount /dev/loop0 /" # # Remount it again so that it shows up in the now writable /etc/mtab # ---------------- docmd " mount -o rw,remount /dev/loop0 /" # # # docmd "ls -la / " # # # # # Create /usr/local and /opt/home in ramdisk # ------------------------------------------- docmd "sh /root/ramdisks.sh" # docmd "df" # # docmd "source /root/.alias" # # docmd "ls -la" # # # rc.S - does e2fsck checking, needs readonly rootfs # # # Go to Multi-User ( emulate the processes started by /sbin/init ) # --------------- docmd "/etc/rc.d/rc.M" # # start the network # docmd "/etc/rc.d/rc.inet1 start " # # # # Start all the daemons # docmd "/etc/rc.d/rc.inet2 " # # # # start ssh # # # # start iptables docmd "/etc/rc.d/rc.iptables" # # # # Start some virtual consoles ( like /sbin/init but no respawn ) # --------------------------- /sbin/agetty 38400 tty6 linux & /sbin/agetty 38400 tty5 linux & /sbin/agetty 38400 tty4 linux & /sbin/agetty 38400 tty3 linux & /sbin/agetty 38400 tty2 linux & # # docmd "df" # # # # login once # docmd "login" # # # Wait for passwd, Stay in tty1 login forever # --------------- # while [ TRUE ]; do # /sbin/agetty 38400 tty1 linux # done # # # umount /proc # # # End of file