[oe-commits] org.oe.dev openprotium-init: a descendant of slugos-init with protium and storcenter related changes.
awilcox commit
openembedded-commits at lists.openembedded.org
Sat Dec 23 22:17:05 UTC 2006
openprotium-init: a descendant of slugos-init with protium and storcenter related changes.
Author: awilcox at openembedded.org
Branch: org.openembedded.dev
Revision: a25740693ac2e076ba730cff4951a1681ae05cce
ViewMTN: http://monotone.openembedded.org/revision.psp?id=a25740693ac2e076ba730cff4951a1681ae05cce
Files:
1
packages/openprotium-init
packages/openprotium-init/files
packages/openprotium-init/files/boot
packages/openprotium-init/files/initscripts
packages/openprotium-init/files/boot/disk
packages/openprotium-init/files/boot/flash
packages/openprotium-init/files/boot/network
packages/openprotium-init/files/boot/nfs
packages/openprotium-init/files/boot/udhcpc.script
packages/openprotium-init/files/conffiles
packages/openprotium-init/files/functions
packages/openprotium-init/files/initscripts/fixfstab
packages/openprotium-init/files/initscripts/loadmodules.sh
packages/openprotium-init/files/initscripts/rmrecovery
packages/openprotium-init/files/initscripts/sysconfsetup
packages/openprotium-init/files/initscripts/syslog.buffer
packages/openprotium-init/files/initscripts/syslog.file
packages/openprotium-init/files/initscripts/syslog.network
packages/openprotium-init/files/initscripts/umountinitrd.sh
packages/openprotium-init/files/links.conf
packages/openprotium-init/files/modulefunctions
packages/openprotium-init/files/reflash
packages/openprotium-init/files/sysconf
packages/openprotium-init/files/turnup
packages/openprotium-init/openprotium-init_0.10.bb
Diffs:
#
# mt diff -rcd737e0251b1d5fce0fdc1dd08fd541ceb98ee31 -ra25740693ac2e076ba730cff4951a1681ae05cce
#
#
#
# add_dir "packages/openprotium-init"
#
# add_dir "packages/openprotium-init/files"
#
# add_dir "packages/openprotium-init/files/boot"
#
# add_dir "packages/openprotium-init/files/initscripts"
#
# add_file "packages/openprotium-init/files/boot/disk"
# content [9013d8fc4ac2debd474c52e9d86794b9d64cca74]
#
# add_file "packages/openprotium-init/files/boot/flash"
# content [ac150c76696ab08f8ea6c6ec70514977285bf5bf]
#
# add_file "packages/openprotium-init/files/boot/network"
# content [7863638b33cded9710583ad3868e24dc35c04195]
#
# add_file "packages/openprotium-init/files/boot/nfs"
# content [eb5efe23bc1d0b1f6e0dc29f7cb0aec3604ad5c5]
#
# add_file "packages/openprotium-init/files/boot/udhcpc.script"
# content [1ed51b781d5c54d52e082e536643650391d1adef]
#
# add_file "packages/openprotium-init/files/conffiles"
# content [f1ace3f1649eab164c7a09a2b6e017f748b39dfa]
#
# add_file "packages/openprotium-init/files/functions"
# content [4b0704488f3f4dcbc4d79d07888c4d57870921e9]
#
# add_file "packages/openprotium-init/files/initscripts/fixfstab"
# content [6ad84d3f2c2390442eedd0de77d2b942fd823692]
#
# add_file "packages/openprotium-init/files/initscripts/loadmodules.sh"
# content [65850cc8bc415b6ddf67c8fca195698d565ed12b]
#
# add_file "packages/openprotium-init/files/initscripts/rmrecovery"
# content [981d670242c4af8a2e143c4edc0673f08f0379ce]
#
# add_file "packages/openprotium-init/files/initscripts/sysconfsetup"
# content [a7c4367f43c69e64b0f6b9ef2706f7f68a08b9e3]
#
# add_file "packages/openprotium-init/files/initscripts/syslog.buffer"
# content [bec2ff9c7eb754176df297d6064c455b6762c0f4]
#
# add_file "packages/openprotium-init/files/initscripts/syslog.file"
# content [80c43d8ea5fd111a047c968bec660a1e86c3a054]
#
# add_file "packages/openprotium-init/files/initscripts/syslog.network"
# content [f9ef95e6aa2e648d0ceecbef03fbd07235a77ca3]
#
# add_file "packages/openprotium-init/files/initscripts/umountinitrd.sh"
# content [09230709c6200572b1fc888fa27f570433601bc1]
#
# add_file "packages/openprotium-init/files/links.conf"
# content [cbb6d9498021f0bd16cc118462c107fe022805fd]
#
# add_file "packages/openprotium-init/files/modulefunctions"
# content [dee4339028f8485586183b3eb1b3300e6c56a424]
#
# add_file "packages/openprotium-init/files/reflash"
# content [018401591f5718096bd756a8fb455c9a921e263c]
#
# add_file "packages/openprotium-init/files/sysconf"
# content [4ce6fa9ab9b9c0186e446756897a03129a5ce7ef]
#
# add_file "packages/openprotium-init/files/turnup"
# content [1284c9014511c5b14c9334d8119b11b52fbe5f23]
#
# add_file "packages/openprotium-init/openprotium-init_0.10.bb"
# content [0a42ed35fa65b68a18fd3a8f2e859bcb903b03c2]
#
============================================================
--- packages/openprotium-init/files/boot/disk 9013d8fc4ac2debd474c52e9d86794b9d64cca74
+++ packages/openprotium-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/openprotium-init/files/boot/flash ac150c76696ab08f8ea6c6ec70514977285bf5bf
+++ packages/openprotium-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/openprotium-init/files/boot/network 7863638b33cded9710583ad3868e24dc35c04195
+++ packages/openprotium-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/openprotium-init/files/boot/nfs eb5efe23bc1d0b1f6e0dc29f7cb0aec3604ad5c5
+++ packages/openprotium-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/openprotium-init/files/boot/udhcpc.script 1ed51b781d5c54d52e082e536643650391d1adef
+++ packages/openprotium-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/openprotium-init/files/conffiles f1ace3f1649eab164c7a09a2b6e017f748b39dfa
+++ packages/openprotium-init/files/conffiles f1ace3f1649eab164c7a09a2b6e017f748b39dfa
@@ -0,0 +1,55 @@
+# conffiles
+# Known SlugOS configuration files. These files are preserved on
+# a flash upgrade. Other configuration files, found from:
+#
+# /usr/lib/ipkg/*.conffiles
+# /etc/*.conf
+#
+# are preserved too with an operation of 'diff' if they have been
+# changed since /etc/.configured was created.
+#
+# Lines starting with # are comments, other lines have
+# two fields:
+#
+# operation file
+#
+# The file must *NOT* have a leading /
+#
+# operation may be:
+# ignore Do not preserve this file
+# preserve Preserve this file unconditionally
+# diff Compare file with the new version, ask if different
+#
+preserve linuxrc
+preserve etc/.configured
+preserve etc/TZ
+diff etc/default/conffiles
+diff etc/default/devpts
+preserve etc/default/rcS
+preserve etc/default/sysconf
+diff etc/default/usbd
+preserve etc/defaultdomain
+preserve etc/dropbear/dropbear_dss_host_key
+preserve etc/dropbear/dropbear_rsa_host_key
+preserve etc/ssh/ssh_host_dsa_key
+preserve etc/ssh/ssh_host_dsa_key.pub
+preserve etc/ssh/ssh_host_rsa_key
+preserve etc/ssh/ssh_host_rsa_key.pub
+preserve etc/fstab
+preserve etc/group
+preserve etc/gshadow
+preserve etc/hostname
+preserve etc/hosts
+preserve etc/localtime
+ignore etc/modules
+ignore etc/modules.conf
+preserve etc/motd
+preserve etc/network/interfaces
+preserve etc/ntp.drift
+preserve etc/passwd
+preserve etc/profile
+preserve etc/resolv.conf
+preserve etc/shadow
+preserve etc/syslog.conf
+preserve etc/timezone
+preserve root/.ssh/authorized_keys
============================================================
--- packages/openprotium-init/files/functions 4b0704488f3f4dcbc4d79d07888c4d57870921e9
+++ packages/openprotium-init/files/functions 4b0704488f3f4dcbc4d79d07888c4d57870921e9
@@ -0,0 +1,413 @@
+#!/bin/sh
+# . this file to load the following utility functions
+#
+# hardware
+# the 'Hardware' string from cpuinfo, or, if not found
+# try a little harder with 'machine'
+hardware(){
+ local hdw
+ hdw=`sed -n 's!^Hardware *: !!p' /proc/cpuinfo`
+ test -n "$hdw" || {
+ hdw=`sed -n 's!^machine *: !!p' /proc/cpuinfo`
+ }
+ echo $hdw
+}
+#
+# machine
+# outputs an identifier of the current machine - i.e. the board
+# slugos is running on.
+machine(){
+ case "$(hardware)" in
+ *Coyote*) echo coyote;;
+ *IXDPG425*) echo ixdpg425;;
+ *WRV54G*) echo wrv54g;;
+ *IXDP425*) echo ixdp425;;
+ *IXDP465*) echo ixdp465;;
+ *IXCDP1100*) echo ixcdp1100*;;
+ *Avila*) echo avila;;
+ *Loft*) echo loft;;
+ *NAS?100d*) echo nas100d;;
+ *NSLU2*) echo nslu2;;
+ *StorCenter*) echo storcenter;;
+ *) echo unknown;;
+ esac
+}
+#
+# single_user_ok
+# if the machine is capable of single user interaction return
+# true, else return false. The result of this function is
+# preempted by setting SULOGIN to 'yes' or 'ok' in /etc/default/rcS
+single_user_ok() {
+ # list known good machines in the 'case'
+ test "$SULOGIN" = yes -o "$SULOGIN" = ok ||
+ case "$(machine)" in
+ ixdp*|avila|loft)
+ test "$SULOGIN" != never;;
+ *) return 1;;
+ esac
+}
+#
+# load_functions "source"
+# load the functions in '/sbin/source' - relies on /sbin/source being
+# a shell script and having support for this function.
+load_functions(){
+ test -n "$1" -a -x "/sbin/$1" && . "/sbin/$1" || {
+ echo "$0: /sbin/$1: script not found" >&2
+ return 1
+ }
+}
+#
+# mtdev "name"
+# return (output) the character device name for flash parition "name"
+# /proc/mtd has the general form:
+# dev: size erasesize name
+# mtd5: 00020000 00020000 "FIS directory"
+# use this rather than hard-wiring the device because the partition
+# table can change - looking in /proc/mtd is more reliable.
+mtdev(){
+ if test $(machine) = storcenter ; then
+ sed -n 's!^mtd\([0-9][0-9]*\):[^"]*"'"$1"'"$!/dev/mtd/\1!p' /proc/mtd
+ else
+ sed -n 's!^\(mtd[0-9][0-9]*\):[^"]*"'"$1"'"$!/dev/\1!p' /proc/mtd
+ fi
+}
+#
+# mtblockdev "name"
+# as mtdev but output the name of the block (not character) device
+mtblockdev(){
+ if test "$(machine)" = storcenter ; then
+ sed -n 's!^mtd\([0-9][0-9]*\):[^"]*"'"$1"'"$!/dev/mtdblock/\1!p' /proc/mtd
+ else
+ sed -n 's!^mtd\([0-9][0-9]*\):[^"]*"'"$1"'"$!/dev/mtdblock\1!p' /proc/mtd
+ fi
+}
+#
+# mtsize "name"
+# the size of the partition as a hexadecimal value (with 0x at the front)
+mtsize(){
+ sed -n 's!^mtd[0-9][0-9]*: \([^ ]*\)[^"]*"'"$1"'"$!0x\1!p' /proc/mtd
+}
+#
+# sysvalmatch "section" "name" 'pattern' "configuration file"
+# sysvalof "section" "name" "configuration file"
+# sysval "section" "name"
+# outputs the value of the SysConf variable 'name' from section 'section',
+# if there are multiple definitions only the last is output
+# NOTE: these functions should only be used internally, add entries to 'config'
+# below if necessary. This is because 'config' does the defaulting.
+sysvalmatch(){
+ sed -n '/^\['"$1"'\]$/,/^\[.*\]$/s/^'"$2"'=\('"$3"'\)$/\1/p' "$4" | sed -n '$p'
+}
+sysvalof(){
+ sysvalmatch "$1" "$2" '.*' "$3"
+}
+sysval(){
+ test -r "$config_root/etc/default/sysconf" &&
+ sysvalof "$1" "$2" "$config_root/etc/default/sysconf"
+}
+#
+# syssection "section"
+# outputs all the values from the given section changed to the format "name value"
+# (i.e. the '=' is dropped).
+syssection(){
+ test -r "$config_root/etc/default/sysconf" &&
+ sed -n '/^\['"$1"'\]$/,/^\[.*\]$/s/^\([^=]*\)=\(.*\)$/\1 \2/p' "$config_root/etc/default/sysconf"
+}
+#
+# config "value"
+# convenience callers for specific values to avoid mis-typing in scripts
+# NOTE: this function does the defaulting, 'sysval' does not!
+# config_root: if set this will override the root where config/sysval
+# looks for /etc/default/sysconf
+config(){
+ local mac
+ mac="$(test -r /proc/net/maclist &&
+ sed -n '/^[0-9A-Za-z][0-9A-Za-z]:[0-9A-Za-z][0-9A-Za-z]:[0-9A-Za-z][0-9A-Za-z]:[0-9A-Za-z][0-9A-Za-z]:[0-9A-Za-z][0-9A-Za-z]:[0-9A-Za-z][0-9A-Za-z]$/p' /proc/net/maclist |
+ sed -n 1p)"
+ #
+ case "$1" in
+ mac) test -n "$mac" && echo "$mac";;
+ host) if test -n "$(sysval network disk_server_name)"
+ then
+ sysval network disk_server_name
+ elif test -n "$(sysval network default_server_name)"
+ then
+ sysval network default_server_name
+ elif test -n "$mac"
+ then
+ echo "$mac" | sed -n 's/^\(..\):\(..\):\(..\):\(..\):\(..\):\(..\)$/slug\1\2\3\4\5\6/p'
+ else
+ # because we want the name to remain constant:
+ echo "openprotium"
+ fi;;
+ domain) sysval network w_d_name;;
+ iface) if test -n "$(sysval network lan_interface)"
+ then
+ sysval network lan_interface
+ else
+ echo eth0
+ fi;;
+ ip) if test -n "$(sysval network ip_addr)"
+ then
+ sysval network ip_addr
+ else
+ echo 192.168.1.16
+ fi;;
+ netmask)sysval network netmask;;
+ gateway)sysval network gateway;;
+ dns) sysval network dns_server1;;
+ dns2) sysval network dns_server2;;
+ dns3) sysval network dns_server3;;
+ boot) if test -n "$(sysval network bootproto)"
+ then
+ sysval network bootproto
+ else
+ echo dhcp
+ fi;;
+ valid) test -r "$config_root/etc/default/sysconf" -a -n "$mac";;
+ *) return 1;;
+ esac
+}
+#
+# checkif "iface"
+# Validate an interface name by making sure that it exists
+# in /proc/net/dev (and is not lo). The listing outputs the
+# interface followed by a :, the check function looks for
+# something of the form '$1[a-zA-Z0-9]*:' and outputs the
+# part preceding the ':'
+checkif(){
+ sed -n '/^[ ]*lo:/d;s/^[ ]*\('"$1"'[a-zA-Z0-9]*\):.*$/\1/p;tE;d;:E;q' /proc/net/dev
+}
+#
+# checkmount "mountpoint"
+# tests an already mounted mountpoint to see whether to attempt to
+# boot with this as root. Returns success if it appears ok.
+checkmount(){
+ # basic test for init (the kernel will try to load this)
+ # but require a shell in bin/sh too
+ test \( -d "$1/mnt" \) -a \
+ \( -x "$1/bin/sh" -o -h "$1/bin/sh" \) -a \
+ \( -x "$1/usr/sbin/chroot" -o -h "$1/usr/sbin/chroot" -o \
+ -x "$1/sbin/chroot" -o -h "$1/sbin/chroot" \) -a \
+ \( -x "$1/sbin/init" -o -h "$1/sbin/init" -o \
+ -x "$1/etc/init" -o -h "$1/etc/init" -o \
+ -x "$1/bin/init" -o -h "$1/bin/init" \)
+}
+#
+# swivel "new root" "old root"
+# NOTE: the arguments must be paths relative to /, bad things
+# will happen if the arguments themselves start with /
+# Pivot to a new root. This does all the fancy pivot_root stuff
+# including closing streams and does a umount /proc - it doesn't
+# matter if this fails (failure codes are ignored), but if /p%s
>>> DIFF TRUNCATED @ 16K
More information about the Openembedded-commits
mailing list