summaryrefslogtreecommitdiffstats
path: root/package/base-files/files.old
diff options
context:
space:
mode:
Diffstat (limited to 'package/base-files/files.old')
-rw-r--r--package/base-files/files.old/etc/hotplug2-common.rules61
-rw-r--r--package/base-files/files.old/etc/hotplug2-init.rules5
-rwxr-xr-xpackage/base-files/files.old/etc/init.d/boot110
-rwxr-xr-xpackage/base-files/files.old/etc/init.d/done20
-rwxr-xr-xpackage/base-files/files.old/etc/init.d/rcS26
-rwxr-xr-xpackage/base-files/files.old/etc/init.d/watchdog13
-rw-r--r--package/base-files/files.old/etc/inittab4
-rwxr-xr-xpackage/base-files/files.old/etc/preinit43
-rwxr-xr-xpackage/base-files/files.old/etc/watchdog13
-rwxr-xr-xpackage/base-files/files.old/init96
-rw-r--r--package/base-files/files.old/lib/firstboot/05_firstboot_skip10
-rw-r--r--package/base-files/files.old/lib/firstboot/10_determine_parts46
-rw-r--r--package/base-files/files.old/lib/firstboot/10_no_fo_clear_overlay17
-rw-r--r--package/base-files/files.old/lib/firstboot/10_reset_has_mini_fo12
-rw-r--r--package/base-files/files.old/lib/firstboot/20_has_mini_fo13
-rw-r--r--package/base-files/files.old/lib/firstboot/20_no_fo_mount_jffs15
-rw-r--r--package/base-files/files.old/lib/firstboot/20_reset_clear_jffs14
-rw-r--r--package/base-files/files.old/lib/firstboot/30_is_rootfs_mounted10
-rw-r--r--package/base-files/files.old/lib/firstboot/30_no_fo_pivot11
-rw-r--r--package/base-files/files.old/lib/firstboot/30_reset_copy_rom13
-rw-r--r--package/base-files/files.old/lib/firstboot/40_copy_ramoverlay15
-rw-r--r--package/base-files/files.old/lib/firstboot/40_no_fo_copy_ramoverlay14
-rw-r--r--package/base-files/files.old/lib/firstboot/50_pivot17
-rw-r--r--package/base-files/files.old/lib/firstboot/99_10_no_fo_cleanup13
-rw-r--r--package/base-files/files.old/lib/firstboot/99_10_with_fo_cleanup25
-rw-r--r--package/base-files/files.old/lib/preinit/05_mount_skip13
-rw-r--r--package/base-files/files.old/lib/preinit/10_check_for_mtd20
-rw-r--r--package/base-files/files.old/lib/preinit/10_essential_fs25
-rw-r--r--package/base-files/files.old/lib/preinit/10_indicate_preinit51
-rw-r--r--package/base-files/files.old/lib/preinit/20_check_jffs2_ready19
-rw-r--r--package/base-files/files.old/lib/preinit/20_device_fs_mount37
-rw-r--r--package/base-files/files.old/lib/preinit/30_device_fs_daemons36
-rw-r--r--package/base-files/files.old/lib/preinit/40_init_shm10
-rw-r--r--package/base-files/files.old/lib/preinit/40_mount_devpts15
-rw-r--r--package/base-files/files.old/lib/preinit/40_mount_jffs226
-rw-r--r--package/base-files/files.old/lib/preinit/41_merge_overlay_hooks24
-rw-r--r--package/base-files/files.old/lib/preinit/50_choose_console31
-rw-r--r--package/base-files/files.old/lib/preinit/50_indicate_regular_preinit12
-rw-r--r--package/base-files/files.old/lib/preinit/60_init_hotplug10
-rw-r--r--package/base-files/files.old/lib/preinit/70_pivot_jffs2_root14
-rw-r--r--package/base-files/files.old/lib/preinit/80_mount_root10
-rw-r--r--package/base-files/files.old/lib/preinit/90_init_console14
-rw-r--r--package/base-files/files.old/lib/preinit/90_mount_no_jffs212
-rw-r--r--package/base-files/files.old/lib/preinit/90_restore_config17
-rw-r--r--package/base-files/files.old/lib/preinit/99_10_mount_no_mtd12
-rw-r--r--package/base-files/files.old/lib/preinit/99_10_run_init16
-rw-r--r--package/base-files/files.old/lib/upgrade/common.sh230
-rwxr-xr-xpackage/base-files/files.old/sbin/firstboot44
-rwxr-xr-xpackage/base-files/files.old/sbin/mount_root26
49 files changed, 1360 insertions, 0 deletions
diff --git a/package/base-files/files.old/etc/hotplug2-common.rules b/package/base-files/files.old/etc/hotplug2-common.rules
new file mode 100644
index 000000000..a1d07d399
--- /dev/null
+++ b/package/base-files/files.old/etc/hotplug2-common.rules
@@ -0,0 +1,61 @@
+
+# uncomment me to log hotplug events
+# DEVPATH is set {
+# exec logger -s -t hotplug -p daemon.info "name=%DEVICENAME%, path=%DEVPATH%"
+# }
+
+$include /etc/hotplug2-platform.rules
+
+DEVICENAME ~~ (^null$|^full$|^ptmx$|^zero$|^gpio|^hvc) {
+ makedev /dev/%DEVICENAME% 0666
+ next-event
+}
+
+DEVICENAME ~~ (^tun|^tap[0-9]$) {
+ makedev /dev/net/%DEVICENAME% 0644
+}
+
+DEVICENAME ~~ (^controlC[0-9]$|^pcmC[0-9]D[0-9]|^timer$) {
+ makedev /dev/snd/%DEVICENAME% 0644
+ next-event
+}
+
+DEVICENAME ~~ ^lp[0-9]$ {
+ makedev /dev/%DEVICENAME% 0644
+ next-event
+}
+
+DEVPATH is set, SUBSYSTEM == input {
+ makedev /dev/input/%DEVICENAME% 0644
+}
+
+DEVICENAME == device-mapper {
+ makedev /dev/mapper/control 0600
+ next-event
+}
+
+ACTION == add, DEVPATH is set {
+ makedev /dev/%DEVICENAME% 0644
+}
+
+ACTION == add, DEVPATH is set, DEVICENAME ~~ ^tty {
+ chmod 0666 /dev/%DEVICENAME%
+}
+
+ACTION == add, DEVPATH is set, DEVICENAME ~~ ^ppp {
+ chmod 0600 /dev/%DEVICENAME%
+}
+
+ACTION == remove, DEVPATH is set, MAJOR is set, MINOR is set {
+ remove /dev/%DEVICENAME%
+}
+
+FIRMWARE is set, ACTION == add {
+ exec /sbin/hotplug-call firmware
+ load-firmware /lib/firmware
+ next-event
+}
+
+SUBSYSTEM == platform {
+ exec /sbin/hotplug-call %SUBSYSTEM%
+}
diff --git a/package/base-files/files.old/etc/hotplug2-init.rules b/package/base-files/files.old/etc/hotplug2-init.rules
new file mode 100644
index 000000000..f01169776
--- /dev/null
+++ b/package/base-files/files.old/etc/hotplug2-init.rules
@@ -0,0 +1,5 @@
+$include /etc/hotplug2-common.rules
+
+SUBSYSTEM == button {
+ exec kill -USR1 1
+}
diff --git a/package/base-files/files.old/etc/init.d/boot b/package/base-files/files.old/etc/init.d/boot
new file mode 100755
index 000000000..005c4ad6f
--- /dev/null
+++ b/package/base-files/files.old/etc/init.d/boot
@@ -0,0 +1,110 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006-2011 OpenWrt.org
+
+START=10
+STOP=98
+
+system_config() {
+ local cfg="$1"
+
+ local hostname conloglevel timezone
+
+ config_get hostname "$cfg" hostname 'OpenWrt'
+ echo "$hostname" > /proc/sys/kernel/hostname
+
+ config_get conloglevel "$cfg" conloglevel
+ config_get buffersize "$cfg" buffersize
+ [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize}
+
+ config_get timezone "$cfg" timezone 'UTC'
+ echo "$timezone" > /tmp/TZ
+
+ config_get zonename "$cfg" zonename
+ [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && ln -s "/usr/share/zoneinfo/$zonename" /tmp/localtime
+
+ # apply timezone to kernel
+ date -k
+
+ if [ -x /sbin/syslogd ]; then
+ local args log_ip log_size log_port log_type log_file
+ config_get log_ip "$cfg" log_ip
+ config_get log_size "$cfg" log_size 16
+ config_get log_port "$cfg" log_port 514
+ config_get log_type "$cfg" log_type circular
+ config_get log_file "$cfg" log_file "/var/log/messages"
+ args="${log_ip:+-L -R ${log_ip}:${log_port}} ${conloglevel:+-l $conloglevel}"
+ if [ "$log_type" = "file" ]; then
+ args="$args -s $log_size -O $log_file -S"
+ else
+ args="$args -C${log_size}"
+ fi
+ service_start /sbin/syslogd $args
+ fi
+ if [ -x /sbin/klogd ]; then
+ config_get klogconloglevel "$cfg" klogconloglevel
+ args="${klogconloglevel:+-c $klogconloglevel}"
+ service_start /sbin/klogd $args
+ fi
+}
+
+apply_uci_config() {
+ sh -c '. /lib/functions.sh; include /lib/config; uci_apply_defaults'
+}
+
+start() {
+ [ -f /proc/mounts ] || /sbin/mount_root
+ [ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc
+ [ -f /proc/net/vlan/config ] && vconfig set_name_type DEV_PLUS_VID_NO_PAD
+
+ mkdir -p /var/run
+ mkdir -p /var/log
+ mkdir -p /var/lock
+ mkdir -p /var/state
+ mkdir -p /tmp/.uci
+ chmod 0700 /tmp/.uci
+ touch /var/log/wtmp
+ touch /var/log/lastlog
+ touch /tmp/resolv.conf.auto
+ ln -sf /tmp/resolv.conf.auto /tmp/resolv.conf
+ grep -q debugfs /proc/filesystems && mount -o noatime -t debugfs debugfs /sys/kernel/debug
+ [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
+
+ load_modules /etc/modules.d/*
+
+ # allow wifi modules time to settle
+ sleep 1
+
+ /sbin/wifi detect > /tmp/wireless.tmp
+ [ -s /tmp/wireless.tmp ] && {
+ cat /tmp/wireless.tmp >> /etc/config/wireless
+ }
+ rm -f /tmp/wireless.tmp
+
+ apply_uci_config
+ config_load system
+ config_foreach system_config system
+
+ killall -q hotplug2
+ [ -x /sbin/hotplug2 ] && /sbin/hotplug2 --override --persistent \
+ --set-rules-file /etc/hotplug2.rules \
+ --set-coldplug-cmd /sbin/udevtrigger \
+ --max-children 1 >/dev/null 2>&1 &
+
+ # create /dev/root if it doesn't exist
+ [ -e /dev/root -o -h /dev/root ] || {
+ rootdev=$(awk 'BEGIN { RS=" "; FS="="; } $1 == "root" { print $2 }' < /proc/cmdline)
+ [ -n "$rootdev" ] && ln -s "$rootdev" /dev/root
+ }
+
+ # early sysctl to avoid networking races
+ if [ -d /proc/sys/net/ipv6/conf ]; then
+ for i in /proc/sys/net/ipv6/conf/*/accept_ra; do
+ echo 0 > $i
+ done
+ fi
+}
+
+stop() {
+ service_stop /sbin/klogd
+ service_stop /sbin/syslogd
+}
diff --git a/package/base-files/files.old/etc/init.d/done b/package/base-files/files.old/etc/init.d/done
new file mode 100755
index 000000000..827866912
--- /dev/null
+++ b/package/base-files/files.old/etc/init.d/done
@@ -0,0 +1,20 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+START=95
+boot() {
+ [ -d /tmp/root ] && {
+ lock /tmp/.switch2jffs
+ firstboot switch2jffs
+ lock -u /tmp/.switch2jffs
+ }
+
+ # process user commands
+ [ -f /etc/rc.local ] && {
+ sh /etc/rc.local
+ }
+
+ # set leds to normal state
+ . /etc/diag.sh
+ set_state done
+}
diff --git a/package/base-files/files.old/etc/init.d/rcS b/package/base-files/files.old/etc/init.d/rcS
new file mode 100755
index 000000000..3ec9bfef6
--- /dev/null
+++ b/package/base-files/files.old/etc/init.d/rcS
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+run_scripts() {
+ for i in /etc/rc.d/$1*; do
+ [ -x $i ] && $i $2 2>&1
+ done | $LOGGER
+}
+
+system_config() {
+ config_get_bool foreground $1 foreground 0
+}
+
+LOGGER="cat"
+[ -x /usr/bin/logger ] && LOGGER="logger -s -p 6 -t sysinit"
+
+. /lib/functions.sh
+
+config_load system
+config_foreach system_config system
+
+if [ "$1" = "S" -a "$foreground" != "1" ]; then
+ run_scripts "$1" "$2" &
+else
+ run_scripts "$1" "$2"
+fi
diff --git a/package/base-files/files.old/etc/init.d/watchdog b/package/base-files/files.old/etc/init.d/watchdog
new file mode 100755
index 000000000..299c89142
--- /dev/null
+++ b/package/base-files/files.old/etc/init.d/watchdog
@@ -0,0 +1,13 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008-2011 OpenWrt.org
+
+START=97
+
+start() {
+ [ -c /dev/watchdog ] || return 1
+ [ -x /sbin/watchdog ] || return 1
+ service_start /sbin/watchdog -t 5 /dev/watchdog
+}
+stop() {
+ service_stop /sbin/watchdog
+}
diff --git a/package/base-files/files.old/etc/inittab b/package/base-files/files.old/etc/inittab
new file mode 100644
index 000000000..ca90fd8a2
--- /dev/null
+++ b/package/base-files/files.old/etc/inittab
@@ -0,0 +1,4 @@
+::sysinit:/etc/init.d/rcS S boot
+::shutdown:/etc/init.d/rcS K shutdown
+ttyS0::askfirst:/bin/ash --login
+tty1::askfirst:/bin/ash --login
diff --git a/package/base-files/files.old/etc/preinit b/package/base-files/files.old/etc/preinit
new file mode 100755
index 000000000..b237c2e06
--- /dev/null
+++ b/package/base-files/files.old/etc/preinit
@@ -0,0 +1,43 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin
+
+pi_ifname=
+pi_ip=192.168.1.1
+pi_broadcast=192.168.1.255
+pi_netmask=255.255.255.0
+
+fs_failsafe_ifname=
+fs_failsafe_ip=192.168.1.1
+fs_failsafe_broadcast=192.168.1.255
+fs_failsafe_netmask=255.255.255.0
+
+fs_failsafe_wait_timeout=2
+
+pi_suppress_stderr="y"
+pi_init_suppress_stderr="y"
+pi_init_path="/bin:/sbin:/usr/bin:/usr/sbin"
+pi_init_cmd="/sbin/init"
+
+. /lib/functions.sh
+
+boot_hook_init preinit_essential
+boot_hook_init preinit_main
+boot_hook_init failsafe
+boot_hook_init initramfs
+boot_hook_init preinit_mount_root
+
+for pi_source_file in /lib/preinit/*; do
+ . $pi_source_file
+done
+
+boot_run_hook preinit_essential
+
+pi_mount_skip_next=false
+pi_jffs2_mount_success=false
+pi_failsafe_net_message=false
+
+boot_run_hook preinit_main
+
diff --git a/package/base-files/files.old/etc/watchdog b/package/base-files/files.old/etc/watchdog
new file mode 100755
index 000000000..299c89142
--- /dev/null
+++ b/package/base-files/files.old/etc/watchdog
@@ -0,0 +1,13 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008-2011 OpenWrt.org
+
+START=97
+
+start() {
+ [ -c /dev/watchdog ] || return 1
+ [ -x /sbin/watchdog ] || return 1
+ service_start /sbin/watchdog -t 5 /dev/watchdog
+}
+stop() {
+ service_stop /sbin/watchdog
+}
diff --git a/package/base-files/files.old/init b/package/base-files/files.old/init
new file mode 100755
index 000000000..b4ef4fe68
--- /dev/null
+++ b/package/base-files/files.old/init
@@ -0,0 +1,96 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+INITRAMFS=1
+
+. /etc/preinit
+
+set_state init
+echo "- init -"
+
+[ -n "$SWITCH_ROOT_TMPFS" ] && {
+ mount -o noatime none /mnt -t tmpfs
+ ( cd /; find -xdev -type d ) | ( cd /mnt; xargs mkdir -p )
+ find / \! -type d -xdev | tar -cT /proc/self/fd/0 | tar -xC /mnt
+ mkdir /mnt/proc /mnt/dev /mnt/tmp /mnt/sys
+ mount -o noatime,move /proc /mnt/proc
+ mount -o noatime,move /dev /mnt/dev
+ mount -o noatime,move /tmp /mnt/tmp
+ mount -o noatime,move /sys /mnt/sys
+ rm -rf /proc /dev /tmp /sys
+ exec switch_root -c /dev/console /mnt /sbin/init
+}
+
+# if we have no root parameter, just go to running from ramfs
+[ -z $rootfs ] && {
+ export NOMOUNT="No Root"
+ exec /sbin/init
+}
+
+#if we have a failsafe boot selected, dont bother
+#trying to find or wait for a root mount point
+[ -z "$FAILSAFE" ] || {
+ exec /bin/busybox init
+}
+
+# Load the modules we have in initramfs, this should
+# make the media accessible, but, it may take some time
+. /lib/functions.sh
+load_modules /etc/modules /etc/modules.d/*
+
+#wait 10 seconds for the disc to show up
+#usb stick typically takes 4 to 6 seconds
+#till it's readable
+#it's quite possible the disc never shows up
+#if we netbooted this kernel
+COUNTER=0
+while [ $COUNTER -lt 10 ]; do
+ sleep 1
+ [ -e $rootfs ] && let COUNTER=10;
+ let COUNTER=COUNTER+1
+done
+[ -e $rootfs ] || {
+ export FAILSAFE="NoDisc"
+ exec /bin/busybox init
+}
+
+# now we'll try mount it, again with a timeout
+# This will fail if the inserted stick is formatted
+# in a manner we dont understand
+COUNTER=0
+while [ $COUNTER -lt 10 ]; do
+ sleep 1
+ mount -o noatime $rootfs /mnt
+ [ $? -eq "0" ] && let COUNTER=100;
+ let COUNTER=COUNTER+1
+done
+[ $? -ne "0" ] && {
+ export FAILSAFE="MountFail"
+ exec /bin/busybox init
+}
+
+#It mounted, lets look for a postinit file, again, give it time
+#I've seen this take 6 seconds to actually complete
+COUNTER=0
+while [ $COUNTER -lt 10 ]; do
+ sleep 1
+ [ -e /mnt/etc/banner ] && let COUNTER=10;
+ let COUNTER=COUNTER+1
+done
+[ -e /mnt/etc/banner ] || {
+ export FAILSAFE="No Openwrt FS"
+ exec /bin/busybox init
+}
+
+unset rootfs
+
+mount -o noatime,move /proc /mnt/proc
+mount -o noatime,move /dev /mnt/dev
+mount -o noatime,move /dev/pts /mnt/dev/pts
+mount -o noatime,move /tmp /mnt/tmp
+mount -o noatime,move /sys /mnt/sys
+mount -o noatime none /tmp -t tmpfs
+killall -q hotplug2
+exec switch_root -c /dev/console /mnt /sbin/init
+
+set_state done
diff --git a/package/base-files/files.old/lib/firstboot/05_firstboot_skip b/package/base-files/files.old/lib/firstboot/05_firstboot_skip
new file mode 100644
index 000000000..5f44df621
--- /dev/null
+++ b/package/base-files/files.old/lib/firstboot/05_firstboot_skip
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+check_skip() {
+ if [ "$firstboot_skip_next" = "true" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
diff --git a/package/base-files/files.old/lib/firstboot/10_determine_parts b/package/base-files/files.old/lib/firstboot/10_determine_parts
new file mode 100644
index 000000000..3f56e32a8
--- /dev/null
+++ b/package/base-files/files.old/lib/firstboot/10_determine_parts
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+set_mtd_part() {
+ partname="rootfs_data"
+ mtdpart="$(find_mtd_part $partname)"
+}
+
+set_rom_part() {
+ rom=$(awk '/squashfs/ {print $2}' /proc/mounts)
+}
+
+set_jffs_part() {
+ jffs=$(awk '/jffs2/ {print $2}' /proc/mounts)
+}
+
+determine_mtd_part() {
+ set_mtd_part
+ if [ -z "$mtdpart" ]; then
+ echo "MTD partition not found."
+ exit 1
+ fi
+}
+
+determine_rom_part() {
+ check_skip || {
+ set_rom_part
+ if [ -z "$rom" ]; then
+ echo "You do not have a squashfs partition; aborting"
+ echo "(firstboot cannot be run on jffs2 based firmwares)"
+ exit 1
+ fi
+ }
+}
+
+determine_jffs2_part() {
+ check_skip || {
+ set_jffs_part
+ }
+}
+
+boot_hook_add switch2jffs determine_mtd_part
+boot_hook_add jffs2reset determine_mtd_part
+boot_hook_add switch2jffs determine_rom_part
+boot_hook_add jffs2reset determine_rom_part
+boot_hook_add switch2jffs determine_jffs2_part
+boot_hook_add jffs2reset determine_jffs2_part
diff --git a/package/base-files/files.old/lib/firstboot/10_no_fo_clear_overlay b/package/base-files/files.old/lib/firstboot/10_no_fo_clear_overlay
new file mode 100644
index 000000000..8a7d9b066
--- /dev/null
+++ b/package/base-files/files.old/lib/firstboot/10_no_fo_clear_overlay
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+no_fo_clear_overlay() {
+ # switch back to squashfs temporarily
+ pivot /rom /mnt
+
+ # get rid of the old overlay
+ umount -l /mnt
+
+ # another umount to get rid of the bind from /tmp/root
+ umount -l /mnt
+}
+
+boot_hook_add no_fo no_fo_clear_overlay
diff --git a/package/base-files/files.old/lib/firstboot/10_reset_has_mini_fo b/package/base-files/files.old/lib/firstboot/10_reset_has_mini_fo
new file mode 100644
index 000000000..4e285840a
--- /dev/null
+++ b/package/base-files/files.old/lib/firstboot/10_reset_has_mini_fo
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+reset_check_for_overlay() {
+ if grep -qE '(mini_fo|overlay)' /proc/filesystems; then
+ reset_has_fo=true
+ fi
+}
+
+boot_hook_add jffs2reset reset_check_for_overlay
diff --git a/package/base-files/files.old/lib/firstboot/20_has_mini_fo b/package/base-files/files.old/lib/firstboot/20_has_mini_fo
new file mode 100644
index 000000000..8ca6a4fe5
--- /dev/null
+++ b/package/base-files/files.old/lib/firstboot/20_has_mini_fo
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+check_for_overlay() {
+ if ! grep -qE '(mini_fo|overlay)' /proc/filesystems; then
+ boot_run_hook no_fo
+ exit 1
+ fi
+}
+
+boot_hook_add switch2jffs check_for_overlay
diff --git a/package/base-files/files.old/lib/firstboot/20_no_fo_mount_jffs b/package/base-files/files.old/lib/firstboot/20_no_fo_mount_jffs
new file mode 100644
index 000000000..c03714fa6
--- /dev/null
+++ b/package/base-files/files.old/lib/firstboot/20_no_fo_mount_jffs
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+no_fo_mount_jffs() {
+ # initialize jffs2
+ mount -o noatime "$mtdpart" /overlay -t jffs2 || exit
+
+ # workaround to ensure that union can attach properly
+ sync
+ ls /overlay >/dev/null
+}
+
+boot_hook_add no_fo no_fo_mount_jffs
diff --git a/package/base-files/files.old/lib/firstboot/20_reset_clear_jffs b/package/base-files/files.old/lib/firstboot/20_reset_clear_jffs
new file mode 100644
index 000000000..a3cd24fe9
--- /dev/null
+++ b/package/base-files/files.old/lib/firstboot/20_reset_clear_jffs
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+reset_clear_jffs() {
+ [ "$reset_has_fo" = "true" ] && {
+ rm -rf $jffs/* 2>&-
+ mount -o remount $jffs / 2>&-
+ exit 0
+ } || reset_has_fo=false
+}
+
+boot_hook_add jffs2reset reset_clear_jffs
diff --git a/package/base-files/files.old/lib/firstboot/30_is_rootfs_mounted b/package/base-files/files.old/lib/firstboot/30_is_rootfs_mounted
new file mode 100644
index 000000000..7233fd903
--- /dev/null
+++ b/package/base-files/files.old/lib/firstboot/30_is_rootfs_mounted
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+skip_if_rootfs_mounted() {
+ mount -o noatime -t jffs2 "$mtdpart" /rom/overlay || exit
+}
+
+boot_hook_add switch2jffs skip_if_rootfs_mounted
diff --git a/package/base-files/files.old/lib/firstboot/30_no_fo_pivot b/package/base-files/files.old/lib/firstboot/30_no_fo_pivot
new file mode 100644
index 000000000..b5c2601ee
--- /dev/null
+++ b/package/base-files/files.old/lib/firstboot/30_no_fo_pivot
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+no_fo_pivot() {
+ # switch to the new (empty) jffs2
+ fopivot /overlay /rom 1
+}
+
+boot_hook_add no_fo no_fo_pivot
diff --git a/package/base-files/files.old/lib/firstboot/30_reset_copy_rom b/package/base-files/files.old/lib/firstboot/30_reset_copy_rom
new file mode 100644
index 000000000..d91c68947
--- /dev/null
+++ b/package/base-files/files.old/lib/firstboot/30_reset_copy_rom
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+reset_copy_rom() {
+ [ "$reset_has_fo" != "true" ] && {
+ dupe $jffs $rom
+ exit 0
+ }
+}
+
+boot_hook_add jffs2reset reset_copy_rom
diff --git a/package/base-files/files.old/lib/firstboot/40_copy_ramoverlay b/package/base-files/files.old/lib/firstboot/40_copy_ramoverlay
new file mode 100644
index 000000000..39c2edacb
--- /dev/null
+++ b/package/base-files/files.old/lib/firstboot/40_copy_ramoverlay
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+copy_ramoverlay() {
+ # try to avoid fs changing while copying
+ mount -o remount,ro none / 2>&-
+ # copy ramoverlay to jffs2
+ echo -n "copying files ... "
+ cp -a /tmp/root/* /rom/overlay 2>&-
+ echo "done"
+}
+
+boot_hook_add switch2jffs copy_ramoverlay
diff --git a/package/base-files/files.old/lib/firstboot/40_no_fo_copy_ramoverlay b/package/base-files/files.old/lib/firstboot/40_no_fo_copy_ramoverlay
new file mode 100644
index 000000000..ced7c1b66
--- /dev/null
+++ b/package/base-files/files.old/lib/firstboot/40_no_fo_copy_ramoverlay
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+no_fo_copy_ramoverlay() {
+ # copy ramoverlay to jffs2, must be done after switching
+ # to the new rootfs to avoid creating opaque directories
+ echo -n "copying files ... "
+ cp -a /tmp/root/* / >/dev/null 2>&1
+ sync
+}
+
+boot_hook_add no_fo no_fo_ramoverlay
diff --git a/package/base-files/files.old/lib/firstboot/50_pivot b/package/base-files/files.old/lib/firstboot/50_pivot
new file mode 100644
index 000000000..53801d7a8
--- /dev/null
+++ b/package/base-files/files.old/lib/firstboot/50_pivot
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+with_fo_pivot() {
+ # switch back to squashfs (temporarily)
+ # and park the ramdisk ontop of /tmp/root
+ pivot /rom /mnt
+ mount -o move /mnt /tmp/root
+
+ # /overlay is the overlay
+ # /rom is the readonly
+ fopivot /overlay /rom
+}
+
+boot_hook_add switch2jffs with_fo_pivot
diff --git a/package/base-files/files.old/lib/firstboot/99_10_no_fo_cleanup b/package/base-files/files.old/lib/firstboot/99_10_no_fo_cleanup
new file mode 100644
index 000000000..6dedcb1e8
--- /dev/null
+++ b/package/base-files/files.old/lib/firstboot/99_10_no_fo_cleanup
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+no_fo_cleanup() {
+ echo "done"
+ umount -l /overlay
+ umount -l /tmp/root
+ exit 0
+}
+
+boot_hook_add no_fo no_fo_cleanup
diff --git a/package/base-files/files.old/lib/firstboot/99_10_with_fo_cleanup b/package/base-files/files.old/lib/firstboot/99_10_with_fo_cleanup
new file mode 100644
index 000000000..560169901
--- /dev/null
+++ b/package/base-files/files.old/lib/firstboot/99_10_with_fo_cleanup
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+with_fo_cleanup() {
+ # try to get rid of /tmp/root
+ # this will almost always fail
+ umount -l /tmp/root 2>&-
+ grep -q overlay /proc/filesystems && {
+ cd /
+ (
+ cd /overlay
+ find -type l
+ ) | while read FILE; do
+ [ -z "$FILE" ] && break
+ if ls -la "$FILE" 2>&- | grep -q '(overlay-whiteout)'; then
+ rm -f "$FILE"
+ fi
+ done
+ }
+ exit 0
+}
+
+boot_hook_add switch2jffs with_fo_cleanup
diff --git a/package/base-files/files.old/lib/preinit/05_mount_skip b/package/base-files/files.old/lib/preinit/05_mount_skip
new file mode 100644
index 000000000..c2b7ee79d
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/05_mount_skip
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+check_skip() {
+ if [ "$pi_mount_skip_next" = "true" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
diff --git a/package/base-files/files.old/lib/preinit/10_check_for_mtd b/package/base-files/files.old/lib/preinit/10_check_for_mtd
new file mode 100644
index 000000000..6a7bd307f
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/10_check_for_mtd
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+mount_no_mtd() {
+ mtd unlock rootfs
+ mount -o noatime,remount,rw /dev/root /
+}
+
+check_for_mtd() {
+ check_skip || {
+ grep -qs rootfs_data /proc/mtd || {
+ mount_no_mtd && pi_mount_skip_next=true
+ }
+ }
+}
+
+boot_hook_add preinit_mount_root check_for_mtd
+
diff --git a/package/base-files/files.old/lib/preinit/10_essential_fs b/package/base-files/files.old/lib/preinit/10_essential_fs
new file mode 100644
index 000000000..fc04eb7ff
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/10_essential_fs
@@ -0,0 +1,25 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+do_mount_procfs() {
+ mount -o noatime -t proc proc /proc
+}
+
+do_mount_sysfs() {
+ mount -o noatime -tsysfs sysfs /sys
+}
+
+calc_tmpfs_size() {
+ pi_size=$(awk '/MemTotal:/ {l=5242880;mt=($2*1024);print((s=mt/2)<l)&&(mt>l)?mt-l:s}' /proc/meminfo)
+}
+
+do_mount_tmpfs() {
+ calc_tmpfs_size
+ mount -o noatime -t tmpfs -o size=$pi_size,nosuid,nodev,mode=1777 tmpfs /tmp
+}
+
+boot_hook_add preinit_essential do_mount_procfs
+boot_hook_add preinit_essential do_mount_sysfs
+boot_hook_add preinit_essential do_mount_tmpfs
+
diff --git a/package/base-files/files.old/lib/preinit/10_indicate_preinit b/package/base-files/files.old/lib/preinit/10_indicate_preinit
new file mode 100644
index 000000000..4a0109cc1
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/10_indicate_preinit
@@ -0,0 +1,51 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+preinit_ip() {
+ # if the preinit interface isn't specified and ifname is set in
+ # preinit.arch use that interface
+ if [ -z "$pi_ifname" ]; then
+ pi_ifname=$ifname
+ fi
+
+ [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
+ ifconfig $pi_ifname $pi_ip netmask $pi_netmask broadcast $pi_broadcast up
+ }
+}
+
+preinit_ip_deconfig() {
+ [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
+ ifconfig $pi_ifname 0.0.0.0 down
+ }
+}
+
+preinit_net_echo() {
+ [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
+ {
+ [ "$pi_preinit_net_messages" = "y" ] || {
+ [ "$pi_failsafe_net_message" = "true" ] &&
+ [ "$pi_preinit_no_failsafe_netmsg" != "y" ]
+ }
+ } && netmsg $pi_broadcast "$1"
+ }
+}
+
+preinit_echo() {
+ preinit_net_echo $1
+ echo $1
+}
+
+pi_indicate_led() {
+ set_state preinit
+}
+
+pi_indicate_preinit() {
+ echo "- preinit -"
+ preinit_net_echo "Doing OpenWRT Preinit\n"
+ pi_indicate_led
+}
+
+boot_hook_add preinit_main preinit_ip
+boot_hook_add preinit_main pi_indicate_preinit
+
diff --git a/package/base-files/files.old/lib/preinit/20_check_jffs2_ready b/package/base-files/files.old/lib/preinit/20_check_jffs2_ready
new file mode 100644
index 000000000..3c5cf67e8
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/20_check_jffs2_ready
@@ -0,0 +1,19 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+mount_no_jffs2() {
+ echo "jffs2 not ready yet; using ramdisk"
+ ramoverlay
+}
+
+check_for_jffs2() {
+ check_skip || {
+ jffs2_ready || {
+ mount_no_jffs2 && pi_mount_skip_next=true
+ }
+ }
+}
+
+boot_hook_add preinit_mount_root check_for_jffs2
+
diff --git a/package/base-files/files.old/lib/preinit/20_device_fs_mount b/package/base-files/files.old/lib/preinit/20_device_fs_mount
new file mode 100644
index 000000000..7535b3ff9
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/20_device_fs_mount
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+do_move_devtmpfs() {
+ local mnt="$(grep devtmpfs /proc/mounts)"
+ mnt="${mnt#* }"; mnt="${mnt%% *}"
+
+ [ "$mnt" = "/dev" ] || mount -o noatime,move "$mnt" /dev
+}
+
+do_mount_devfs() {
+ mount -o noatime -t devfs devfs /dev
+}
+
+do_mount_hotplug() {
+ mount -t tmpfs -o noatime,mode=0755,size=512K tmpfs /dev
+}
+
+do_mount_udev() {
+ mount -n -t tmpfs -o noatime,mode=0755 udev /dev
+}
+
+choose_device_fs() {
+ if grep -q devtmpfs /proc/mounts; then
+ do_move_devtmpfs
+ elif grep -q devfs /proc/filesystems; then
+ do_mount_devfs
+ elif [ -x /sbin/hotplug2 ]; then
+ do_mount_hotplug
+ elif [ -x /sbin/udevd ]; then
+ do_mount_udev
+ fi
+}
+
+boot_hook_add preinit_essential choose_device_fs
+
diff --git a/package/base-files/files.old/lib/preinit/30_device_fs_daemons b/package/base-files/files.old/lib/preinit/30_device_fs_daemons
new file mode 100644
index 000000000..8379e5e74
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/30_device_fs_daemons
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Copyright (C) 2006-2013 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+init_devfs() {
+ HOTPLUG=/sbin/hotplug-call
+}
+
+init_hotplug2() {
+ [ -c /dev/console ] || mknod /dev/console c 5 1
+ /sbin/hotplug2 --set-rules-file /etc/hotplug2-init.rules --no-persistent --set-coldplug-cmd /sbin/udevtrigger
+ /sbin/hotplug2 --set-rules-file /etc/hotplug2-init.rules --persistent &
+}
+
+init_udev() {
+ [ -d /lib/udev/devices ] && cp -af /lib/udev/devices/* /dev/
+ [ -c /dev/console ] || mknod -m 0600 /dev/console c 5 1
+ [ -c /dev/null ] || mknod -m 0666 /dev/null c 1 3
+ /sbin/udevd --daemon --resolve-names=never
+ /sbin/udevadm trigger
+ /sbin/udevadm settle
+}
+
+init_device_fs() {
+ HOTPLUG=
+ if grep -q devfs /proc/filesystems; then
+ init_devfs
+ elif [ -x /sbin/hotplug2 ]; then
+ init_hotplug2
+ elif [ -x /sbin/udevd ]; then
+ init_udev
+ fi
+}
+
+boot_hook_add preinit_essential init_device_fs
+
diff --git a/package/base-files/files.old/lib/preinit/40_init_shm b/package/base-files/files.old/lib/preinit/40_init_shm
new file mode 100644
index 000000000..8971116a4
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/40_init_shm
@@ -0,0 +1,10 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+init_shm() {
+ [ -d /dev/shm ] || mkdir -p /dev/shm
+}
+
+boot_hook_add preinit_essential init_shm
+
diff --git a/package/base-files/files.old/lib/preinit/40_mount_devpts b/package/base-files/files.old/lib/preinit/40_mount_devpts
new file mode 100644
index 000000000..b55a7f2e8
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/40_mount_devpts
@@ -0,0 +1,15 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+init_devpts() {
+ [ -d /dev/pts ] || mkdir -p /dev/pts
+}
+
+do_mount_devpts() {
+ mount -o noatime -t devpts devpts /dev/pts
+}
+
+boot_hook_add preinit_essential init_devpts
+boot_hook_add preinit_essential do_mount_devpts
+
diff --git a/package/base-files/files.old/lib/preinit/40_mount_jffs2 b/package/base-files/files.old/lib/preinit/40_mount_jffs2
new file mode 100644
index 000000000..ded785ed5
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/40_mount_jffs2
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+find_mount_jffs2() {
+ mkdir -p /tmp/overlay
+ mount -o noatime -t jffs2 "$(find_mtd_part rootfs_data)" /tmp/overlay
+ mtd -qq unlock rootfs_data
+}
+
+jffs2_not_mounted() {
+ if [ "$pi_jffs2_mount_success" != "true" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+do_mount_jffs2() {
+ check_skip || {
+ find_mount_jffs2 && pi_jffs2_mount_success=true
+ }
+}
+
+boot_hook_add preinit_mount_root do_mount_jffs2
+
diff --git a/package/base-files/files.old/lib/preinit/41_merge_overlay_hooks b/package/base-files/files.old/lib/preinit/41_merge_overlay_hooks
new file mode 100644
index 000000000..4ca6877be
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/41_merge_overlay_hooks
@@ -0,0 +1,24 @@
+#!/bin/sh
+# Copyright (C) 2010 OpenWrt.org
+
+merge_overlay_hooks() {
+ jffs2_not_mounted || [ ! -d /tmp/overlay/lib/preinit ] || {
+ echo "- merge overlay components -"
+
+ mkdir -p /tmp/preinit-hook-merge
+ ln -sf /lib/preinit/* /tmp/overlay/lib/preinit/[0-9][0-9]_* /tmp/preinit-hook-merge/
+
+ boot_hook_splice_start
+
+ local pipart
+ for pipart in /tmp/preinit-hook-merge/*; do
+ . $pipart
+ done
+
+ boot_hook_splice_finish
+
+ rm -rf /tmp/preinit-hook-merge
+ }
+}
+
+boot_hook_add preinit_mount_root merge_overlay_hooks
diff --git a/package/base-files/files.old/lib/preinit/50_choose_console b/package/base-files/files.old/lib/preinit/50_choose_console
new file mode 100644
index 000000000..ecbc2eaf4
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/50_choose_console
@@ -0,0 +1,31 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+choose_console() {
+ # the shell really doesn't like having stdin/out closed
+ # that's why we use /dev/pty/m0 and m1 (or equivalent) as replacement
+ # for /dev/console if there's no serial console available
+
+ if grep -q devfs /proc/filesystems; then
+ M0=/dev/pty/m0
+ M1=/dev/pty/m1
+ M2=/dev/pty/m1
+ elif [ -x /sbin/hotplug2 ]; then
+ M0=/dev/ptmx
+ M1=/dev/ptmx
+ M2=/dev/ptmx
+ elif [ -x /sbin/udevd ]; then
+ M0=/dev/pty/ptmx
+ M1=/dev/pty/ptmx
+ M2=/dev/pty/ptmx
+ fi
+ dd if=/dev/console of=/dev/null bs=1 count=0 >/dev/null 2>/dev/null && {
+ M0=/dev/console
+ M1=/dev/console
+ M2=/dev/console
+ }
+}
+
+boot_hook_add preinit_essential choose_console
+
diff --git a/package/base-files/files.old/lib/preinit/50_indicate_regular_preinit b/package/base-files/files.old/lib/preinit/50_indicate_regular_preinit
new file mode 100644
index 000000000..9cc01f219
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/50_indicate_regular_preinit
@@ -0,0 +1,12 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+indicate_regular_preinit() {
+ echo "- regular preinit -"
+ preinit_net_echo "Continuing with Regular Preinit\n"
+ pi_indicate_led
+}
+
+boot_hook_add preinit_main indicate_regular_preinit
+
diff --git a/package/base-files/files.old/lib/preinit/60_init_hotplug b/package/base-files/files.old/lib/preinit/60_init_hotplug
new file mode 100644
index 000000000..dc05e0ed0
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/60_init_hotplug
@@ -0,0 +1,10 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+init_hotplug() {
+ echo "$HOTPLUG" > /proc/sys/kernel/hotplug
+}
+
+boot_hook_add preinit_main init_hotplug
+
diff --git a/package/base-files/files.old/lib/preinit/70_pivot_jffs2_root b/package/base-files/files.old/lib/preinit/70_pivot_jffs2_root
new file mode 100644
index 000000000..b76f111ca
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/70_pivot_jffs2_root
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+rootfs_pivot() {
+ check_skip || jffs2_not_mounted || {
+ echo "switching to jffs2"
+ mount -o noatime,move /tmp/overlay /overlay 2>&-
+ fopivot /overlay /rom && pi_mount_skip_next=true
+ }
+}
+
+boot_hook_add preinit_mount_root rootfs_pivot
+
diff --git a/package/base-files/files.old/lib/preinit/80_mount_root b/package/base-files/files.old/lib/preinit/80_mount_root
new file mode 100644
index 000000000..ad24fb8ac
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/80_mount_root
@@ -0,0 +1,10 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+do_mount_root() {
+ boot_run_hook preinit_mount_root
+}
+
+boot_hook_add preinit_main do_mount_root
+
diff --git a/package/base-files/files.old/lib/preinit/90_init_console b/package/base-files/files.old/lib/preinit/90_init_console
new file mode 100644
index 000000000..ca05755fd
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/90_init_console
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+init_console() {
+ if [ "$pi_suppress_stderr" = "y" ]; then
+ exec <$M0 >$M1 2>&0
+ else
+ exec <$M0 >$M1 2>$M2
+ fi
+}
+
+boot_hook_add preinit_essential init_console
+
diff --git a/package/base-files/files.old/lib/preinit/90_mount_no_jffs2 b/package/base-files/files.old/lib/preinit/90_mount_no_jffs2
new file mode 100644
index 000000000..d8ad4ae11
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/90_mount_no_jffs2
@@ -0,0 +1,12 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+do_mount_no_jffs2() {
+ check_skip || {
+ mount_no_jffs2 && pi_mount_skip_next=true
+ }
+}
+
+boot_hook_add preinit_mount_root do_mount_no_jffs2
+
diff --git a/package/base-files/files.old/lib/preinit/90_restore_config b/package/base-files/files.old/lib/preinit/90_restore_config
new file mode 100644
index 000000000..210bf6184
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/90_restore_config
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+restore_config() {
+ [ -f /sysupgrade.tgz ] && {
+ echo "- config restore -"
+ cd /
+ mv sysupgrade.tgz /tmp
+ tar xzf /tmp/sysupgrade.tgz
+ rm -f /tmp/sysupgrade.tgz
+ sync
+ }
+}
+
+boot_hook_add preinit_main restore_config
+
diff --git a/package/base-files/files.old/lib/preinit/99_10_mount_no_mtd b/package/base-files/files.old/lib/preinit/99_10_mount_no_mtd
new file mode 100644
index 000000000..c4f38e415
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/99_10_mount_no_mtd
@@ -0,0 +1,12 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+do_mount_no_mtd() {
+ check_skip || {
+ mount_no_mtd
+ }
+}
+
+boot_hook_add preinit_mount_root do_mount_no_mtd
+
diff --git a/package/base-files/files.old/lib/preinit/99_10_run_init b/package/base-files/files.old/lib/preinit/99_10_run_init
new file mode 100644
index 000000000..fef3a503e
--- /dev/null
+++ b/package/base-files/files.old/lib/preinit/99_10_run_init
@@ -0,0 +1,16 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+run_init() {
+ preinit_echo "- init -"
+ preinit_ip_deconfig
+ if [ "$pi_init_suppress_stderr" = "y" ]; then
+ exec env - PATH=$pi_init_path $pi_init_env $pi_init_cmd 2>&0
+ else
+ exec env - PATH=$pi_init_path $pi_init_env $pi_init_cmd
+ fi
+}
+
+boot_hook_add preinit_main run_init
+
diff --git a/package/base-files/files.old/lib/upgrade/common.sh b/package/base-files/files.old/lib/upgrade/common.sh
new file mode 100644
index 000000000..b758212f0
--- /dev/null
+++ b/package/base-files/files.old/lib/upgrade/common.sh
@@ -0,0 +1,230 @@
+#!/bin/sh
+
+RAM_ROOT=/tmp/root
+
+ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
+libs() { ldd $* | awk '{print $3}'; }
+
+install_file() { # <file> [ <file> ... ]
+ for file in "$@"; do
+ dest="$RAM_ROOT/$file"
+ [ -f $file -a ! -f $dest ] && {
+ dir="$(dirname $dest)"
+ mkdir -p "$dir"
+ cp $file $dest
+ }
+ done
+}
+
+install_bin() { # <file> [ <symlink> ... ]
+ src=$1
+ files=$1
+ [ -x "$src" ] && files="$src $(libs $src)"
+ install_file $files
+ [ -e /lib/ld.so.1 ] && {
+ install_file /lib/ld.so.1
+ }
+ shift
+ for link in "$@"; do {
+ dest="$RAM_ROOT/$link"
+ dir="$(dirname $dest)"
+ mkdir -p "$dir"
+ [ -f "$dest" ] || ln -s $src $dest
+ }; done
+}
+
+supivot() { # <new_root> <old_root>
+ mount | grep "on $1 type" 2>&- 1>&- || mount -o bind $1 $1
+ mkdir -p $1$2 $1/proc $1/sys $1/dev $1/tmp $1/overlay && \
+ mount -o noatime,move /proc $1/proc && \
+ pivot_root $1 $1$2 || {
+ umount $1 $1
+ return 1
+ }
+
+ mount -o noatime,move $2/sys /sys
+ mount -o noatime,move $2/dev /dev
+ mount -o noatime,move $2/tmp /tmp
+ mount -o noatime,move $2/overlay /overlay 2>&-
+ return 0
+}
+
+run_ramfs() { # <command> [...]
+ install_bin /bin/busybox /bin/ash /bin/sh /bin/mount /bin/umount \
+ /sbin/pivot_root /usr/bin/wget /sbin/reboot /bin/sync /bin/dd \
+ /bin/grep /bin/cp /bin/mv /bin/tar /usr/bin/md5sum "/usr/bin/[" \
+ /bin/vi /bin/ls /bin/cat /usr/bin/awk /usr/bin/hexdump \
+ /bin/sleep /bin/zcat /usr/bin/bzcat /usr/bin/printf /usr/bin/wc
+
+ install_bin /sbin/mtd
+ for file in $RAMFS_COPY_BIN; do
+ install_bin $file
+ done
+ install_file /etc/resolv.conf /lib/functions.sh /lib/functions.sh /lib/upgrade/*.sh $RAMFS_COPY_DATA
+
+ supivot $RAM_ROOT /mnt || {
+ echo "Failed to switch over to ramfs. Please reboot."
+ exit 1
+ }
+
+ mount -o remount,ro /mnt
+ umount -l /mnt
+
+ grep /overlay /proc/mounts > /dev/null && {
+ mount -o noatime,remount,ro /overlay
+ umount -l /overlay
+ }
+
+ # spawn a new shell from ramdisk to reduce the probability of cache issues
+ exec /bin/busybox ash -c "$*"
+}
+
+kill_remaining() { # [ <signal> ]
+ local sig="${1:-TERM}"
+ echo -n "Sending $sig to remaining processes ... "
+
+ local stat
+ for stat in /proc/[0-9]*/stat; do
+ [ -f "$stat" ] || continue
+
+ local pid name state ppid rest
+ read pid name state ppid rest < $stat
+ name="${name#(}"; name="${name%)}"
+
+ local cmdline
+ read cmdline < /proc/$pid/cmdline
+
+ # Skip kernel threads
+ [ -n "$cmdline" ] || continue
+
+ case "$name" in
+ # Skip essential services
+ *ash*|*init*|*watchdog*|*ssh*|*dropbear*|*telnet*|*login*|*hostapd*|*wpa_supplicant*) : ;;
+
+ # Killable process
+ *)
+ if [ $pid -ne $$ ] && [ $ppid -ne $$ ]; then
+ echo -n "$name "
+ kill -$sig $pid 2>/dev/null
+ fi
+ ;;
+ esac
+ done
+ echo ""
+}
+
+run_hooks() {
+ local arg="$1"; shift
+ for func in "$@"; do
+ eval "$func $arg"
+ done
+}
+
+ask_bool() {
+ local default="$1"; shift;
+ local answer="$default"
+
+ [ "$INTERACTIVE" -eq 1 ] && {
+ case "$default" in
+ 0) echo -n "$* (y/N): ";;
+ *) echo -n "$* (Y/n): ";;
+ esac
+ read answer
+ case "$answer" in
+ y*) answer=1;;
+ n*) answer=0;;
+ *) answer="$default";;
+ esac
+ }
+ [ "$answer" -gt 0 ]
+}
+
+v() {
+ [ "$VERBOSE" -ge 1 ] && echo "$@"
+}
+
+rootfs_type() {
+ mount | awk '($3 ~ /^\/$/) && ($5 !~ /rootfs/) { print $5 }'
+}
+
+get_image() { # <source> [ <command> ]
+ local from="$1"
+ local conc="$2"
+ local cmd
+
+ case "$from" in
+ http://*|ftp://*) cmd="wget -O- -q";;
+ *) cmd="cat";;
+ esac
+ if [ -z "$conc" ]; then
+ local magic="$(eval $cmd $from | dd bs=2 count=1 2>/dev/null | hexdump -n 2 -e '1/1 "%02x"')"
+ case "$magic" in
+ 1f8b) conc="zcat";;
+ 425a) conc="bzcat";;
+ esac
+ fi
+
+ eval "$cmd $from ${conc:+| $conc}"
+}
+
+get_magic_word() {
+ get_image "$@" | dd bs=2 count=1 2>/dev/null | hexdump -v -n 2 -e '1/1 "%02x"'
+}
+
+get_magic_long() {
+ get_image "$@" | dd bs=4 count=1 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
+}
+
+refresh_mtd_partitions() {
+ mtd refresh rootfs
+}
+
+jffs2_copy_config() {
+ if grep rootfs_data /proc/mtd >/dev/null; then
+ # squashfs+jffs2
+ mtd -e rootfs_data jffs2write "$CONF_TAR" rootfs_data
+ else
+ # jffs2
+ mtd jffs2write "$CONF_TAR" rootfs
+ fi
+}
+
+default_do_upgrade() {
+ sync
+ if [ "$SAVE_CONFIG" -eq 1 -a -z "$USE_REFRESH" ]; then
+ get_image "$1" | mtd -j "$CONF_TAR" write - "${PART_NAME:-image}"
+ else
+ get_image "$1" | mtd write - "${PART_NAME:-image}"
+ fi
+}
+
+do_upgrade() {
+ v "Performing system upgrade..."
+ if type 'platform_do_upgrade' >/dev/null 2>/dev/null; then
+ platform_do_upgrade "$ARGV"
+ else
+ default_do_upgrade "$ARGV"
+ fi
+
+ [ "$SAVE_CONFIG" -eq 1 -a -n "$USE_REFRESH" ] && {
+ v "Refreshing partitions"
+ if type 'platform_refresh_partitions' >/dev/null 2>/dev/null; then
+ platform_refresh_partitions
+ else
+ refresh_mtd_partitions
+ fi
+ if type 'platform_copy_config' >/dev/null 2>/dev/null; then
+ platform_copy_config
+ else
+ jffs2_copy_config
+ fi
+ }
+ v "Upgrade completed"
+ [ -n "$DELAY" ] && sleep "$DELAY"
+ ask_bool 1 "Reboot" && {
+ v "Rebooting system..."
+ reboot -f
+ sleep 5
+ echo b 2>/dev/null >/proc/sysrq-trigger
+ }
+}
diff --git a/package/base-files/files.old/sbin/firstboot b/package/base-files/files.old/sbin/firstboot
new file mode 100755
index 000000000..06b64c313
--- /dev/null
+++ b/package/base-files/files.old/sbin/firstboot
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+switch2jffs_hook=
+jffs2reset_hook=
+no_fo_hook=
+
+. /lib/functions.sh
+
+firstboot_skip_next=false
+
+for fb_source_file in /lib/firstboot/*; do
+ . $fb_source_file
+done
+
+set_mtd_part
+set_rom_part
+set_jffs_part
+
+# invoked as an executable
+if [ "${0##*/}" = "firstboot" ]; then
+ if [ "$1" = "switch2jffs" ]; then
+ boot_run_hook switch2jffs
+ else
+ if [ -t 0 ] && [ "$1" != "-y" ]; then
+ local input
+
+ echo -n "firstboot will erase all settings and remove any installed packages. Are you sure? [N/y]"
+ read input
+ [ "$input" = "y" ] || [ "$input" = "Y" ] || return 0
+ fi
+
+ if [ -n "$jffs" ]; then
+ reset_has_fo=true
+ echo "firstboot has already been run"
+ echo "jffs2 partition is mounted, only resetting files"
+ boot_run_hook jffs2reset
+ else
+ mtd erase "$partname"
+ mount -o noatime "$mtdpart" /overlay -t jffs2
+ fopivot /overlay /rom 1
+ fi
+ fi
+fi
+
diff --git a/package/base-files/files.old/sbin/mount_root b/package/base-files/files.old/sbin/mount_root
new file mode 100755
index 000000000..1c48ebab1
--- /dev/null
+++ b/package/base-files/files.old/sbin/mount_root
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Copyright (C) 2006-2010 OpenWrt.org
+# Copyright (C) 2010 Vertical Communications
+
+# Initialize hook variables et by pulling in from preinit
+
+preinit_essential_hook=
+preinit_main_hook=
+failsafe_hook=
+initramfs_hook=
+preinit_mount_root=
+
+. /lib/functions.sh
+
+for pi_source_file in /lib/preinit/*; do
+ . $pi_source_file
+done
+
+# Override function that doesn't apply to use of mount_root as a command rather
+# than as part of preinit
+
+preinit_echo() {
+ echo "$@"
+}
+
+boot_run_hook preinit_mount_root