X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=linuxrc;h=d2e689978cfeac4486e7713191a91cf114f17f1e;hb=58888c7de07621d6f7b2e4fcdc176ce969265d66;hp=85ae3efaa63c76d35f575dac839f41f35555e524;hpb=7af6acfccfb742d4e8e8b1de840ec1e192587e38;p=grml-terminalserver.git diff --git a/linuxrc b/linuxrc index 85ae3ef..d2e6899 100755 --- a/linuxrc +++ b/linuxrc @@ -2,7 +2,7 @@ # Filename: /linuxrc # Purpose: minirt for kernel 2.6 running on grml live-cd # Authors: (c) Klaus Knopper , (c) Michael Prokop -# Latest change: Mon Sep 18 23:19:53 CEST 2006 [mika] +# Latest change: Don Nov 16 14:46:00 CET 2006 [mika] ####################################################################################### # hardcoded configurable options @@ -269,7 +269,7 @@ askmodules(){ c="" for m in "$@"; do if test -f "/modules/scsi/$m"; then - test -z "$c" && { echo -n " $m"; c="1"; } || { echo " $m"; c=""; } + test -z "$c" && { echo -n " $m"; c="1"; } || { echo " $m"; c=""; } fi done [ -n "$c" ] && echo "" @@ -509,24 +509,65 @@ esac stage=2 rundebugshell # NFS -if checkbootparam "nfsdir" ; then - NFS="$(getbootparam nfsdir)" -# if test -z $NFS -# then -# NFS=192.168.0.1 -# echo "${CRE}${BLUE}No NFS-server given, assuming default $NFS${NORMAL}" -# fi - echo "${RED}Debug: NFS = ${NFS}${NORMAL}" - log_begin_msg "${CRE} ${GREEN}*${NORMAL} Looking for CD-ROM in: ${MAGENTA}$NFS${NORMAL}" - if mountit -t nfs $NFS "-o ro" >/dev/null 2>&1 +for i in $cmdline; do case "$i" in nfsdir=*|NFSDIR=*) eval $i;; esac; done +[ -n "$nfsdir" ] && NFS="$nfsdir" +if [ -n "$NFS" ]; then + tmp_="$(getbootparam nfsdir)" + echo -n "checkbootparam nfsdir " + checkbootparam "nfsdir" && echo "OK" || echo "FAILED" + echo "getbootparam nfsdir=\"$tmp_\"" + + # put the mylibs into /lib for discover and udhcpc + cdir + + # starting hw-detection for network card - currently broken, so don't use it + # echo "Starting hw-detection" + # kernel_version_=`uname -r` + # modules_to_load=$(/static/discover --disable-bus all --enable-bus pci --type network --normalize-whitespace --data-path=linux/module/name --data-version=$kernel_version_ | grep -v '^ $' | uniq) + # echo "trying to load the following network modules: \"$modules_to_load\"" + + KERNELVER=`uname -r` + for mod in `find /lib/modules/$KERNELVER/kernel/drivers/net/ -name \*.ko` ; do + echo `basename $mod | tr -d \.ko` >> /modules.load + done + modules_to_load=`cat /modules.load | xargs` + + # FIXME modprobe is buggy from busybox + modLoad() + { + for mod in $@ ; do + tmp_="`modprobe -vn $mod 2>/dev/null`" + if [ $? -ne 0 ]; then + continue + fi + # be quiet by default, be verbose only with bootoption debuglinuxrc + [ -n "$DEBUG" ] && eval "$tmp_" || eval "$tmp_" 1>/dev/null 2>/dev/null + done + } + modLoad "$modules_to_load" + rm -f /modules.load + + # loading additional modules + modLoad sunrpc lockd af_packet nfs + + /static/udhcpc --foreground --quit --script=/static/udhcp-config.sh + #echo "press to start a system shell and configure your system" + #sh + + # recreate the old dir structures + rdir + #rm -rf /myusr /mylib + + log_begin_msg "${RED}Debug: NFS = ${NFS}${NORMAL}" + log_begin_msg -n "${CRE}${NORMAL}Looking for GRML in: ${MAGENTA}$NFS${NORMAL}" + if mount -t nfs "$NFS" -o "async,ro,nolock" /cdrom #>/dev/null 2>&1 then if test -f /cdrom/$GRML_DIR/$GRML_NAME then - log_begin_msg "Accessing grml CD-ROM at ${MAGENTA}${NFS}${NORMAL}" ; echo " $SUCCESS" + log_begin_msg -n "Accessing grml CDROM at ${MAGENTA}$NFS${NORMAL}" ; echo " $SUCCESS" FOUND_GRML="$NFS" break fi - umount /cdrom fi fi @@ -576,7 +617,7 @@ remount_grml() [ -n "$SOURCE2" ] && umount $SOURCE2 # umount possible loop-device mount_grml $TARGET else - echo "${CRE} ${RED}Warning: Changing to $TARGET failed.${NORMAL}" + log_failure_msg "Warning: Changing to $TARGET failed." return 1 fi @@ -613,7 +654,7 @@ boot_from() fi if [ $? -ne 0 ]; then [ -n "$LOOP_SOURCE" ] && /bin/umount $LOOP_SOURCE - echo -n "${CRE} ${RED}Accessing grml CD-ROM failed. ${MAGENTA}$TARGET_DEV${RED} is not mountable.${NORMAL}" + log_failure_msg "Accessing grml CD-ROM failed. ${MAGENTA}$TARGET_DEV${NORMAL} is not mountable." sleep 2 return 1 fi @@ -621,7 +662,7 @@ boot_from() if [ -f $TARGET/$GRML_DIR/$GRML_NAME ]; then log_begin_msg "Accessing grml CD-ROM at ${MAGENTA}$TARGET_DEV${NORMAL}." ; echo " $SUCCESS" else - echo -n "${CRE} ${RED}Accessing grml CD-ROM failed. Could not find $GRML_DIR/$GRML_NAME on ${MAGENTA}$TARGET_DEV${RED}.${NORMAL}" + log_failure_msg "Accessing grml CD-ROM failed. Could not find $GRML_DIR/$GRML_NAME on ${MAGENTA}$TARGET_DEV${RED}.${NORMAL}" [ -n "$LOOP_SOURCE" ] && /bin/umount $LOOP_SOURCE umount $TARGET sleep 2 @@ -664,7 +705,7 @@ copy_to() fi done if test -z "$MOUNTED"; then - echo -n "${CRE} ${RED}Copying grml CD-ROM failed. ${MAGENTA}$TARGET_DEV_DESC${RED} is not mountable.${NORMAL}" + log_failure_msg "Copying grml CD-ROM failed. ${MAGENTA}$TARGET_DEV_DESC${NORMAL} is not mountable." sleep 2 return 1 fi @@ -682,7 +723,7 @@ copy_to() if [ $FOUNDSPACE -lt $SIZE ] then - echo -n "${CRE} ${RED}Copying grml CD-ROM failed. Not enough free space on ${MAGENTA}${TARGET_DEV_DESC}${RED}. Found: ${MAGENTA}${FOUNDSPACE}k${RED} Need: ${MAGENTA}${SIZE}k${RED} ${NORMAL}" + log_failure_msg "Copying grml CD-ROM failed. Not enough free space on ${MAGENTA}${TARGET_DEV_DESC}${NORMAL}. Found: ${MAGENTA}${FOUNDSPACE}k${NORMAL} Need: ${MAGENTA}${SIZE}k${NORMAL}" sleep 2 umount $TARGET return 1 @@ -690,7 +731,8 @@ copy_to() # do the real copy - echo "${CRE} ${GREEN}Copying grml CD-ROM to ${MAGENTA}$TARGET_DEV_DESC${GREEN}... Please be patient. ${NORMAL}" + log_begin_msg "Copying grml CD-ROM to ${TARGET_DEV_DESC}... Please be patient." + echo if [ -z "$use_cp" -a -x /usr/bin/rsync ] then # first cp the small files @@ -699,17 +741,24 @@ copy_to() [ -f $TARGET/$GRML_DIR/$GRML_NAME ] && /bin/rm -f $TARGET/$GRML_DIR/$GRML_NAME /usr/bin/rsync -a --progress --include="$GRML_DIR/$GRML_NAME" --include="$GRML_DIR/" --exclude="*" $COPY $TARGET # Copy grml to $TARGET #/usr/bin/rsync -avP $COPY $TARGET # Copy grml to $TARGET + # make sure to support directories from http://grml.org/config/ + for dir in scripts bootparams config debs ; do + if [ -d "/cdrom/$dir" ] ; then + log_begin_msg "Customization directory $dir found, copying to $TARGET" + cp -a /cdrom/$dir $TARGET/ && echo "$SUCCESS" || echo "$FAILED" + fi + done else /bin/cp -a -f $COPY $TARGET # Copy grml to $TARGET fi if [ $? -ne 0 ] then - echo -n "${CRE} ${RED}Copying grml CD-ROM failed. ${MAGENTA}$TARGET_DEV_DESC${RED} possibly has not enough space left.${NORMAL}" + log_failure_msg "Copying grml CD-ROM failed. ${MAGENTA}$TARGET_DEV_DESC${NORMAL} possibly has not enough space left." sleep 2 return 1 fi # remount r/o - /bin/mount -n -o remount,ro $TARGET + /bin/mount -n -o remount,ro $TARGET 1>/dev/null 2>&1 remount_grml } @@ -737,16 +786,16 @@ if test -n "$DO_REMOUNT" -a -n "$FOUND_GRML" ; then # first copy_to, then boot_from if [ -n "$COPYTO" ]; then - copy_to $COPYTO && REAL_TARGET="$TARGET" + copy_to $COPYTO && REAL_TARGET="$TARGET" fi if [ -n "$BOOTFROM" ]; then - boot_from - if [ "$?" -eq "0" ]; then - # set new source / target paths - REAL_TARGET="$TARGET" - SOURCE2="$LOOP_SOURCE" - SOURCE="/cdrom2" - TARGET="/cdrom3" + boot_from + if [ "$?" -eq "0" ]; then + # set new source / target paths + REAL_TARGET="$TARGET" + SOURCE2="$LOOP_SOURCE" + SOURCE="/cdrom2" + TARGET="/cdrom3" fi fi fi @@ -781,10 +830,9 @@ export PATH # From here, we should have all essential commands available. hash -r -# Did we remount the source media ? -if test -n "$REAL_TARGET"; -then - /bin/mount -n --move $REAL_TARGET /cdrom # move it back and go on to normal boot +# Did we remount the source media? +if test -n "$REAL_TARGET"; then + /bin/mount -n --move $REAL_TARGET /cdrom # move it back and go on to normal boot fi # Clean up /etc/mtab (and - just in case - make a nice entry for looped ISO) @@ -843,7 +891,6 @@ if test -n "$UNIONFS" && /bin/mount -t unionfs -o noatime${SECURE},dirs=/ramdisk ln -snf /UNIONFS/$i /$i fi done - #echo "${GREEN}done${NORMAL}" echo " $SUCCESS" log_begin_msg "Merging read-only system with read-writeable /ramdisk." for i in $(cd /UNIONFS; echo *); do # Create links for new stuff on /UNIONFS @@ -904,7 +951,7 @@ rm -f /linuxrc exit 0 else - echo "${CRE}${RED}Can't find grml filesystem, sorry.${NORMAL}" + log_failure_msg "Error: Can't find grml filesystem, sorry." echo " Are you booting via USB or firewire? ====================================