summaryrefslogtreecommitdiff
path: root/packages/openturbostation-init/files/boot
diff options
context:
space:
mode:
authorOyvind Repvik <nail@nslu2-linux.org>2007-03-07 13:09:56 +0000
committerOyvind Repvik <nail@nslu2-linux.org>2007-03-07 13:09:56 +0000
commitcfaeb5f96bedf12169fe3895d23f8ead736e30bb (patch)
treeb59cf686689d001acf26a2b09ae67280caebbb43 /packages/openturbostation-init/files/boot
parentb861666064d4921e599f82f3c86f7924bbe46f96 (diff)
openturbostation: init-stuff
Diffstat (limited to 'packages/openturbostation-init/files/boot')
-rw-r--r--packages/openturbostation-init/files/boot/disk67
-rw-r--r--packages/openturbostation-init/files/boot/flash13
-rw-r--r--packages/openturbostation-init/files/boot/network16
-rw-r--r--packages/openturbostation-init/files/boot/nfs19
-rw-r--r--packages/openturbostation-init/files/boot/udhcpc.script17
5 files changed, 132 insertions, 0 deletions
diff --git a/packages/openturbostation-init/files/boot/disk b/packages/openturbostation-init/files/boot/disk
new file mode 100644
index 0000000000..b4bbaf1f3c
--- /dev/null
+++ b/packages/openturbostation-init/files/boot/disk
@@ -0,0 +1,67 @@
+#!/bin/sh
+# boot from the hard disk partition "$1" (which
+# must be given) using options from the rest of
+# the command line.
+#
+# 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
+. /etc/default/modulefunctions
+#
+#
+if test -n "$1"
+then
+ device="$1"
+ shift
+ # proc is needed for UUID mount and module load
+ mount -t proc proc /proc
+ # load USB & SCSI storage modules (/proc required!)
+ if [ "$(machine)" != "storcenter" ]; then
+ echo "boot: loading modules required for disk boot"
+ loaddiskmods
+ # waiting for disk (FIXME)
+ sleep=6
+ test "$sleep" -gt 0 && sleep "$sleep"
+ else
+ # make the device links so turnup can use short disk names.
+ # probably only necessary on devfs based systems.
+ /etc/init.d/devices start
+ scc -l redflash -f auto
+ fi
+ #
+ # fire the boot
+ echo "boot: rootfs: mount $* $device [$UUID]"
+ #
+ # Mount read-write because before exec'ing init
+ # If a UUID is given (in the environment) this
+ # is used in preference to the device, but if
+ # the UUID mount fails a standard device mount
+ # is attempted.
+ if test -n "$UUID" &&
+ mount "$@" -U "$UUID" /mnt ||
+ mount "$@" "$device" /mnt
+ then
+ # checkmount checks for sh, chroot, init
+ # and /mnt (i.e. /mnt/mnt in this case)
+ if checkmount /mnt
+ then
+ # if mounted, then move /dev to the new root
+ mount --bind /dev /mnt/dev
+ # 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
diff --git a/packages/openturbostation-init/files/boot/flash b/packages/openturbostation-init/files/boot/flash
new file mode 100644
index 0000000000..40f64c9701
--- /dev/null
+++ b/packages/openturbostation-init/files/boot/flash
@@ -0,0 +1,13 @@
+#!/bin/sh
+# boot from the current (flash) root partition
+# nothing need be done apart from setting the
+# system LED status correctly
+. /etc/default/functions
+scc -l redflash -f auto
+test -x /sbin/init && exec /sbin/init
+# fallback if /sbin/init has been deleted (bad!)
+scc -l red
+exec <>/dev/console >&0 2>&0
+test -x /sbin/sulogin && exec /sbin/sulogin
+test -x /bin/sh && exec /bin/sh
+exit 1
diff --git a/packages/openturbostation-init/files/boot/network b/packages/openturbostation-init/files/boot/network
new file mode 100644
index 0000000000..599250e744
--- /dev/null
+++ b/packages/openturbostation-init/files/boot/network
@@ -0,0 +1,16 @@
+#!/bin/sh
+# bring up the network before boot, used to allow
+# netconsole logging and NFS boot. This runs out
+# of flash, but that's ok because the script doesn't
+# leave any process running.
+#
+# NOTE: /etc/default/functions defines ifup as a shell
+# function!
+. /etc/default/functions
+#
+# Now all the information for booting should be in the configuration
+# file. Config the loopback and network interfaces.
+ifconfig lo 127.0.0.1 up
+iface="$(config iface)"
+test -n "$iface" && ifup "$iface"
+# exit code is true only if the interface config has succeeded
diff --git a/packages/openturbostation-init/files/boot/nfs b/packages/openturbostation-init/files/boot/nfs
new file mode 100644
index 0000000000..7cfce66cbb
--- /dev/null
+++ b/packages/openturbostation-init/files/boot/nfs
@@ -0,0 +1,19 @@
+#!/bin/sh
+# boot from the nfs partition "$1" (which
+# must be given) using options from the rest of
+# the command line.
+#
+# Use the standard init path (see /etc/init.d/rcS)
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin
+#
+. /etc/default/functions
+scc -l redflash -f auto
+#
+if /boot/network
+then
+ # network is up and running, the NFS mount will
+ # now succeed (possibly), use /boot/disk
+ exec /boot/disk "$@"
+fi
+# fallback - use the flash boot
+exec /boot/flash
diff --git a/packages/openturbostation-init/files/boot/udhcpc.script b/packages/openturbostation-init/files/boot/udhcpc.script
new file mode 100644
index 0000000000..3f437e3143
--- /dev/null
+++ b/packages/openturbostation-init/files/boot/udhcpc.script
@@ -0,0 +1,17 @@
+#!/bin/sh
+# executed by udhcpc to do the real work of configuring an interface
+# writes the result (if any) to file descriptor 9
+case "$1" in
+deconfig) # ignored
+ :;;
+renew|bound) # this gives the real information
+ test -n "$ip" && {
+ echo "ip='$ip'"
+ echo "subnet='$subnet'"
+ echo "broadcast='$broadcast'"
+ echo "router='$router'"
+ } >&9;;
+leasefail) # ignore - probably no dhcp server
+ :;;
+*) echo "udhcpc: $*: command not recognised" >&2;;
+esac