diff options
Diffstat (limited to 'packages/slugos-init/files/boot')
-rw-r--r-- | packages/slugos-init/files/boot/.mtn2git_empty | 0 | ||||
-rw-r--r-- | packages/slugos-init/files/boot/disk | 49 | ||||
-rw-r--r-- | packages/slugos-init/files/boot/flash | 14 | ||||
-rw-r--r-- | packages/slugos-init/files/boot/network | 25 | ||||
-rw-r--r-- | packages/slugos-init/files/boot/nfs | 17 | ||||
-rw-r--r-- | packages/slugos-init/files/boot/ram | 47 | ||||
-rw-r--r-- | packages/slugos-init/files/boot/udhcpc.script | 17 |
7 files changed, 169 insertions, 0 deletions
diff --git a/packages/slugos-init/files/boot/.mtn2git_empty b/packages/slugos-init/files/boot/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/packages/slugos-init/files/boot/.mtn2git_empty diff --git a/packages/slugos-init/files/boot/disk b/packages/slugos-init/files/boot/disk new file mode 100644 index 0000000000..ede33a3ee6 --- /dev/null +++ b/packages/slugos-init/files/boot/disk @@ -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 diff --git a/packages/slugos-init/files/boot/flash b/packages/slugos-init/files/boot/flash new file mode 100644 index 0000000000..e0bcebc9b8 --- /dev/null +++ b/packages/slugos-init/files/boot/flash @@ -0,0 +1,14 @@ +#!/bin/sh +# boot from the current (flash) root partition +# nothing need be done, make the power led flash +# amber to indicate runlevel S +/sbin/leds -A '!gr' +exec /sbin/init +# fallback if /sbin/init has been deleted (bad!) +# flashing amber/red - failed early boot +# disk lights flashing: failed in flash boot! +/sbin/leds +A '!g12' +exec <>/dev/console >&0 2>&0 +exec /sbin/sulogin +exec /bin/sh +exit 1 diff --git a/packages/slugos-init/files/boot/network b/packages/slugos-init/files/boot/network new file mode 100644 index 0000000000..02b226d1f3 --- /dev/null +++ b/packages/slugos-init/files/boot/network @@ -0,0 +1,25 @@ +#!/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 +mac="$(config mac)" +iface="$(config iface)" +if test -n "$mac" -a -n "$iface" -a "$mac" != "00:00:00:00:00:00" -a "$mac" != "FF:FF:FF:FF:FF:FF" +then + if ifconfig "$iface" hw ether "$mac" && + ifup "$iface" + then + exit 0 + fi +fi +# exit code is true only if the interface config has succeeded +exit 1 diff --git a/packages/slugos-init/files/boot/nfs b/packages/slugos-init/files/boot/nfs new file mode 100644 index 0000000000..534d8b7cb0 --- /dev/null +++ b/packages/slugos-init/files/boot/nfs @@ -0,0 +1,17 @@ +#!/bin/sh +# boot from the nfs 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 +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/slugos-init/files/boot/ram b/packages/slugos-init/files/boot/ram new file mode 100644 index 0000000000..66d46a7089 --- /dev/null +++ b/packages/slugos-init/files/boot/ram @@ -0,0 +1,47 @@ +#!/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" + # + # prepare the device. This uses tmpfs to avoid dependency + # on non-built-in file systems and because tmpfs can expand + # to bigger than the 10MByte ram0 partition used before. + # The 'device' is currently unused. + if mount -t tmpfs "$@" tmpfs /mnt + then + cd / + # filter out boot (with zimage), linuxrc and anything + # below /var, keep dev or the boot will fail (note that + # nothing is mounted this early in the bootstrap). + find . -mount -print | + sed '\@^./boot/@d;\@^./boot$@d;\@^./linuxrc@d;\@^./var/@d' | + cpio -p -d -m -u /mnt + # checkmount checks for sh, init and no .recovery plus + # either mnt or initrd, mnt must exist! + if checkmount /mnt + then + # pivot to /mnt + cd / + swivel mnt mnt + # swivel failed + fi + # Failure: unmount the partition. + umount /mnt + fi +fi +# fallback - use the flash boot +exec /boot/flash diff --git a/packages/slugos-init/files/boot/udhcpc.script b/packages/slugos-init/files/boot/udhcpc.script new file mode 100644 index 0000000000..3f437e3143 --- /dev/null +++ b/packages/slugos-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 |