diff options
Diffstat (limited to 'packages/slugos-init')
-rw-r--r-- | packages/slugos-init/files/boot/kexec | 202 | ||||
-rw-r--r-- | packages/slugos-init/files/boot/network | 5 | ||||
-rw-r--r-- | packages/slugos-init/files/functions | 2 | ||||
-rw-r--r-- | packages/slugos-init/files/initscripts/umountinitrd.sh | 2 | ||||
-rw-r--r-- | packages/slugos-init/files/leds | 5 | ||||
-rw-r--r-- | packages/slugos-init/files/modulefunctions | 9 | ||||
-rw-r--r-- | packages/slugos-init/files/reflash | 4 | ||||
-rw-r--r-- | packages/slugos-init/files/sysconf | 5 | ||||
-rw-r--r-- | packages/slugos-init/files/turnup | 143 | ||||
-rw-r--r-- | packages/slugos-init/slugos-init_0.10.bb | 5 |
10 files changed, 344 insertions, 38 deletions
diff --git a/packages/slugos-init/files/boot/kexec b/packages/slugos-init/files/boot/kexec new file mode 100644 index 0000000000..7c02a14f04 --- /dev/null +++ b/packages/slugos-init/files/boot/kexec @@ -0,0 +1,202 @@ +#!/bin/sh +# +# Loads the specified kernel and kexecs it. + +# The access method and path from which to fetch the kernel +# is specified in "$1" and "$2": +# +# flash /boot/zImage-ixp4xxbe +# nfs spike:/home/slug/vmlinuz +# wget http://devserv/kernels/vmlinuzbe +# wget ftp://ftpserv/pub/zImage +# /dev/sda1 /kernels/zImage-test +# UUID /kernels/zImage-test +# tftp server:/pub/kernels/vmlinuz +# +# Command-line options for the new kernel are in "$3". + + +# In order to use this, you must exec this script from the /linuxrc file. +# +# This sample linuxrc script boots from external disk. The last line of +# this example (exec /boot/flash) is a fallback; it will not normally be +# executed unless /boot/kexec is missing or damaged. +#-------------------- +# #!/bin/sh +# sleep=8 exec /boot/kexec /dev/sda1 /boot/zImage-ixp4xxbe \ +# "console=ttyS0,115200n8 root=/dev/sda1 rootfstype=ext3 rw init=/linuxrc" +# exec /boot/flash +#-------------------- +# +# This one boots from flash in the normal fashion, except the kernel is +# loaded using wget. This is common for kernel debugging. +#-------------------- +# #!/bin/sh +# exec /boot/kexec wget http://myserver/boot/zImage-ixp4xxbe \ +# "console=ttyS0,115200n8 root=/dev/mtdblock4 rootfstype=jffs2 rw \ +# init=/boot/flash noirqdebug" +# exec /boot/flash +#-------------------- + + +# Use the standard init path (see /etc/init.d/rcS) +export PATH=/sbin:/bin:/usr/sbin:/usr/bin + +# Wait at least a short while for the disks... +if [ ! "$sleep" -gt 0 ] ; then + sleep=1 +fi + +# Load the helper functions +. /etc/default/functions +. /etc/default/modulefunctions + +# Print a distinctive banner to make it easy to separate the in-flash +# kernel boot from the kexec'd kernel boot when looking at logs, etc. +echo '###########################################################' +echo '###################### KEXEC ######################' + +leds boot system + +if [ -n "$1" -a -n "$2" ] ; then + + method="$1" + shift + kpath="$1" + shift + if [ -n "$1" ] ; then + kcmdline="$1" + shift + fi + kexec_image= + need_umount=0 + do_kexec=0 + + mount -t proc proc /proc + + case "$method" in + + flash ) + echo "Loading kexec kernel directly from \"$kpath\"..." + kexec_image="$kpath" + ;; + + wget ) + if /boot/network ; then + echo "mounting tmpfs partition..." + if mount -t tmpfs tmpfs /mnt ; then + need_umount=1 + echo "Loading kexec kernel using wget \"$kpath\"..." + wget -P /mnt "$kpath" + t=`basename "$kpath"` + kexec_image="/mnt/$t" + fi + fi + ;; + + nfs ) + if /boot/network ; then + echo "Loading kexec kernel using nfs \"$kpath\"..." + echo "mounting nfs partition..." + if mount -o ro,nolock -t nfs `dirname "$kpath"` /mnt ; then + need_umount=1 + t=`basename "$kpath"` + kexec_image="/mnt/$t" + fi + fi + ;; + + /dev/* ) + echo "Loading kexec kernel using disk \"$kpath\"..." + loaddiskmods + sleep "$sleep" + echo "mounting partition \"$method\"..." + if mount -o ro "$method" /mnt ; then + need_umount=1 + kexec_image="/mnt/$kpath" + fi + ;; + + UUID ) + echo "Loading kexec kernel using disk UUID \"$kpath\"..." + loaddiskmods + sleep "$sleep" + if [ -n "$UUID" ] ; then + echo "mounting partition UUID \"$UUID\"..." + if mount -o ro -U "$UUID" /mnt ; then + need_umount=1 + kexec_image="/mnt/$kpath" + fi + fi + ;; + + tftp ) + if /boot/network ; then + echo "mounting tmpfs partition..." + if mount -t tmpfs tmpfs /mnt ; then + need_umount=1 + t=`basename "$kpath"` + kexec_image="/mnt/$t" + echo "Loading kexec kernel using tftp \"$kpath\"..." + tftp -g -l "$kexec_image" -r "${kpath#*:}" "${kpath%%:*}" + fi + fi + ;; + + * ) + echo "Unrecognized method: \"$method\"" + ;; + + esac + + if [ -n "$kexec_image" -a -f "$kexec_image" ] ; then + if kexec -l "$kexec_image" ; then + do_kexec=1 + fi + else + echo "Unable to load \"$kexec_image\"" + fi + + if [ $do_kexec -eq 1 -a -n "$kcmdline" ] ; then + echo "Attempting to mount /sys (sysfs)..." + if mount -t sysfs sysfs /sys ; then + echo "Setting command line:" + echo " \"$kcmdline\"" + echo "$kcmdline" > /sys/kernel/kexec_cmdline + echo "unmounting /sys..." + umount /sys + else + do_kexec=0 + fi + fi + + if [ $need_umount -eq 1 ] ; then + echo "unmounting /mnt..." + umount /mnt + fi + + if [ $do_kexec -eq 1 ] ; then + echo "Remounting root as read-only..." + mount -o remount,ro / + echo "Invoking \"kexec -f -e\" ..." + kexec -f -e + echo "ERROR!" + # We should never return here! At this point, things are not + # too well. Remount the root as rw, and fallback. + echo "Remounting root as read-write..." + mount -o remount,rw / + fi +else + echo "Usage: $0 flash|nfs|wget|UUID|/dev/<partition> <path-or-URL> [cmdline]" +fi + +# fallback - use the flash boot +echo "Falling back to flash boot..." +leds beep -f 1000 -r 2 +exec /boot/flash + +# fallback to the fallback +leds boot system panic +exec <>/dev/console >&0 2>&0 +test -x /bin/sh && exec /bin/sh +exit 1
\ No newline at end of file diff --git a/packages/slugos-init/files/boot/network b/packages/slugos-init/files/boot/network index 599250e744..9aa295e43d 100644 --- a/packages/slugos-init/files/boot/network +++ b/packages/slugos-init/files/boot/network @@ -8,6 +8,11 @@ # function! . /etc/default/functions # +# We may need to load the network driver modules here +. /etc/default/modulefunctions +loadnetmods +# +# # 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 diff --git a/packages/slugos-init/files/functions b/packages/slugos-init/files/functions index c329171128..18f4009ee7 100644 --- a/packages/slugos-init/files/functions +++ b/packages/slugos-init/files/functions @@ -274,6 +274,8 @@ ifup(){ if test "$(config boot)" != static then test -n "$hostname" && HOSTNAME="-H $hostname" + # Pause a moment in case link negotiation takes a while + sleep 3 # The script writes the required shell variable assignments # to file descriptor 9 eval $(udhcpc -i "$iface" -n -q -r "$ip" $HOSTNAME -s /boot/udhcpc.script 9>&1 >/dev/null) diff --git a/packages/slugos-init/files/initscripts/umountinitrd.sh b/packages/slugos-init/files/initscripts/umountinitrd.sh index 2798fe5985..93f05a00f6 100644 --- a/packages/slugos-init/files/initscripts/umountinitrd.sh +++ b/packages/slugos-init/files/initscripts/umountinitrd.sh @@ -20,6 +20,8 @@ do umount /mnt;; /initrd)# need the device for a remount ffsdev="$(mtblockdev $ffspart)" + [ -n "$ffsdev" ] || \ + ffsdev="$(mtblockdev rootfs)" echo "Remounting $ffsdev read-only on /initrd" >&2 if test -n "$ffsdev" -a -b "$ffsdev" then diff --git a/packages/slugos-init/files/leds b/packages/slugos-init/files/leds index f5011f8bad..8043dae682 100644 --- a/packages/slugos-init/files/leds +++ b/packages/slugos-init/files/leds @@ -18,8 +18,9 @@ esac # handle the 'user' setting. led_user_default(){ case "$(machine)" in - nslu2) echo -n "cpu-idle";; - *) echo -n "cpu";; + nslu2) echo -n "cpu-idle";; + nas100d) echo -n "on";; + *) echo -n "cpu";; esac } # diff --git a/packages/slugos-init/files/modulefunctions b/packages/slugos-init/files/modulefunctions index dbb9ab51d3..784f6ef662 100644 --- a/packages/slugos-init/files/modulefunctions +++ b/packages/slugos-init/files/modulefunctions @@ -21,7 +21,14 @@ loaddiskmods(){ } loadnetmods(){ - true + case "$(machine)" in + dsmg600) + modprobe via-velocity + ;; + *) + true + ;; + esac } loadmiscmods(){ diff --git a/packages/slugos-init/files/reflash b/packages/slugos-init/files/reflash index 131f0b67de..22a18bb068 100644 --- a/packages/slugos-init/files/reflash +++ b/packages/slugos-init/files/reflash @@ -146,7 +146,7 @@ then then imgksize="$size" imgkoffset="$base" - elif test "$name" = "$ffspart" + elif test "$name" = "$ffspart" -o "$name" = "rootfs" then imgffssize="$size" imgffsoffset="$base" @@ -320,6 +320,8 @@ ffssize=0 if test -n "$ffsfile" then ffsdev="$(mtblockdev $ffspart)" + [ -n "$ffsdev" ] || \ + ffsdev="$(mtblockdev rootfs)" test -n "$ffsdev" -a -b "$ffsdev" || { echo "reflash: $ffspart($ffsdev): cannot find $ffspart mtd partition." >&2 echo " check /proc/mtd, either the partition does not exist or there is no" >&2 diff --git a/packages/slugos-init/files/sysconf b/packages/slugos-init/files/sysconf index d91c184425..84a14af550 100644 --- a/packages/slugos-init/files/sysconf +++ b/packages/slugos-init/files/sysconf @@ -8,7 +8,6 @@ # to load these functions!) test "$1" != sysconf && . /etc/default/functions -# NSLU2 flash layout is non-standard. case "$(machine)" in nslu2) kpart="Kernel" @@ -493,6 +492,8 @@ sysconf_test_restore(){ sysconf_save(){ local sysdev ffsdev ffsdir saved list size status ffsdev="$(mtblockdev $ffspart)" + [ -n "$ffsdev" ] || \ + ffsdev="$(mtblockdev rootfs)" sysdev="$(mtblockdev $syspart)" status=1 if test -n "$sysdev" -a -b "$sysdev" -a -n "$ffsdev" -a -b "$ffsdev" @@ -622,6 +623,8 @@ sysconf_restore(){ test "$1" = auto && sysconf_noninteractive=1 ffsdev="$(mtblockdev $ffspart)" + [ -n "$ffsdev" ] || \ + ffsdev="$(mtblockdev rootfs)" sysdev="$(mtblockdev $syspart)" status=1 if test -n "$sysdev" -a -b "$sysdev" -a -n "$ffsdev" -a -b "$ffsdev" && diff --git a/packages/slugos-init/files/turnup b/packages/slugos-init/files/turnup index 556d942e26..761e07829d 100644 --- a/packages/slugos-init/files/turnup +++ b/packages/slugos-init/files/turnup @@ -8,9 +8,93 @@ # configuration # The following variables control which directories in /var end # up on the rootfs and which end up in a temporary file system. -INRAM_MEMSTICK="/var/cache /var/lock /var/log /var/run /var/tmp /var/lib/ipkg" -INRAM_NFS="/var/cache /var/lock /var/run /var/tmp" -INRAM_DISK="" +INRAM_MEMSTICK="\ +### SlugOS from-memory-stick boot. +d root root 0755 /var/backups none +d root root 0755 /var/volatile/cache none +l root root 0755 /var/cache /var/volatile/cache +d root root 0755 /var/lib none +d root root 2755 /var/local none +d root root 1777 /var/volatile/lock none +l root root 1777 /var/lock /var/volatile/lock +d root root 0755 /var/volatile/log none +l root root 0755 /var/log /var/volatile/log +d root root 0755 /var/volatile/run none +l root root 0755 /var/run /var/volatile/run +d root root 0755 /var/spool none +d root root 1777 /var/volatile/tmp none +l root root 1777 /var/tmp /var/volatile/tmp +d root root 0755 /var/lock/subsys none +d root root 0755 /var/lib/dropbear none +d root root 0755 /var/lib/misc none +f root root 0664 /var/log/wtmp none +f root root 0664 /var/run/utmp none" + +INRAM_NFS="\ +### SlugOS from-NFS boot. +d root root 0755 /var/backups none +d root root 0755 /var/volatile/cache none +l root root 0755 /var/cache /var/volatile/cache +d root root 0755 /var/lib none +d root root 2755 /var/local none +d root root 1777 /var/volatile/lock none +l root root 1777 /var/lock /var/volatile/lock +d root root 0755 /var/log none +d root root 0755 /var/volatile/run none +l root root 0755 /var/run /var/volatile/run +d root root 0755 /var/spool none +d root root 1777 /var/volatile/tmp none +l root root 1777 /var/tmp /var/volatile/tmp +d root root 0755 /var/lock/subsys none +d root root 0755 /var/lib/dropbear none +d root root 0755 /var/lib/misc none +d root root 0755 /var/lib/ipkg none +f root root 0664 /var/log/wtmp none +f root root 0664 /var/run/utmp none" + +INRAM_DISK="\ +### SlugOS from-disk boot. +d root root 0755 /var/backups none +d root root 0755 /var/cache none +d root root 0755 /var/lib none +d root root 2755 /var/local none +d root root 1777 /var/lock none +d root root 0755 /var/log none +d root root 0755 /var/run none +d root root 0755 /var/spool none +d root root 1777 /var/tmp none +d root root 0755 /var/lock/subsys none +d root root 0755 /var/lib/dropbear none +d root root 0755 /var/lib/misc none +d root root 0755 /var/lib/ipkg none +f root root 0664 /var/log/wtmp none +f root root 0664 /var/run/utmp none" + +INRAM_HEADER="\ +# This configuration file lists filesystem objects that should get verified +# during startup and be created if missing. +# +# Every line must either be a comment starting with # +# or a definition of format: +# <type> <owner> <group> <mode> <path> <linksource> +# where the items are separated by whitespace ! +# +# <type> : d|f|l : (d)irectory|(f)ile|(l)ink +# +# A linking example: +# l root root 0777 /var/test /tmp/testfile +# f root root 0644 /var/test none +# +# Understanding links: +# When populate-volatile is to verify/create a directory or file, it will first +# check it's existence. If a link is found to exist in the place of the target, +# the path of the target is replaced with the target the link points to. +# Thus, if a link is in the place to be verified, the object will be created +# in the place the link points to instead. +# This explains the order of \"link before object\" as in the example above, where +# a link will be created at /var/test pointing to /tmp/testfile and due to this +# link the file defined as /var/test will actually be created as /tmp/testfile. +#" # # force: override certain checks @@ -75,7 +159,7 @@ fsoptions() { # get_flash <directory> {mount options} # mount the flash device, writeable, on the given directory get_flash() { - local ffsdir ffsdev + local ffsdir ffspart ffsdev ffsdir="$1" shift @@ -85,9 +169,12 @@ get_flash() { } case "$(machine)" in - nslu2) ffsdev="$(mtblockdev Flashdisk)";; - *) ffsdev="$(mtblockdev filesystem)";; + nslu2) ffspart="Flashdisk";; + *) ffspart="filesystem";; esac + ffsdev="$(mtblockdev $ffspart)" + [ -n "$ffsdev" ] || \ + ffsdev="$(mtblockdev rootfs)" umountflash "$ffsdev" && mountflash "$ffsdev" "$ffsdir" "$@" } @@ -153,7 +240,7 @@ copy_rootfs() { # /var/* echo "turnup: copying root file system" >&2 ( cd "$1" - find . -mount -print | + find . -xdev -print | sed '\@^./dev/@d;\@^./boot/@d;\@^./boot$@d;\@^./linuxrc@d;\@^./var/@d' | cpio -p -d -m -u "$2" ) || { @@ -209,7 +296,6 @@ setup_bootdev() { # Removes the /var tmpfs entry from /etc/fstab. # Creates links from /var into /media/ram for NFS and Memstick. setup_var() { - local ram_targets directory test -n "$1" -a -d "$1"/var || { echo "turnup: setup_var($1,$2): expected a directory" >&2 @@ -220,35 +306,30 @@ setup_var() { *) echo "turnup: setup_var($1,$2): expected 'disk', 'nfs' or 'memstick'" >&2 return 1;; esac - # - # populate /var, there is a shell script to do this, but it uses - # absolute path names - chroot "$1" /bin/busybox sh /etc/init.d/populate-volatile.sh || { - echo "turnup: /var: could not populate directory" >&2 - return 1 - } + # populate /var. We just need to create the /var/volatile mount + # point, the populate-volatile script does the work at boot time. + echo "turnup: ensuring /var/volatile mountpoint exists" + test -d "$1"/var/volatile || mkdir "$1"/var/volatile + + # we need to put in place the correct configuration file for + # the populate-volatile script to use at boot time. The config + # file is already in place for the flash boot, and it's the same + # file for the ram boot. case "$2" in - disk) ram_targets="$INRAM_DISK";; - nfs) ram_targets="$INRAM_NFS";; - memstick) - ram_targets="$INRAM_MEMSTICK";; + disk) echo "$INRAM_HEADER" > "$1"/etc/default/volatiles/00_core + echo "$INRAM_DISK" >>"$1"/etc/default/volatiles/00_core;; + nfs) echo "$INRAM_HEADER" > "$1"/etc/default/volatiles/00_core + echo "$INRAM_NFS" >>"$1"/etc/default/volatiles/00_core;; + memstick) echo "$INRAM_HEADER" > "$1"/etc/default/volatiles/00_core + echo "$INRAM_MEMSTICK" >>"$1"/etc/default/volatiles/00_core;; esac - for directory in $ram_targets - do - rm -rf "$1/$directory" - ln -s "/media/ram/$directory" "$1/$directory" - done - # the startup link is left for the moment, this seems safer - #rm "$1"/etc/rc?.d/[KS]??populate-var.sh - # remove the /var tmpfs entry from the new /etc/fstab + # remove the /var tmpfs entry from the new /etc/fstab, if it is + # present in the first place. sed -i '\@[ ]/var[ ][ ]*tmpfs[ ]@d' "$1"/etc/fstab - echo "turnup: tmpfs will no longer be mounted on /var" >&2 + echo "turnup: ensuring tmpfs will not be mounted on /var" >&2 # - # Previous versions of turnup removed populate-var.sh from the - # startup links, this one doesn't, so /var can be made back into - # a tmpfs just by a change to /etc/fstab. return 0 } diff --git a/packages/slugos-init/slugos-init_0.10.bb b/packages/slugos-init/slugos-init_0.10.bb index 55fea3e120..9748f13ec9 100644 --- a/packages/slugos-init/slugos-init_0.10.bb +++ b/packages/slugos-init/slugos-init_0.10.bb @@ -4,12 +4,13 @@ PRIORITY = "required" LICENSE = "GPL" DEPENDS = "base-files devio" RDEPENDS = "busybox devio" -PR = "r79" +PR = "r87" SRC_URI = "file://boot/flash \ file://boot/disk \ file://boot/nfs \ file://boot/ram \ + file://boot/kexec \ file://boot/network \ file://boot/udhcpc.script \ file://initscripts/fixfstab \ @@ -35,7 +36,7 @@ SBINPROGS = "" USRSBINPROGS = "" CPROGS = "${USRSBINPROGS} ${SBINPROGS}" SCRIPTS = "turnup reflash leds sysconf" -BOOTSCRIPTS = "flash disk nfs ram network udhcpc.script" +BOOTSCRIPTS = "flash disk nfs ram kexec network udhcpc.script" INITSCRIPTS = "syslog.buffer syslog.file syslog.network zleds\ leds_startup rmrecovery sysconfsetup umountinitrd.sh\ fixfstab loadmodules.sh" |