[oe-commits] org.oe.dev openturbostation: init-stuff
nail commit
openembedded-commits at lists.openembedded.org
Wed Mar 7 16:41:42 UTC 2007
openturbostation: init-stuff
Author: nail at nslu2-linux.org
Branch: org.openembedded.dev
Revision: c68d955a46410c83d7fc2a287fafb26d96ce02c1
ViewMTN: http://monotone.openembedded.org/revision.psp?id=c68d955a46410c83d7fc2a287fafb26d96ce02c1
Files:
1
packages/openturbostation-init/files/boot/disk
packages/openturbostation-init/files/boot/flash
packages/openturbostation-init/files/boot/network
packages/openturbostation-init/files/boot/nfs
packages/openturbostation-init/files/boot/udhcpc.script
packages/openturbostation-init/files/initscripts/fixfstab
packages/openturbostation-init/files/initscripts/loadmodules.sh
packages/openturbostation-init/files/initscripts/rmrecovery
packages/openturbostation-init/files/initscripts/sysconfsetup
packages/openturbostation-init/files/initscripts/syslog.buffer
packages/openturbostation-init/files/initscripts/syslog.file
packages/openturbostation-init/files/initscripts/syslog.network
packages/openturbostation-init/files/initscripts/umountinitrd.sh
Diffs:
#
# mt diff -ra78c21833c1ba73537b27d947ec750018c16a61d -rc68d955a46410c83d7fc2a287fafb26d96ce02c1
#
#
#
# add_file "packages/openturbostation-init/files/boot/disk"
# content [9013d8fc4ac2debd474c52e9d86794b9d64cca74]
#
# add_file "packages/openturbostation-init/files/boot/flash"
# content [ac150c76696ab08f8ea6c6ec70514977285bf5bf]
#
# add_file "packages/openturbostation-init/files/boot/network"
# content [7863638b33cded9710583ad3868e24dc35c04195]
#
# add_file "packages/openturbostation-init/files/boot/nfs"
# content [eb5efe23bc1d0b1f6e0dc29f7cb0aec3604ad5c5]
#
# add_file "packages/openturbostation-init/files/boot/udhcpc.script"
# content [1ed51b781d5c54d52e082e536643650391d1adef]
#
# add_file "packages/openturbostation-init/files/initscripts/fixfstab"
# content [6ad84d3f2c2390442eedd0de77d2b942fd823692]
#
# add_file "packages/openturbostation-init/files/initscripts/loadmodules.sh"
# content [65850cc8bc415b6ddf67c8fca195698d565ed12b]
#
# add_file "packages/openturbostation-init/files/initscripts/rmrecovery"
# content [981d670242c4af8a2e143c4edc0673f08f0379ce]
#
# add_file "packages/openturbostation-init/files/initscripts/sysconfsetup"
# content [a7c4367f43c69e64b0f6b9ef2706f7f68a08b9e3]
#
# add_file "packages/openturbostation-init/files/initscripts/syslog.buffer"
# content [bec2ff9c7eb754176df297d6064c455b6762c0f4]
#
# add_file "packages/openturbostation-init/files/initscripts/syslog.file"
# content [80c43d8ea5fd111a047c968bec660a1e86c3a054]
#
# add_file "packages/openturbostation-init/files/initscripts/syslog.network"
# content [f9ef95e6aa2e648d0ceecbef03fbd07235a77ca3]
#
# add_file "packages/openturbostation-init/files/initscripts/umountinitrd.sh"
# content [09230709c6200572b1fc888fa27f570433601bc1]
#
============================================================
--- packages/openturbostation-init/files/boot/disk 9013d8fc4ac2debd474c52e9d86794b9d64cca74
+++ packages/openturbostation-init/files/boot/disk 9013d8fc4ac2debd474c52e9d86794b9d64cca74
@@ -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
============================================================
--- packages/openturbostation-init/files/boot/flash ac150c76696ab08f8ea6c6ec70514977285bf5bf
+++ packages/openturbostation-init/files/boot/flash ac150c76696ab08f8ea6c6ec70514977285bf5bf
@@ -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
============================================================
--- packages/openturbostation-init/files/boot/network 7863638b33cded9710583ad3868e24dc35c04195
+++ packages/openturbostation-init/files/boot/network 7863638b33cded9710583ad3868e24dc35c04195
@@ -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
============================================================
--- packages/openturbostation-init/files/boot/nfs eb5efe23bc1d0b1f6e0dc29f7cb0aec3604ad5c5
+++ packages/openturbostation-init/files/boot/nfs eb5efe23bc1d0b1f6e0dc29f7cb0aec3604ad5c5
@@ -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
============================================================
--- packages/openturbostation-init/files/boot/udhcpc.script 1ed51b781d5c54d52e082e536643650391d1adef
+++ packages/openturbostation-init/files/boot/udhcpc.script 1ed51b781d5c54d52e082e536643650391d1adef
@@ -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
============================================================
--- packages/openturbostation-init/files/initscripts/fixfstab 6ad84d3f2c2390442eedd0de77d2b942fd823692
+++ packages/openturbostation-init/files/initscripts/fixfstab 6ad84d3f2c2390442eedd0de77d2b942fd823692
@@ -0,0 +1,91 @@
+#!/bin/sh
+# validate /etc/fstab against the current UUID list in
+# /etc/uuid_by_partition
+#
+. /etc/default/functions
+pfile=/etc/uuid_by_partition
+
+#
+# use debug to find out what is going on
+test "$1" = start -o "$1" = debug || exit 0
+
+#
+# obtain the current list of parititions with UUIDs
+newlist="$(uuid_by_partition)"
+
+if test -r "$pfile"
+then
+ # read the old list
+ oldlist="$(cat "$pfile")"
+ #
+ # if it hasn't changed nothing need be done
+ test "$newlist" = "$oldlist" && exit 0
+ #
+ # it has changed, but this only matters if
+ # a previously existing uuid has moved, build
+ # a list of old device vs new device for every
+ # uuid which has moved
+ changedlist="$(
+ { echo "$oldlist"
+ echo "$newlist"
+ } | awk 'device[$2] == ""{device[$2] = $1}
+ device[$2] != $1{print device[$2], $1}')"
+
+ if test -n "$changedlist"
+ then
+ # at least one partition has moved, scan the
+ # current fstab to see if it has a reference
+ # to this partition
+ changedfstab="$(
+ { echo "$changedlist"
+ echo '#fstab'
+ cat /etc/fstab
+ } | awk 'BEGIN{list=1}
+ list==1 && $0=="#fstab"{list=0; continue}
+ list==1{new[$1] = $2; continue}
+ new[$1] != ""{print $1, new[$1]}')"
+
+ # if this list is not empty edit the fstab
+ if test -n "$changedfstab"
+ then
+ rm -f /tmp/fstab.$$
+ # if the edit fails then do not overwrite the old
+ # partition list - just exit with an error
+ { echo "$changedlist"
+ echo '#fstab'
+ cat /etc/fstab
+ } | awk 'BEGIN{list=1}
+ list==1 && $0=="#fstab"{list=0; continue}
+ list==1{new[$1] = $2; continue}
+ new[$1] != ""{$1 = new[$1]}
+ {print}' >/tmp/fstab.$$ || {
+ if test "$1" = start
+ then
+ logger -s "/etc/init.d/fixfstab: /tmp/fstab.$$: awk failed"
+ else
+ echo "debug: awk script failed with:" >&2
+ echo "$changedlist" >&2
+ echo "output in /tmp/fstab.$$" >&2
+ fi
+ exit 1
+ }
+
+ if test "$1" = start
+ then
+ mv /tmp/fstab.$$ /etc/fstab || {
+ logger -s "/etc/init.d/fixfstab: /tmp/fstab.$$: update failed"
+ exit 1
+ }
+ else
+ echo "debug: fstab changed:"
+ diff -u /etc/fstab /tmp/fstab.$$
+ fi
+ fi
+ fi
+fi
+
+# write the new list to the file, only if we
+# are doing something...
+test "$1" = start && echo "$newlist" >"$pfile"
+
+exit 0
============================================================
--- packages/openturbostation-init/files/initscripts/loadmodules.sh 65850cc8bc415b6ddf67c8fca195698d565ed12b
+++ packages/openturbostation-init/files/initscripts/loadmodules.sh 65850cc8bc415b6ddf67c8fca195698d565ed12b
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+. /etc/default/modulefunctions # Load module loading logic
+
+loadnetmods
+
+loaddiskmods
+
+loadmiscmods
+
+exit 0
============================================================
--- packages/openturbostation-init/files/initscripts/rmrecovery 981d670242c4af8a2e143c4edc0673f08f0379ce
+++ packages/openturbostation-init/files/initscripts/rmrecovery 981d670242c4af8a2e143c4edc0673f08f0379ce
@@ -0,0 +1,4 @@
+#!/bin/sh
+# Run to remove /.recovery if the boot seems to have succeeded
+test -e /.recovery && rm -f /.recovery
+exit 0
============================================================
--- packages/openturbostation-init/files/initscripts/sysconfsetup a7c4367f43c69e64b0f6b9ef2706f7f68a08b9e3
+++ packages/openturbostation-init/files/initscripts/sysconfsetup a7c4367f43c69e64b0f6b9ef2706f7f68a08b9e3
@@ -0,0 +1,46 @@
+#!/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 (/etc/default/sysconf) to recreate it, run this
+# script with the reload option to overwrite the system files. The
+# configuration files described in sysconf_reload (in
+# /sbin/sysconf) will be overwritten on reload.
+#
+# start: standard startup, do a complete (auto) restore if necessary
+# reinit: always do a complete auto restore
+# reload: just reload sysconf (no config files!)
+#
+# /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
+load_functions sysconf || exit 1
+#
+case "$1" in
+start) test -s /etc/default/sysconf || {
+ if sysconf_read
+ then
+ if sysconf_valid
+ then
+ sysconf_restore auto
+ else
+ sysconf_reload
+ fi
+ else
+ sysconf_default
+ sysconf_reload
+ fi
+ };;
+
+reload) test -s /etc/default/sysconf || sysconf_read || sysconf_default
+ sysconf_reload;;
+
+reinit) sysconf_restore auto;;
+
+*) ;;
+esac
============================================================
--- packages/openturbostation-init/files/initscripts/syslog.buffer bec2ff9c7eb754176df297d6064c455b6762c0f4
+++ packages/openturbostation-init/files/initscripts/syslog.buffer bec2ff9c7eb754176df297d6064c455b6762c0f4
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# Invoke the syslog startup if the configuration
+# uses (only) 'buffer' as the DESTINATION
+DESTINATION=
+test -f /etc/syslog.conf && . /etc/syslog.conf
+doit=
+
+for d in $DESTINATION
+do
+ case "$d" in
+ buffer) doit=1;;
+ file) exit 0;;
+ remote) exit 0;;
+ *) echo "/etc/syslog.conf: $d: unknown destination" >&2
+ exit 1;;
+ esac
+done
+
+test -n "$doit" -a -x /etc/init.d/syslog &&
+ exec /etc/init.d/syslog "$@"
+
+exit 0
============================================================
--- packages/openturbostation-init/files/initscripts/syslog.file 80c43d8ea5fd111a047c968bec660a1e86c3a054
+++ packages/openturbostation-init/files/initscripts/syslog.file 80c43d8ea5fd111a047c968bec660a1e86c3a054
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# Invoke the syslog startup if the configuration
+# uses 'file' (and, optionally, buffer) as the DESTINATION
+DESTINATION=
+test -f /etc/syslog.conf && . /etc/syslog.conf
+doit=
+
+for d in $DESTINATION
+do
+ case "$d" in
+ buffer) :;;
+ file) doit=1;;
+ remote) exit 0;;
+ *) echo "/etc/syslog.conf: $d: unknown destination" >&2
+ exit 1;;
+ esac
+done
+
+test -n "$doit" -a -x /etc/init.d/syslog &&
+ exec /etc/init.d/syslog "$@"
+
+exit 0
============================================================
--- packages/openturbostation-init/files/initscripts/syslog.network f9ef95e6aa2e648d0ceecbef03fbd07235a77ca3
+++ packages/openturbostation-init/files/initscripts/syslog.network f9ef95e6aa2e648d0ceecbef03fbd07235a77ca3
@@ -0,0 +1,28 @@
+#!/bin/sh
+#
+# Invoke the syslog startup if the configuration
+# uses 'remote', or doesn't use 'buffer' or 'file'
+DESTINATION=
+test -f /etc/syslog.conf && . /etc/syslog.conf
+doit=
+doneit=
+
+for d in $DESTINATION
+do
+ case "$d" in
+ buffer) doneit=1;;
+ file) doneit=1;;
+ remote) doit=1;;
+ *) doit=1
+ echo "/etc/syslog.conf: $d: unknown destination" >&2
+ exit 1;;
+ esac
+done
+
+# One of doneit or doit is set unless the DESTINATION value
+# is empty (which is probably an error), let syslog handle
+# the error.
+test \( -n "$doit" -o -z "$doneit" \) -a -x /etc/init.d/syslog &&
+ exec /etc/init.d/syslog "$@"
+
+exit 0
============================================================
--- packages/openturbostation-init/files/initscripts/umountinitrd.sh 09230709c6200572b1fc888fa27f570433601bc1
+++ packages/openturbostation-init/files/initscripts/umountinitrd.sh 09230709c6200572b1fc888fa27f570433601bc1
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# umount /mnt, which is where the initrd ends up mounted
+# if the directory /initrd is not present, if this fails
+# then the /initrd is mounted and we want to remount that
+# ro - this works round the shutdown -r hang problem
+. /etc/default/functions
+#
+# if we are turnup'ed to disk, then just unmount the initrd all together
+#
+if [ -e /initrd/dev/.devfsd ]; then
+ [ "$VERBOSE" = "very" ] && echo "Unmounting initrd..."
+ umount /initrd/dev
+ umount /initrd
+ exit 0
+fi
+
+while read device directory remainder
+do
+ case "$directory" in
+ /mnt) echo "InitRD: unmount initrd on /mnt" >&2
+ umount /mnt;;
+ /initrd)# need the device for a remount
+ ffspart=Flashdisk
+ ffsdev="$(mtblockdev $ffspart)"
+ echo "InitRD: remount $ffdev read-only on /initrd" >&2
+ if test -n "$ffsdev" -a -b "$ffsdev"
+ then
+ mount -o remount,ro "$ffsdev" /initrd
+ else
+ echo "Flashdisk: $ffsdev: flash device not found" >&2
+ fi;;
+ esac
+done </proc/mounts
More information about the Openembedded-commits
mailing list