]> git.ipfire.org Git - ipfire-3.x.git/commitdiff
Added some nice things on mkinitramfs.
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 17 Feb 2009 22:54:35 +0000 (23:54 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 17 Feb 2009 22:54:35 +0000 (23:54 +0100)
src/mkinitramfs/functions
src/mkinitramfs/mkinitramfs
src/mkinitramfs/mkliveramfs

index ec8705edece3a731cd525e608f731236fb462e5d..21e60f826e8f99cce5e95bcca6bea7a13157bc8d 100644 (file)
@@ -490,9 +490,10 @@ mkdir -p bin sbin dev sys proc sysroot \
        etc/udev/rules.d lib/udev/rules.d
 
 # Install some essential binaries
-install bash chmod cat cut dd dmesg env grep kbd_mode kill killall5 ln ls lsmod mkdir \
-       mknod modprobe mount mountpoint openvt pidof ps rm sed setfont sh sleep switchroot \
-       udevadm udevd umount /lib/udev/console_init /lib/udev/vol_id
+install bash chmod cat cut dd dmesg env grep head ip kbd_mode kill killall5 less ln \
+       ls lsmod mkdir mknod modprobe mount mountpoint openvt pidof ps rm sed \
+       setfont sh sleep switchroot udevadm udevd umount \
+       /lib/udev/console_init /lib/udev/vol_id
 
 # Copy modprobe.conf and friends over
 [ -e /etc/modprobe.conf ] && install /etc/modprobe.conf
index f71d32de16df71e503c0ef13af7957d3a17ff662..abc5cd3e035f5dae7585a2d0c800b1b9e4be8bc2 100644 (file)
@@ -30,7 +30,7 @@ rootfs=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $3; }}' /etc/fstab)
 rootopts=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $4; }}' /etc/fstab)
 [ -z "$rootopts" ] && rootopts="defaults"
 
-MODULES="$MODULES $rootfs" # Add rootfs module
+installmodule --load $rootfs
 
 if [[ "$rootdev" =~ "^(UUID=|LABEL=)" ]]; then
        rootdev=$(resolve_device_name "$rootdev")
@@ -53,6 +53,13 @@ fi
 
 findstoragedriver ${rootdev##/dev/}
 
+cat >> sbin/real-init <<EOF
+
+#rootdev=$rootdev
+#rootfstype=$rootfs
+#rootopts=$rootopts
+EOF
+
 cat >> sbin/real-init <<'EOF'
 
 # Users can override rootfs target on the kernel commandline
@@ -77,7 +84,9 @@ vecho "Creating devices..."
 udevadm trigger
 
 vecho "Mounting root filesystem $rootdev..."
-mount $rootdev /sysroot $rootfs $rootopts
+[ -n "$rootopts"   ] && rootopts="-o $rootopts"
+[ -n "$rootfstype" ] && rootopts="-t $rootfstype $rootopts"
+mount $rootdev /sysroot $rootopts
 
 kill $(pidof udevd)
 
index f0863fcbe9aba2f5f1c7d0954c487d06ab9cacb0..3fe8873815316603b53fae22a9bf156346fd317e 100644 (file)
@@ -35,12 +35,15 @@ for module in /lib/modules/$KERNEL/kernel/drivers/{ata,message/fusion,pcmcia,scs
        MODULES="$MODULES $(basename ${module/.ko})"
 done
 
-install dhclient
+install arping dhclient dhclient-script ping
 
 # Creating folders
 mkdir -p mnt/{source,tmpfs,overlayfs,squashfs}
 
 cat >> sbin/real-init <<'EOF'
+
+netdevice=eth0
+
 # Users can override rootfs target on the kernel commandline
 for o in $(cat /proc/cmdline); do
        case $o in
@@ -53,6 +56,18 @@ for o in $(cat /proc/cmdline); do
        rootfstype=*)
                rootfstype=${o#rootfstype=}
                ;;
+       net=*)
+               net=${o#net=}
+               ;;
+       netdevice=*)
+               netdevice=${o#netdevice=}
+               ;;
+       gateway=*)
+               gateway=${o#gateway=}
+               ;;
+       dns=*)
+               dns="$dns ${o#dns=}"
+               ;;
        esac
 done
 
@@ -109,6 +124,13 @@ else
                        fi
                        thingtomount=/dev/root
                        ;;
+               NFS=*)
+                       NFS=${root#NFS=}
+                       vecho "Going on to mount $NFS"
+                       #mount -t nfs $NFS /mnt/source
+                       #rootfstype=loop
+                       #thingtomount=$(ls -1 /mnt/source/*.iso | head -n 1)
+                       ;;
                /dev/*)
                        ln -s $root /dev/root
                        thingtomount=$root
@@ -140,18 +162,53 @@ udevd --daemon
 vecho "Creating devices..."
 udevadm trigger
 
+if [ -n "$net" ]; then
+       # Wait 30 seconds for network to appear.
+       COUNTDOWN=30
+       while [ "x$COUNTDOWN" != "x0" ] ; do
+               is_verbose && echo -n "."
+       
+               if ip link show $netdevice &>/dev/null; then
+                       COUNTDOWN=0
+                       continue
+               fi
+
+               COUNTDOWN=$(($COUNTDOWN - 1))
+               sleep 1
+       done
+       vecho # Blank line
+
+       ip link set $netdevice up
+       if [ "$net" = "dhcp" ]; then
+               vecho "Getting an IP address by DHCP..."
+               dhclient $(get_verbose) $netdevice
+       else
+               vecho "Setting IP address $net..."
+               ip addr add $net dev $netdevice
+       fi
+       if [ -n "$gateway" ]; then
+               vecho "Setting default gateway $gateway..."
+               ip route add default via $gateway
+       fi
+       if ! ping -c3 -w10 ping.ipfire.org 2>/dev/null; then
+               echo "This box does not seem to have an internet connection."
+               echo "You may fix this now and continue then:"
+               bash
+       fi
+fi
+
 if [ "$SHELL" == "1" ] ; then
        echo "Shell requested on kernel commandline. Exit to continue booting."
        echo
        bash
 fi
 
-# Wait 60 seconds for /dev/root to appear.
+# Wait 90 seconds for $thingtomount to appear.
 COUNTDOWN=90
 while [ "x$COUNTDOWN" != "x0" ] ; do
        is_verbose && echo -n "."
 
-       if [ -e /dev/root ]; then
+       if [ -e $thingtomount ]; then
                COUNTDOWN=0
                continue
        fi
@@ -167,21 +224,21 @@ while [ "x$COUNTDOWN" != "x0" ] ; do
 done
 vecho # Blank line
 
-if [ ! -b /dev/root ] ; then
+if [ ! -e $thingtomount ] ; then
        echo
        echo "--------------------------------------"
        echo "WARNING: Cannot find root file system!"
        echo "--------------------------------------"
        echo
-       echo "Create symlink /dev/root and then exit this shell to continue"
+       echo "Create symlink $thingtomount and then exit this shell to continue"
        echo "the boot sequence."
        echo
        bash
 fi
 
 if is_verbose; then
-       vecho "Mounting /dev/root..."
-       ls -l /dev/root
+       vecho "Mounting $thingtomount..."
+       ls -l $thingtomount
 fi
 
 if [ "x$READONLY" == "x1" ] ; then