Boot recovery and turnup fixes
authorJohn Bowler <jbowler@nslu2-linux.org>
Sun, 19 Jun 2005 17:37:12 +0000 (17:37 +0000)
committerJohn Bowler <jbowler@nslu2-linux.org>
Sun, 19 Jun 2005 17:37:12 +0000 (17:37 +0000)
BKrev: 42b5ad48iyguDIZgY5zIazJA42ia2g

packages/openslug-init/openslug-init-0.10/boot/disk
packages/openslug-init/openslug-init-0.10/turnup

index e69de29..ede33a3 100644 (file)
@@ -0,0 +1,49 @@
+#!/bin/sh
+# boot from the hard disk partition "$1" (which
+# must be given) using options from the rest of
+# the command line.
+#
+/sbin/leds -A '!gr'
+#
+# Use the standard init path (see /etc/init.d/rcS)
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin
+#
+# Load the helper functions
+. /etc/default/functions
+#
+if test -n "$1"
+then
+       device="$1"
+       shift
+       echo "boot: rootfs: mount $* $device"
+       #
+       # wait if required
+       test "$sleep" -gt 0 && sleep "$sleep"
+       #
+       # Mount read-write because before exec'ing init
+       # this script creates the '.recovery' link to
+       # detect failed boot.  No file type is given to
+       if mount "$@" "$device" /mnt
+       then
+               # checkmount checks for sh, init and no
+               # .recovery plus either mnt or initrd
+               if checkmount /mnt && :>/mnt/.recovery
+               then
+                       # sync to ensure .recovery is written
+                       sync
+                       # pivot to /initrd if available, else /mnt
+                       cd /
+                       if test -d /mnt/initrd
+                       then
+                               swivel mnt initrd
+                       else
+                               swivel mnt mnt
+                       fi
+                       # swivel failed
+               fi
+               # Failure: unmount the partition
+               umount /mnt
+       fi
+fi
+# fallback - use the flash boot
+exec /boot/flash
index ade85f0..14756fc 100644 (file)
@@ -182,9 +182,9 @@ setup_var() {
        #rm "$1"/etc/rc?.d/[KS]??populate-var.sh
        # remove the /var tmpfs entry from the new /etc/fstab
        case "$2" in
-       disk)   sed -i '\@\s/var\s\s*tmpfs\s@d' "$1"/etc/fstab
+       disk)   sed -i '\@[     ]/var[  ][      ]*tmpfs[        ]@d' "$1"/etc/fstab
                echo "turnup: tmpfs will no longer be mounted on /var" >&2;;
-       nfs)    sed -i '\@\s/var\s\s*tmpfs\s@s@\s/var@&/tmp@' "$1"/etc/fstab
+       nfs)    sed -i '\@[     ]/var[  ][      ]*tmpfs[        ]@s@[   ]/var@&/tmp@' "$1"/etc/fstab
                echo "turnup: tmpfs /var mount moved to /var/tmp" >&2;;
        esac
        #
@@ -280,7 +280,7 @@ setup_rootfs() {
 #  / with the correct options.
 #  bad, since sed won't fail even if it changes nothing.
 setup_fstab() {
-       sed -i '\@^[^   ]*\s\s*/\s@s@^.*$@'"$2  /       $3      $4      1  1"'@' "$1"/etc/fstab
+       sed -i '\@^[^   ]*[     ][      ]*/[    ]@s@^.*$@'"$2   /       $3      $4      1  1"'@' "$1"/etc/fstab
        egrep -q "^$2   /       $3      $4      1  1\$" "$1"/etc/fstab || {
                echo "turnup: /etc/fstab: root(/) entry not changed" >&2
                echo "  you probably need to check the options in /etc/fstab" >&2