summaryrefslogtreecommitdiff
path: root/packages/slugos-init
diff options
context:
space:
mode:
authorRod Whitby <rod@whitby.id.au>2006-01-07 08:58:44 +0000
committerOpenEmbedded Project <openembedded-devel@lists.openembedded.org>2006-01-07 08:58:44 +0000
commit8fb6b2d3d410ad2badf0c99ed7a66b698aafaa17 (patch)
tree8a700d795bdf33061b8bccc353fe0aaffa044036 /packages/slugos-init
parent0b67482ddc4fe571d16fa094627abb447b9a8edb (diff)
slugos: Major rename of common SlugOS files and directories from openslug to slugos.
Diffstat (limited to 'packages/slugos-init')
-rw-r--r--packages/slugos-init/.mtn2git_empty0
-rw-r--r--packages/slugos-init/files/.mtn2git_empty0
-rw-r--r--packages/slugos-init/files/README49
-rw-r--r--packages/slugos-init/files/boot/.mtn2git_empty0
-rw-r--r--packages/slugos-init/files/boot/disk49
-rw-r--r--packages/slugos-init/files/boot/flash14
-rw-r--r--packages/slugos-init/files/boot/network25
-rw-r--r--packages/slugos-init/files/boot/nfs17
-rw-r--r--packages/slugos-init/files/boot/ram47
-rw-r--r--packages/slugos-init/files/boot/udhcpc.script17
-rw-r--r--packages/slugos-init/files/conffiles50
-rw-r--r--packages/slugos-init/files/functions332
-rw-r--r--packages/slugos-init/files/initscripts/.mtn2git_empty0
-rw-r--r--packages/slugos-init/files/initscripts/leds_startup11
-rw-r--r--packages/slugos-init/files/initscripts/rmrecovery4
-rw-r--r--packages/slugos-init/files/initscripts/sysconfsetup231
-rw-r--r--packages/slugos-init/files/initscripts/syslog.buffer23
-rw-r--r--packages/slugos-init/files/initscripts/syslog.file23
-rw-r--r--packages/slugos-init/files/initscripts/syslog.network28
-rw-r--r--packages/slugos-init/files/initscripts/umountinitrd.sh18
-rw-r--r--packages/slugos-init/files/initscripts/zleds38
-rw-r--r--packages/slugos-init/files/kern_header.c47
-rw-r--r--packages/slugos-init/files/leds.c190
-rw-r--r--packages/slugos-init/files/leds.h21
-rw-r--r--packages/slugos-init/files/links.conf6
-rw-r--r--packages/slugos-init/files/linuxrc146
-rw-r--r--packages/slugos-init/files/modprobe.conf3
-rw-r--r--packages/slugos-init/files/modutils.txt1
-rw-r--r--packages/slugos-init/files/reflash620
-rw-r--r--packages/slugos-init/files/turnup890
-rw-r--r--packages/slugos-init/files/update-kernel82
-rw-r--r--packages/slugos-init/slugos-init_0.10.bb151
32 files changed, 3133 insertions, 0 deletions
diff --git a/packages/slugos-init/.mtn2git_empty b/packages/slugos-init/.mtn2git_empty
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/packages/slugos-init/.mtn2git_empty
diff --git a/packages/slugos-init/files/.mtn2git_empty b/packages/slugos-init/files/.mtn2git_empty
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/packages/slugos-init/files/.mtn2git_empty
diff --git a/packages/slugos-init/files/README b/packages/slugos-init/files/README
new file mode 100644
index 0000000000..264d4d8f85
--- /dev/null
+++ b/packages/slugos-init/files/README
@@ -0,0 +1,49 @@
+OpenSlug-1.x Family Release README
+
+Warning: OpenSlug is not for the faint of heart! In fact, OpenSlug has a
+specific target audience.
+
+Some background first. According to the NSLU2 - Linux developers, there are 4
+specific types ("camps") of NSLU2 - Linux users:
+
+ Camp #1: Users who want full Linksys compatibility (including for future
+ Linksys firmware releases). They can load firmware images via
+ the Linksys web interface and telnet in - to load Optware -
+ Unslung packages with ipkg, but have no idea what RedBoot is or
+ does.
+
+ Camp #2: "Camp #1 Plus users." They can telnet into RedBoot (ability
+ to "self-rescue" a non-working NSLU2), and are comfortable
+ using Linux.
+
+ Camp #3: Power users! Firmware flashing via any interface is a walk
+ in the park. They aren't just *users*, but are developers or
+ administrators of computers and/or computer software.
+ However, they have no JTAG or custom bootloaders.
+
+ Camp #4: Bleeding edge users. They create and use custom bootloaders,
+ certainly having no need or desire for Linksys compatibility,
+ modifying and/or changing the hardware as well.
+
+With those camps in mind, OpenSlug is targetted toward Camp #3 and Camp #4
+users. If you're not in Camps 3 & 4, then you should be looking to use the
+Unslung firmware. If you are a Camp #2 user, and still want to use OpenSlug,
+you need to practice gaining RedBoot access, and be able to recover from bad
+flashes, "drive not formatted" conditions, and other common mistakes/problems
+which are documented in the NSLU2-Linux Wiki at http://www.nslu2-linux.org.
+Once you are comfortable doing those things, then you may consider using
+OpenSlug.
+
+If you're still reading - and still intent on using OpenSlug, click through
+the Intel license, download the latest OpenSlug binary and flash it to your
+NSLU2! (Without any HD attached while flashing!!!) Your next stop should be
+the OpenSlug Turnip page at:
+
+ http://www.nslu2-linux.org/wiki/OpenSlug/OpenSlugTurnUp
+
+Please add your name and information to the OpenSlug database at the yahoo
+NSLU2-Linux group at:
+
+ http://groups.yahoo.com/group/nslu2-linux/
+
+Happy OpenSlugging! \ No newline at end of file
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
diff --git a/packages/slugos-init/files/conffiles b/packages/slugos-init/files/conffiles
new file mode 100644
index 0000000000..51a8091b1e
--- /dev/null
+++ b/packages/slugos-init/files/conffiles
@@ -0,0 +1,50 @@
+# 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
+diff 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/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
diff --git a/packages/slugos-init/files/functions b/packages/slugos-init/files/functions
new file mode 100644
index 0000000000..e90f03aead
--- /dev/null
+++ b/packages/slugos-init/files/functions
@@ -0,0 +1,332 @@
+# . this file to load the following utility functions
+#
+# 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(){
+ sed -n 's!^\(mtd[0-9][0-9]*\):[^"]*"'"$1"'"$!/dev/\1!p' /proc/mtd
+}
+#
+# mtblockdev "name"
+# as mtdev but output the name of the block (not character) device
+mtblockdev(){
+ sed -n 's!^mtd\([0-9][0-9]*\):[^"]*"'"$1"'"$!/dev/mtdblock\1!p' /proc/mtd
+}
+#
+# 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',
+# this is a bit gross, when it gets a match it copies the value to the
+# hold space, if no match it jumps over the copy, at the end ($) it copies
+# the hold space to the pattern space and prints the result, thus it only
+# ever prints the last match
+# BUG FIX: busybox sed doesn't initialise the hold space and crashes if it
+# is used before initialisation, so temporarily this script does it's own
+# tail by hand.
+# NOTE: these functions should only be used internally, add entries to 'config'
+# below if necessary. This is because 'config' does the defaulting and in the
+# recovering case (zero or absent SysConf) /etc/default/sysconf only contains
+# the hw_addr entry!
+sysvalmatch(){
+ # sed -n '/^\['"$1"'\]$/,/^\[.*\]$/s/^'"$2"'=\('"$3"'\)$/\1/;tH;bE;:H;h;:E;$g;$p' "$4"
+ sed -n '/^\['"$1"'\]$/,/^\[.*\]$/s/^'"$2"'=\('"$3"'\)$/\1/p' "$4" | sed -n '$p'
+}
+sysvalof(){
+ sysvalmatch "$1" "$2" '.*' "$3"
+}
+sysval(){
+ sysvalof "$1" "$2" /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! Validity
+# of the sysconf file is determined by the presence of the all important
+# hw_addr.
+config(){
+ local mac
+ mac=
+ test -r /etc/default/sysconf &&
+ mac="$(sysvalmatch network hw_addr '[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]' /etc/default/sysconf)"
+ if test -n "$mac"
+ then
+ case "$1" in
+ 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
+ else
+ echo "$mac" | sed -n 's/^..:..:..:\(..\):\(..\):\(..\)$/LKG\1\2\3/p'
+ 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.77
+ 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) return 0;;
+ *) return 1;;
+ esac
+ else
+ # These are the defaults for an invalid mac address, use the compiled
+ # in hardware address.
+ case "$1" in
+ mac) echo "00:02:B3:02:02:01";;
+ host) echo "brokenslug";;
+ iface) echo eth0;;
+ ip) echo 192.168.1.77;;
+ boot) echo dhcp;;
+ *) return 1;;
+ esac
+ fi
+}
+#
+# 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 and no .recovery too
+ test \( ! -f "$1/.recovery" \) -a \
+ \( -d "$1/initrd" -o -d "$1/mnt" \) -a \
+ \( -x "$1/bin/sh" -o -h "$1/bin/sh" \) -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 /proc
+# was mounted it must be restored by the caller on return.
+# Normally this function never returns!
+# On return 0,1,2 are connected to /dev/console - this may not
+# have been true before!
+swivel() {
+ cd "$1"
+ exec <&- >&- 2>&-
+ # This is just-in-case the called mounted /proc and was
+ # unable to close it because of the streams
+ umount /proc 2>/dev/null
+ if pivot_root . "$2"
+ then
+ # everything must move out of the old root, this process
+ # is $2/bin/sh so it must die, IO is redirected
+ # just in case - typically it will be to a device so it
+ # won't hold the old root open.
+ # the exec here is the first point at which the old root
+ # is unused - before the exec regardless of the close of
+ # 0,1,2 above ash still has *this* shell script open!
+ # (it's on fd 10).
+ # init closes all file descriptors, there's no point
+ # supplying it with fds.
+ # NOTE: this used to use $2/usr/sbin/chroot, however on
+ # linux / is already . when the command is executed
+ # therefore it is essential to use the local (new root)
+ # chroot to ensure it gets the correct shared libraries.
+ exec usr/sbin/chroot . bin/sh -c "\
+ test -x sbin/init && exec sbin/init
+ test -x etc/init && exec etc/init
+ test -x bin/init && exec bin/init
+ leds -A +gr1 '!g1'
+ sleep 10 >/.recovery
+ sync;sync;sync
+ exit 1"
+ fi
+ #
+ # recovery - must restore the old root
+ cd "$2"
+ sbin/pivot_root . "$1"
+ # cd is back to $1 - either pivot_root doesn't change it and the
+ # chroot above was not executed, or pivot_root does change it and
+ # has just changed it back!
+ exec <>/dev/console >&0 2>&0
+}
+#
+# ifup "interface"
+# bring that interface up with the configured ip and other
+# information
+ifup(){
+ local ip hostname router subnet iface HOSTNAME NETMASK BROADCAST
+
+ iface="$1"
+ ip="$(config ip)"
+ hostname="$(config host)"
+ router="$(config gateway)"
+ broadcast=
+
+ if test -n "$ip"
+ then
+ # only if an ip was specified
+ subnet="$(config netmask)"
+ else
+ ip=192.168.1.77
+ fi
+
+ # First try udhcpc - note that the /boot/udhcpc.script
+ # simply records the values returned and the udhcpc
+ # is not left running so this will only work for
+ # the lease length time!
+ ifconfig "$iface" up
+ if test "$(config boot)" != static
+ then
+ test -n "$hostname" && HOSTNAME="-H $hostname"
+ # 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)
+ fi
+
+ test -n "$broadcast" && BROADCAST="broadcast $broadcast"
+ test -n "$subnet" && NETMASK="netmask $subnet"
+
+ if ifconfig "$iface" "$ip" $NETMASK $BROADCAST
+ then
+ for route in $router
+ do
+ route add default gw "$route" dev "$iface"
+ done
+ return 0
+ else
+ ifconfig "$iface" down
+ return 1
+ fi
+}
+#
+# ifdown "interface"
+# take the interface down
+ifdown(){
+ ifconfig "$1" down
+}
+#
+# mountflash "flash device" "flash root directory" {mount options}
+# Finds and mounts the flash file system on the given directory
+mountflash() {
+ local ffsdev ffsdir
+
+ ffsdev="$1"
+ test -n "$ffsdev" -a -b "$ffsdev" || {
+ echo "$0: unable to find flash file system to copy ($ffsdev)" >&2
+ return 1
+ }
+ shift
+
+ ffsdir="$1"
+ test -n "$ffsdir" -a -d "$ffsdir" || {
+ echo "$0: mountflash $ffsdir: not a directory (internal error)" >&2
+ return 1
+ }
+ shift
+
+ mount -t jffs2 "$@" "$ffsdev" "$ffsdir" || {
+ echo "$0: $ffsdev: unable to mount flash file system on $ffsdir" >&2
+ return 1
+ }
+ return 0
+}
+#
+# umountflash [-r] "flash device"
+# unmount any instance of the given flash device, if -r is specified a mount on
+# root is an error, otherwise a mount on root is ignored (and remains).
+umountflash() {
+ local rootok ffsno ffsdev
+ rootok=1
+ case "$1" in
+ -r) rootok=
+ shift;;
+ esac
+ #
+ # The argument is ffsdev
+ ffsdev="$1"
+ ffsno="$(devio "<<$ffsdev" prd)"
+ test -n "$ffsno" -a "$ffsno" -ge 0 || {
+ echo "$0: $ffsdev: device number $ffsno is not valid, cannot continue." >&2
+ return 1
+ }
+ #
+ # Make sure that Flashdisk isn't mounted on /
+ if test -z "$rootok" -a "$(devio "<</etc/init.d/sysconfsetup" prd)" -eq "$ffsno"
+ then
+ echo "$0: $ffsdev is mounted on /, use turnup ram" >&2
+ return 1
+ fi
+ #
+ # The function is currently always used interactively, so output
+ echo "$0: umounting any existing mount of $ffsdev" >&2
+ #
+ # check each mount point, do this last first because otherwise nested
+ # mounts of ffsdev cannot be umounted.
+ ffs_umount() {
+ local device mp type options stuff
+
+ read device mp type options stuff
+ test -z "$device" && return 0
+
+ # handle following entries first
+ ffs_umount || return 1
+
+ # handle this entry, since this is currently only used for unmounting
+ # the flash root partition we know a file which must exist...
+ case "$mp/$type" in
+ //jffs2);; # skip /
+ */jffs2)test "$(devio "<<$mp/etc/init.d/sysconfsetup" prd 2>/dev/null)" -ne "$ffsno" ||
+ umount "$mp" || {
+ echo "$0: $mp: unable to umount $ffsdev" >&2
+ return 1
+ };;
+ esac
+
+ return 0
+ }
+ #
+ ffs_umount </proc/mounts || {
+ echo "$0: umount $ffsdev from all mount points then re-run reflash" >&2
+ return 1
+ }
+
+ return 0
+}
diff --git a/packages/slugos-init/files/initscripts/.mtn2git_empty b/packages/slugos-init/files/initscripts/.mtn2git_empty
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/packages/slugos-init/files/initscripts/.mtn2git_empty
diff --git a/packages/slugos-init/files/initscripts/leds_startup b/packages/slugos-init/files/initscripts/leds_startup
new file mode 100644
index 0000000000..945d75bd02
--- /dev/null
+++ b/packages/slugos-init/files/initscripts/leds_startup
@@ -0,0 +1,11 @@
+#!/bin/sh
+# Bug fix: during the initial boot sysvinit sets PREVLEVEL to
+# nothing in rcS and to 'N' in the transition from rcS to the
+# user state. This script runs on that transition and, if
+# the PREVLEVEL is 'N', sets 'previous' (as in /etc/init.d/rc)
+# to 'S'
+if test "$PREVLEVEL" = N
+then
+ previous=S exec /etc/init.d/zleds stop
+fi
+exit 0
diff --git a/packages/slugos-init/files/initscripts/rmrecovery b/packages/slugos-init/files/initscripts/rmrecovery
new file mode 100644
index 0000000000..eec822b154
--- /dev/null
+++ b/packages/slugos-init/files/initscripts/rmrecovery
@@ -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
diff --git a/packages/slugos-init/files/initscripts/sysconfsetup b/packages/slugos-init/files/initscripts/sysconfsetup
new file mode 100644
index 0000000000..31ff38d7ee
--- /dev/null
+++ b/packages/slugos-init/files/initscripts/sysconfsetup
@@ -0,0 +1,231 @@
+#!/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
+#
+# /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
+#
+config valid && test "$1" != reload && exit 0
+#
+# 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=
+config valid || 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 '<</dev/mtd1;cpb'
+ #
+ # to examine the current settings. The badly formatted stuff
+ # is removed (to be exact, the sed script selects only lines
+ # which match one of the two above). The lan interface, which
+ # defaults to ixp0, is changed to the correct value for openslug,
+ # eth0. The bootproto, which LinkSys sets to static in manufacturing,
+ # is reset to dhcp if the IP is still the original (192.168.1.77)
+ devio "<<$sysdev" cpb fb1,10 | sed -n '/^\[[^][]*\]$/p;
+ s/^lan_interface=ixp0$/lan_interface=eth0/;
+ /^ip_addr=192\.168\.1\.77$/,/^bootproto/s/^bootproto=static$/bootproto=dhcp/;
+ /^[-a-zA-Z0-9_][-a-zA-Z0-9_]*=/p' >/etc/default/sysconf
+ #
+ # The SysConf must have a hardware id, if it doesn't it has
+ # probably been erased or never set in the first place and the
+ # hardware id is retrieved from the RedBoot partition. This is
+ # the only thing which cannot be defaulted.
+fi
+#
+# Error recovery: no SysConf or invalid SysConf. Make a new one from the
+# RedBoot hardware ID information.
+# NOTE: this block of code overwrites the shell script arguments.
+config valid || {
+ reddev="$(mtblockdev RedBoot)"
+ initmac=
+ if test -n "$reddev" -a -b "$reddev"
+ then
+ # The hardware id starts 80 bytes before the end of the
+ # block, the block ends (or should end) with the signature
+ # <4 bytes> sErCoMm <bytes> sErCoMm. Note that devio 'pf'
+ # empties the stack.