#!/bin/bash # # /linuxrc.common.sh # # # # 06-Nov-04 amo Date-of-Birth # 13-Nov-04 amo Split off ramdisk options into linuxrc.Commands.Help.txt # 20-Nov-04 amo Split off common mount and checking to linuxrc.common.sh # 23-Nov-04 amo Use CFRW to debug mount CF as rw vs ro options -> linuxrc -> /etc/fstab # 17-Mar-05 amo Added bootUSB in addition to bootCF # 03-Sep-05 amo Added BootMsg variable # # # # # Define the path # export PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin" # # # Mount the CompactFlash as ro # ---------------------------- # - rw causes it to fail to boot CFRW="ro" # CFRW="rw" # # # ----------------- # Echo the mssages # ----------------- # BootMsg defined from lilo/grub: boot: BootMsg=1 # function BootMsg { msg="$1" # # just echo the messages # ---------------------- if [ ! -z "$BootMsg" ]; then eval ' echo "$msg" "$redirfile" ' fi # } # BootMsg # # # 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 BootMsg "$cmd" # else BootMsg "" BootMsg "$cmd" eval "$cmd" # stat=$? # if [ $stat != 0 ]; then BootMsg "" BootMsg "ERROR: Failed: ${stat}: $cmd " 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 BootMsg " already mounted" BootMsg "" else BootMsg "#" BootMsg "# Aborting: $0 " BootMsg "#" eche "# Aborting: $0 " # ERR="1" fi fi # # show what's mounted after the mount command # - # - use space in front of " mount" to avoid these debug messages # - # if [ "$mnt" = "mount" ]; then docmd "cat /proc/mounts" # ls -la /etc/mtab docmd "cat /etc/mtab" docmd "df" # docmd "mount" fi # if [ ! -z "$ERR" -a "$ERREXIT" = "exit-on-critical-error" ]; then exit 1 fi fi # } # docmd # # # # Check /proc # =========== # function mount_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 # BootMsg "#" BootMsg "# /proc already mounted " BootMsg "#" # fi # } # mount_proc # # # End of linuxrc.common.sh file