From 6950e496815f69df7b50f4664b654ac6b3e4f7de Mon Sep 17 00:00:00 2001 From: John Bowler Date: Mon, 30 May 2005 06:12:33 +0000 Subject: Initscripts patch. This changes the order of the shutdown scripts in openslug to ensure that the network shutdown does not happen before network file systems have been unmounted. It also adds some missing scripts - hwclock.sh (load/save the hwclock, otherwise it gets loaded but not saved, in the absence of NTP). alignment.sh (added to openslug, was in 'arm' before), and umountfs (excluded from oe). The file system unmount scripts use /proc/mounts (not fstab) and unmount in the correct order (the old scripts only worked if nothing was mounted within a mounted file system). Scripts have been patched (openslug only patches) to make them work correctly with openslug NFS, flash and disk root and to arrange for syslog to run as long as possible (it's now in S/0/6, not in the user run levels). Directory struction of openslug-init has been tidied up, with all the initscripts in a sub-dirctory. initscritps-openslug is an openslug specific variant of initscripts which tracks it and fails safe (an update/change to initscripts will cause initscripts-openslug to fail rather than build strangeness). turnup also contains a fix for slugbug 150. BKrev: 429aaed1D-1XOdk8brF2bP9C9EEEJQ --- packages/busybox/busybox_1.00.bb | 3 + .../initscripts-1.0/openslug/alignment.sh | 0 .../initscripts-1.0/openslug/devices.patch | 0 .../initscripts-1.0/openslug/domainname.sh | 0 .../initscripts-1.0/openslug/rootopts.patch | 0 .../initscripts/initscripts-1.0/openslug/umountfs | 0 .../initscripts-1.0/openslug/umountnfs.sh | 0 packages/initscripts/initscripts-openslug_1.0.bb | 0 packages/meta/openslug-image.bb | 6 +- packages/netbase/netbase_4.21.bb | 42 ++++++ .../openslug-init-0.10/initscripts/leds_startup | 0 .../openslug-init-0.10/initscripts/rmrecovery | 0 .../openslug-init-0.10/initscripts/sysconfsetup | 0 .../openslug-init-0.10/initscripts/syslog.buffer | 0 .../openslug-init-0.10/initscripts/syslog.file | 0 .../openslug-init-0.10/initscripts/syslog.network | 0 .../openslug-init-0.10/initscripts/umountinitrd.sh | 0 .../openslug-init-0.10/initscripts/zleds | 0 .../openslug-init/openslug-init-0.10/leds_rs_green | 38 ------ .../openslug-init/openslug-init-0.10/leds_startup | 0 .../openslug-init/openslug-init-0.10/rmrecovery | 0 .../openslug-init/openslug-init-0.10/sysconfsetup | 146 -------------------- packages/openslug-init/openslug-init-0.10/turnup | 152 +++++++++++++++++---- packages/openslug-init/openslug-init_0.10.bb | 46 +++++-- 24 files changed, 208 insertions(+), 225 deletions(-) create mode 100644 packages/initscripts/initscripts-1.0/openslug/alignment.sh create mode 100644 packages/initscripts/initscripts-1.0/openslug/devices.patch create mode 100644 packages/initscripts/initscripts-1.0/openslug/domainname.sh create mode 100644 packages/initscripts/initscripts-1.0/openslug/rootopts.patch create mode 100644 packages/initscripts/initscripts-1.0/openslug/umountfs create mode 100644 packages/initscripts/initscripts-1.0/openslug/umountnfs.sh create mode 100644 packages/initscripts/initscripts-openslug_1.0.bb create mode 100644 packages/openslug-init/openslug-init-0.10/initscripts/leds_startup create mode 100644 packages/openslug-init/openslug-init-0.10/initscripts/rmrecovery create mode 100644 packages/openslug-init/openslug-init-0.10/initscripts/sysconfsetup create mode 100644 packages/openslug-init/openslug-init-0.10/initscripts/syslog.buffer create mode 100644 packages/openslug-init/openslug-init-0.10/initscripts/syslog.file create mode 100644 packages/openslug-init/openslug-init-0.10/initscripts/syslog.network create mode 100644 packages/openslug-init/openslug-init-0.10/initscripts/umountinitrd.sh create mode 100644 packages/openslug-init/openslug-init-0.10/initscripts/zleds delete mode 100644 packages/openslug-init/openslug-init-0.10/leds_rs_green delete mode 100644 packages/openslug-init/openslug-init-0.10/leds_startup delete mode 100644 packages/openslug-init/openslug-init-0.10/rmrecovery delete mode 100644 packages/openslug-init/openslug-init-0.10/sysconfsetup diff --git a/packages/busybox/busybox_1.00.bb b/packages/busybox/busybox_1.00.bb index 97ad82ae56..b15d568aef 100644 --- a/packages/busybox/busybox_1.00.bb +++ b/packages/busybox/busybox_1.00.bb @@ -54,6 +54,9 @@ INITSCRIPT_NAME_${PN}-httpd = "busybox-httpd" INITSCRIPT_NAME_${PN}-udhcpd = "busybox-udhcpd" INITSCRIPT_NAME_${PN} = "syslog" +# This disables the syslog startup links in openslug (see openslug-init) +INITSCRIPT_PARAMS_${PN}_openslug = "start 20 ." + inherit cml1 update-rc.d do_configure () { diff --git a/packages/initscripts/initscripts-1.0/openslug/alignment.sh b/packages/initscripts/initscripts-1.0/openslug/alignment.sh new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/initscripts/initscripts-1.0/openslug/devices.patch b/packages/initscripts/initscripts-1.0/openslug/devices.patch new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/initscripts/initscripts-1.0/openslug/domainname.sh b/packages/initscripts/initscripts-1.0/openslug/domainname.sh new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/initscripts/initscripts-1.0/openslug/rootopts.patch b/packages/initscripts/initscripts-1.0/openslug/rootopts.patch new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/initscripts/initscripts-1.0/openslug/umountfs b/packages/initscripts/initscripts-1.0/openslug/umountfs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/initscripts/initscripts-1.0/openslug/umountnfs.sh b/packages/initscripts/initscripts-1.0/openslug/umountnfs.sh new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/initscripts/initscripts-openslug_1.0.bb b/packages/initscripts/initscripts-openslug_1.0.bb new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/meta/openslug-image.bb b/packages/meta/openslug-image.bb index d2bf3bb7c3..6ab8bc73b5 100644 --- a/packages/meta/openslug-image.bb +++ b/packages/meta/openslug-image.bb @@ -1,4 +1,4 @@ -PR = "r12" +PR = "r13" IMAGE_BASENAME = "openslug" @@ -9,7 +9,7 @@ OPENSLUG_HIDDEN_PACKAGES = "ipkg-native ipkg-utils-native fakeroot-native ${PATC virtual/libc makedevs-native mtd-utils-native slugimage-native nslu2-linksys-firmware " DEPENDS = "virtual/kernel base-files base-passwd \ - busybox dropbear hotplug-ng initscripts netbase \ + busybox dropbear hotplug-ng initscripts-openslug netbase \ sysvinit tinylogin portmap \ ixp4xx-csr ixp425-eth openslug-init \ module-init-tools modutils-initscripts \ @@ -21,7 +21,7 @@ DEPENDS = "virtual/kernel base-files base-passwd \ # (OPENSLUG_EXTRA_FILESYSTEMS, included in OPENSLUG_EXTRA_INSTALL) # kernel-module-af-packet must be in the image for DHCP to work IPKG_INSTALL = "base-files base-passwd \ - busybox dropbear hotplug-ng initscripts netbase \ + busybox dropbear hotplug-ng initscripts-openslug netbase \ update-modules sysvinit tinylogin portmap \ ixp4xx-csr ixp425-eth openslug-init \ module-init-tools modutils-initscripts \ diff --git a/packages/netbase/netbase_4.21.bb b/packages/netbase/netbase_4.21.bb index e69de29bb2..06e3a3c1b9 100644 --- a/packages/netbase/netbase_4.21.bb +++ b/packages/netbase/netbase_4.21.bb @@ -0,0 +1,42 @@ +SECTION = "base" +DESCRIPTION = "This package provides the necessary \ +infrastructure for basic TCP/IP based networking." +LICENSE = "GPL" +PR = "r6" + +inherit update-rc.d + +INITSCRIPT_NAME = "networking" +INITSCRIPT_PARAMS = "start 40 S . stop 40 0 6 1 ." +# On MNCI, start very late so that our own apps come up faster +INITSCRIPT_PARAMS_ramses = "start 85 1 2 3 4 5 . stop 85 0 6 1 ." +# On OpenSlug delay the stop until after network apps have exited +# Do not stop in single user - there's no way to sulogin! +INITSCRIPT_PARAMS_openslug = "start 40 S 0 6 ." + +SRC_URI = "${DEBIAN_MIRROR}/main/n/netbase/netbase_${PV}.tar.gz \ + file://options \ + file://init \ + file://hosts \ + file://interfaces" + +do_install () { + install -d ${D}${sysconfdir}/init.d \ + ${D}${sbindir} \ + ${D}${mandir}/man8 \ + ${D}${sysconfdir}/network/if-pre-up.d \ + ${D}${sysconfdir}/network/if-up.d \ + ${D}${sysconfdir}/network/if-down.d \ + ${D}${sysconfdir}/network/if-post-down.d + install -m 0644 ${WORKDIR}/options ${D}${sysconfdir}/network/options + install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/networking + install -m 0644 ${WORKDIR}/hosts ${D}${sysconfdir}/hosts + install -m 0644 etc-rpc ${D}${sysconfdir}/rpc + install -m 0644 etc-protocols ${D}${sysconfdir}/protocols + install -m 0644 etc-services ${D}${sysconfdir}/services + install -m 0755 update-inetd ${D}${sbindir}/ + install -m 0644 update-inetd.8 ${D}${mandir}/man8/ + install -m 0644 ${WORKDIR}/interfaces ${D}${sysconfdir}/network/interfaces +} + +CONFFILES_${PN} = "${sysconfdir}/network/options ${sysconfdir}/hosts ${sysconfdir}/network/interfaces" diff --git a/packages/openslug-init/openslug-init-0.10/initscripts/leds_startup b/packages/openslug-init/openslug-init-0.10/initscripts/leds_startup new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/openslug-init/openslug-init-0.10/initscripts/rmrecovery b/packages/openslug-init/openslug-init-0.10/initscripts/rmrecovery new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/openslug-init/openslug-init-0.10/initscripts/sysconfsetup b/packages/openslug-init/openslug-init-0.10/initscripts/sysconfsetup new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/openslug-init/openslug-init-0.10/initscripts/syslog.buffer b/packages/openslug-init/openslug-init-0.10/initscripts/syslog.buffer new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/openslug-init/openslug-init-0.10/initscripts/syslog.file b/packages/openslug-init/openslug-init-0.10/initscripts/syslog.file new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/openslug-init/openslug-init-0.10/initscripts/syslog.network b/packages/openslug-init/openslug-init-0.10/initscripts/syslog.network new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/openslug-init/openslug-init-0.10/initscripts/umountinitrd.sh b/packages/openslug-init/openslug-init-0.10/initscripts/umountinitrd.sh new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/openslug-init/openslug-init-0.10/initscripts/zleds b/packages/openslug-init/openslug-init-0.10/initscripts/zleds new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/openslug-init/openslug-init-0.10/leds_rs_green b/packages/openslug-init/openslug-init-0.10/leds_rs_green deleted file mode 100644 index c3ad3d2d64..0000000000 --- a/packages/openslug-init/openslug-init-0.10/leds_rs_green +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# -# This script is executed at the start and end of each run-level -# transition. It is the first 'stop' script and the last 'start' -# script. -# -# 'stop' sets the correct colour power LED to flash between the -# two colours of the previous and next runlevel. -# 'start' sets the LED to steady -# -# 'red' is the initial setting on kernel boot -# -# 'amber' is used for run levels S (from /linuxrc), 0 (halt), -# 1 (single user) and 6 (reboot). halt and reboot do not -# terminate therefore the LED remains flashing until the -# kernel terminates. -# -# 'green' is used for run levels 2-5 - the normal user run levels. -# -# colours are 'g' (green), 'r' (red) or 'gr' (amber). -colour() { - case "$1" in - S|0|1|6) echo gr;; - 2|3|4|5) echo g;; - N) echo r;; - *) echo "led change: $runlevel: runlevel unknown" >&2 - echo r;; - esac -} - -# leds syntax is -A + / -case "$1" in -start) leds -A +"$(colour "$runlevel")";; -stop) leds -A +"$(colour "$previous")" /"$(colour "$runlevel")";; -*) echo "led change: $1: command ignored" >&2;; -esac - -exit 0 diff --git a/packages/openslug-init/openslug-init-0.10/leds_startup b/packages/openslug-init/openslug-init-0.10/leds_startup deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/openslug-init/openslug-init-0.10/rmrecovery b/packages/openslug-init/openslug-init-0.10/rmrecovery deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/openslug-init/openslug-init-0.10/sysconfsetup b/packages/openslug-init/openslug-init-0.10/sysconfsetup deleted file mode 100644 index 8d2ecdca09..0000000000 --- a/packages/openslug-init/openslug-init-0.10/sysconfsetup +++ /dev/null @@ -1,146 +0,0 @@ -#!/bin/sh -# This script is run once when the system first boots. Its sole -# purpose is to create /etc/default/sysconf (the overall system -# configuration file) and other files derived from this. -# -# The script runs immediately after S10checkroot.sh - this is the -# point at which the rootfs will be mounted rw even if the kernel -# booted with it ro. -# -# rm or mv the file to run this again. If this is done the -# following configuration files will be rewritten: -# -# /etc/default/sysconf -# /etc/hostname -# /etc/defaultdomain -# /etc/network/interfaces -# /etc/resolv.conf -# -test -r /etc/default/sysconf && exit 0 -# -# /etc/default/functions contains useful utility functions - it's -# in a separate file so that it can be loaded by any script -. /etc/default/functions -# -# Utility to deal with absence of DNS configuration -echodns(){ - local dns - if test $# -gt 0 - then - for dns in "$@" - do - echo "nameserver $dns" - done - fi -} -# -# The SysConf device must exist in /dev at this point for this script -# to work. -# -# It is important not to hard-wire the name of the device because of -# the posibility of changing the flash partition layout. -# -# The block device is used here because at present udev does not -# show the character devices -sysdev="$(mtblockdev SysConf)" -if test -n "$sysdev" -a -b "$sysdev" -then - # Read the defined part of SysConf into /etc/default/sysconf. - # SysConf has lines of two forms: - # - # [section] - # name=value - # - # In practice SysConf also contains other stuff, use the command: - # - # devio '</etc/default/sysconf - # - # Now take the result and set up the 'standard' files in the - # root file system (these couldn't be set up before because - # they depend on stuff which RedBoot puts into SysConf from the - # ID info on the specific machine - in particular the hardware - # address of eth0, which must be the one assigned for *this* - # box!) - # - # HOSTNAME: defaults to LGK i.e. something derived from - # the ethernet hardware. LinkSys documentation explains how - # to determine this. Set by the user in linksys setup software. - # DOMAINNAME: LinkSys puts this in w_d_name. - test -n "$(config host)" && config host >/etc/hostname - domain="$(config domain)" - test -n "$domain" && echo "$domain" >/etc/defaultdomain - # - # Ethernet information. This goes into /etc/network/interfaces, - # however this is only used for static setup (and this is not - # the default). With dhcp the openslug udhcp script, - # /etc/udhcpc.d/50default, loads the values from sysconf. The - # lan_interface config value must exist for the file to be - # overwritten here. - iface="$(config iface)" - if test -n "$iface" - then - boot="$(config boot)" - # Only dhcp and static are supported at present - bootp - # support requires installation of appropriate packages - # dhcp is the fail-safe - case "$boot" in - dhcp|static) ;; - *) boot=dhcp;; - esac - # - mac="$(config mac)" - ip="$(config ip)" - netmask="$(config netmask)" - gateway="$(config gateway)" - { - echo "# /etc/network/interfaces" - echo "# configuration file for ifup(8), ifdown(8)" - echo "#" - echo "# The loopback interface" - echo "auto lo" - echo "iface lo inet loopback" - echo "#" - echo "# The NSLU2 built-in ethernet" - echo "auto eth0" - echo "# Automatically generated from /etc/default/sysconf" - if test -n "$mac" - then - echo "# The pre-up option must always be supplied, regardless" - echo "# of configuration, to set the hardware correctly." - echo "# Severe network problems may result if this option is" - echo "# removed." - c= - else - echo "# WARNING: improperly configured network interface." - echo "# WARNING: the pre-up line must be corrected or severe" - echo "# WARNING: network problems may result." - c='#' - mac='' - fi - echo "iface $iface inet $boot" - echo "${c} pre-up ifconfig $iface hw ether $mac" - # The following are ignored for DHCP but are harmless - test -n "$ip" && echo " address $ip" - test -n "$netmask" && echo " netmask $netmask" - test -n "$gateway" && echo " gateway $gateway" - } >/etc/network/interfaces - fi - # - # The DNS server information gives up to three nameservers, but this - # currently only binds in the first. - { - test -n "$domain" && echo "search $domain" - echodns $(config dns) $(config dns1) $(config dns2) - } >/etc/resolv.conf -fi - -exit 0 diff --git a/packages/openslug-init/openslug-init-0.10/turnup b/packages/openslug-init/openslug-init-0.10/turnup index b688bc3051..d22e15c208 100644 --- a/packages/openslug-init/openslug-init-0.10/turnup +++ b/packages/openslug-init/openslug-init-0.10/turnup @@ -8,6 +8,55 @@ # force: override certain checks force= # +# fstype new +# The type of the file system mounted on "new" Outputs the last +# piece of information found, which should be the one for the +# currently visible mount! +fstype() { + local cwd dev mp type options pass freq result + cwd="$(cd "$1"; /bin/pwd)" + result= + while read dev mp type options pass freq + do + case "$mp" in + "$cwd") result="$type";; + esac + done # Make sure the candidate rootfs is empty check_rootfs() { @@ -87,8 +136,8 @@ setup_dev() { return 1 } echo "done" >&2 - # now remove the startup links which mount the ramfs on /dev - rm "$1"/etc/rc?.d/[KS]??devices + # now prevent this being done each time + :>"$1"/dev/.permanent return 0 } @@ -128,8 +177,8 @@ setup_var() { echo "turnup: /var: could not populate directory" >&2 return 1 } - # and remove the startup links - rm "$1"/etc/rc?.d/[KS]??populate-var.sh + # 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 case "$2" in disk) sed -i '\@\s/var\s\s*tmpfs\s@d' "$1"/etc/fstab @@ -138,10 +187,9 @@ setup_var() { echo "turnup: tmpfs /var mount moved to /var/tmp" >&2;; esac # - # warn the user - it's not enough to put the /var mount back, it - # is necessary to reinsert the populate-var.sh links! - echo " If you remount tmpfs on /var it must be populated at boot, use:" >&2 - echo " update-rc.d populate-var.sh start 37 S ." >&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 } @@ -224,6 +272,23 @@ setup_rootfs() { # return code of last setup function } +# +# setup_fstab new fsdev fstype fsoptions +# Alters the /etc/fstab entry for / to refer to the correct device and +# have the correct type and options. Essential for checkroot to remount +# / 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 + 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 + echo " to ensure that the root partition is mounted correctly" >&2 + return 1 + } +} + + # # boot_rootfs [options] # Change the flash partition (not the current root!) to boot off @@ -342,7 +407,7 @@ mountflash() { # disk [-m] [-i] [-s