aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files
diff options
context:
space:
mode:
Diffstat (limited to 'package/base-files')
-rw-r--r--package/base-files/Makefile14
-rw-r--r--package/base-files/files.old/etc/hotplug2-common.rules (renamed from package/base-files/files/etc/hotplug2-common.rules)0
-rw-r--r--package/base-files/files.old/etc/hotplug2-init.rules (renamed from package/base-files/files/etc/hotplug2-init.rules)0
-rwxr-xr-xpackage/base-files/files.old/etc/init.d/boot110
-rwxr-xr-xpackage/base-files/files.old/etc/init.d/rcS26
-rwxr-xr-xpackage/base-files/files.old/etc/init.d/watchdog (renamed from package/base-files/files/etc/init.d/watchdog)0
-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/99_10_with_fo_cleanup25
-rw-r--r--package/base-files/files.old/lib/preinit/10_essential_fs (renamed from package/base-files/files/lib/preinit/10_essential_fs)0
-rw-r--r--package/base-files/files.old/lib/preinit/10_indicate_preinit51
-rw-r--r--package/base-files/files.old/lib/preinit/20_device_fs_mount (renamed from package/base-files/files/lib/preinit/20_device_fs_mount)0
-rw-r--r--package/base-files/files.old/lib/preinit/30_device_fs_daemons (renamed from package/base-files/files/lib/preinit/30_device_fs_daemons)0
-rw-r--r--package/base-files/files.old/lib/preinit/40_init_shm (renamed from package/base-files/files/lib/preinit/40_init_shm)0
-rw-r--r--package/base-files/files.old/lib/preinit/40_mount_devpts (renamed from package/base-files/files/lib/preinit/40_mount_devpts)0
-rw-r--r--package/base-files/files.old/lib/preinit/50_choose_console (renamed from package/base-files/files/lib/preinit/50_choose_console)0
-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_hotplug (renamed from package/base-files/files/lib/preinit/60_init_hotplug)0
-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_console (renamed from package/base-files/files/lib/preinit/90_init_console)0
-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/etc/init.d/boot32
-rwxr-xr-xpackage/base-files/files/etc/init.d/rcS25
-rw-r--r--package/base-files/files/etc/inittab3
-rwxr-xr-xpackage/base-files/files/etc/preinit2
-rwxr-xr-xpackage/base-files/files/etc/rc.button/failsafe2
-rwxr-xr-xpackage/base-files/files/etc/rc.button/reset18
-rwxr-xr-xpackage/base-files/files/etc/rc.button/rfkill23
-rw-r--r--package/base-files/files/lib/firstboot/99_10_with_fo_cleanup2
-rw-r--r--package/base-files/files/lib/preinit/10_indicate_preinit1
-rw-r--r--package/base-files/files/lib/preinit/30_failsafe_wait5
-rw-r--r--package/base-files/files/lib/preinit/50_indicate_regular_preinit1
-rw-r--r--package/base-files/files/lib/preinit/80_mount_root3
-rw-r--r--package/base-files/files/lib/preinit/99_10_run_init6
-rw-r--r--package/base-files/files/lib/upgrade/common.sh2
38 files changed, 705 insertions, 70 deletions
diff --git a/package/base-files/Makefile b/package/base-files/Makefile
index b763658549..90c280645d 100644
--- a/package/base-files/Makefile
+++ b/package/base-files/Makefile
@@ -15,6 +15,7 @@ PKG_RELEASE:=134
PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
PKG_BUILD_DEPENDS:=opkg/host
+PKG_CONFIG_DEPENDS:=CONFIG_PROCD_INIT
include $(INCLUDE_DIR)/package.mk
@@ -55,6 +56,18 @@ define Package/base-files/description
This package contains a base filesystem and system scripts for OpenWrt.
endef
+define Package/base-files/config
+config PROCD_INIT
+ bool "Use procd as the init process"
+ default n
+endef
+
+ifeq ($(CONFIG_PROCD_INIT),)
+define InstallOldFiles
+ $(CP) ./files.old/* $(1)/
+endef
+endif
+
ifneq ($(CONFIG_PREINITOPT),)
define ImageConfigOptions
mkdir -p $(1)/lib/preinit
@@ -87,6 +100,7 @@ define Package/base-files/install
if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \
$(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \
fi
+ $(call InstallOldFiles,$(1))
if [ -d $(PLATFORM_DIR)/base-files/. ]; then \
$(CP) $(PLATFORM_DIR)/base-files/* $(1)/; \
fi
diff --git a/package/base-files/files/etc/hotplug2-common.rules b/package/base-files/files.old/etc/hotplug2-common.rules
index c284f8f3fe..c284f8f3fe 100644
--- a/package/base-files/files/etc/hotplug2-common.rules
+++ b/package/base-files/files.old/etc/hotplug2-common.rules
diff --git a/package/base-files/files/etc/hotplug2-init.rules b/package/base-files/files.old/etc/hotplug2-init.rules
index f011697766..f011697766 100644
--- a/package/base-files/files/etc/hotplug2-init.rules
+++ b/package/base-files/files.old/etc/hotplug2-init.rules
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 0000000000..005c4ad6f8
--- /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/rcS b/package/base-files/files.old/etc/init.d/rcS
new file mode 100755
index 0000000000..3ec9bfef6e
--- /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/etc/init.d/watchdog b/package/base-files/files.old/etc/init.d/watchdog
index 299c891428..299c891428 100755
--- a/package/base-files/files/etc/init.d/watchdog
+++ b/package/base-files/files.old/etc/init.d/watchdog
diff --git a/package/base-files/files.old/etc/inittab b/package/base-files/files.old/etc/inittab
new file mode 100644
index 0000000000..ca90fd8a2a
--- /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 0000000000..b237c2e06e
--- /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 0000000000..299c891428
--- /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 0000000000..b4ef4fe687
--- /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/99_10_with_fo_cleanup b/package/base-files/files.old/lib/firstboot/99_10_with_fo_cleanup
new file mode 100644
index 0000000000..0181b39d49
--- /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 /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/lib/preinit/10_essential_fs b/package/base-files/files.old/lib/preinit/10_essential_fs
index fc04eb7ff3..fc04eb7ff3 100644
--- a/package/base-files/files/lib/preinit/10_essential_fs
+++ b/package/base-files/files.old/lib/preinit/10_essential_fs
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 0000000000..4a0109cc17
--- /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/lib/preinit/20_device_fs_mount b/package/base-files/files.old/lib/preinit/20_device_fs_mount
index 7535b3ff9d..7535b3ff9d 100644
--- a/package/base-files/files/lib/preinit/20_device_fs_mount
+++ b/package/base-files/files.old/lib/preinit/20_device_fs_mount
diff --git a/package/base-files/files/lib/preinit/30_device_fs_daemons b/package/base-files/files.old/lib/preinit/30_device_fs_daemons
index 8379e5e74f..8379e5e74f 100644
--- a/package/base-files/files/lib/preinit/30_device_fs_daemons
+++ b/package/base-files/files.old/lib/preinit/30_device_fs_daemons
diff --git a/package/base-files/files/lib/preinit/40_init_shm b/package/base-files/files.old/lib/preinit/40_init_shm
index 8971116a49..8971116a49 100644
--- a/package/base-files/files/lib/preinit/40_init_shm
+++ b/package/base-files/files.old/lib/preinit/40_init_shm
diff --git a/package/base-files/files/lib/preinit/40_mount_devpts b/package/base-files/files.old/lib/preinit/40_mount_devpts
index b55a7f2e8e..b55a7f2e8e 100644
--- a/package/base-files/files/lib/preinit/40_mount_devpts
+++ b/package/base-files/files.old/lib/preinit/40_mount_devpts
diff --git a/package/base-files/files/lib/preinit/50_choose_console b/package/base-files/files.old/lib/preinit/50_choose_console
index ecbc2eaf42..ecbc2eaf42 100644
--- a/package/base-files/files/lib/preinit/50_choose_console
+++ b/package/base-files/files.old/lib/preinit/50_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 0000000000..9cc01f2199
--- /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/lib/preinit/60_init_hotplug b/package/base-files/files.old/lib/preinit/60_init_hotplug
index dc05e0ed05..dc05e0ed05 100644
--- a/package/base-files/files/lib/preinit/60_init_hotplug
+++ b/package/base-files/files.old/lib/preinit/60_init_hotplug
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 0000000000..ad24fb8ace
--- /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/lib/preinit/90_init_console b/package/base-files/files.old/lib/preinit/90_init_console
index ca05755fd3..ca05755fd3 100644
--- a/package/base-files/files/lib/preinit/90_init_console
+++ b/package/base-files/files.old/lib/preinit/90_init_console
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 0000000000..fef3a503e2
--- /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 0000000000..2e123ab3cf
--- /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-linux.so.3 ] && {
+ install_file /lib/ld-linux.so.3
+ }
+ 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/etc/init.d/boot b/package/base-files/files/etc/init.d/boot
index 005c4ad6f8..67db0d2a6a 100755
--- a/package/base-files/files/etc/init.d/boot
+++ b/package/base-files/files/etc/init.d/boot
@@ -24,27 +24,6 @@ system_config() {
# 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() {
@@ -84,12 +63,6 @@ start() {
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)
@@ -103,8 +76,3 @@ start() {
done
fi
}
-
-stop() {
- service_stop /sbin/klogd
- service_stop /sbin/syslogd
-}
diff --git a/package/base-files/files/etc/init.d/rcS b/package/base-files/files/etc/init.d/rcS
index 3ec9bfef6e..9599bbf32e 100755
--- a/package/base-files/files/etc/init.d/rcS
+++ b/package/base-files/files/etc/init.d/rcS
@@ -1,26 +1,9 @@
#!/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
+[ -x /usr/bin/logger ] && LOGGER="logger -p 6 -t sysinit"
-if [ "$1" = "S" -a "$foreground" != "1" ]; then
- run_scripts "$1" "$2" &
-else
- run_scripts "$1" "$2"
-fi
+for i in /etc/rc.d/$1*; do
+ [ -x $i ] && $i $2 2>&1
+done | $LOGGER
diff --git a/package/base-files/files/etc/inittab b/package/base-files/files/etc/inittab
index ca90fd8a2a..7817185937 100644
--- a/package/base-files/files/etc/inittab
+++ b/package/base-files/files/etc/inittab
@@ -1,4 +1,3 @@
::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K shutdown
-ttyS0::askfirst:/bin/ash --login
-tty1::askfirst:/bin/ash --login
+::askconsole:/bin/ash --login
diff --git a/package/base-files/files/etc/preinit b/package/base-files/files/etc/preinit
index b237c2e06e..ff26f96d68 100755
--- a/package/base-files/files/etc/preinit
+++ b/package/base-files/files/etc/preinit
@@ -2,6 +2,8 @@
# Copyright (C) 2006 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
+[ -z "$PREINIT" ] && exec /sbin/init
+
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
pi_ifname=
diff --git a/package/base-files/files/etc/rc.button/failsafe b/package/base-files/files/etc/rc.button/failsafe
new file mode 100755
index 0000000000..dcdf7de80e
--- /dev/null
+++ b/package/base-files/files/etc/rc.button/failsafe
@@ -0,0 +1,2 @@
+#!/bin/sh
+touch /tmp/failsafe_button
diff --git a/package/base-files/files/etc/rc.button/reset b/package/base-files/files/etc/rc.button/reset
new file mode 100755
index 0000000000..763994d075
--- /dev/null
+++ b/package/base-files/files/etc/rc.button/reset
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+[ "${ACTION}" = "released" ] || exit 0
+
+. /lib/functions.sh
+
+logger "$BUTTON pressed for $SEEN seconds"
+
+if [ "$SEEN" -lt 1 ]
+then
+ echo "REBOOT" > /dev/console
+ sync
+ reboot
+elif [ "$SEEN" -gt 5 ]
+then
+ echo "FACTORY RESET" > /dev/console
+ firstboot && reboot &
+fi
diff --git a/package/base-files/files/etc/rc.button/rfkill b/package/base-files/files/etc/rc.button/rfkill
new file mode 100755
index 0000000000..7a8cfe91b9
--- /dev/null
+++ b/package/base-files/files/etc/rc.button/rfkill
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+[ "${ACTION}" = "released" ] || exit 0
+
+. /lib/functions.sh
+
+local rfkill_state=0
+
+wifi_rfkill_set() {
+ uci set wireless.$1.disabled=$rfkill_state
+}
+
+wifi_rfkill_check() {
+ local disabled
+ config_get disabled $1 disabled
+ [ "$disabled" = "1" ] || rfkill_state=1
+}
+
+config_load wireless
+config_foreach wifi_rfkill_check wifi-device
+config_foreach wifi_rfkill_set wifi-device
+uci commit wireless
+wifi up
diff --git a/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup b/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup
index 0181b39d49..560169901c 100644
--- a/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup
+++ b/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup
@@ -6,7 +6,7 @@
with_fo_cleanup() {
# try to get rid of /tmp/root
# this will almost always fail
- umount /tmp/root 2>&-
+ umount -l /tmp/root 2>&-
grep -q overlay /proc/filesystems && {
cd /
(
diff --git a/package/base-files/files/lib/preinit/10_indicate_preinit b/package/base-files/files/lib/preinit/10_indicate_preinit
index 4a0109cc17..da70b97c40 100644
--- a/package/base-files/files/lib/preinit/10_indicate_preinit
+++ b/package/base-files/files/lib/preinit/10_indicate_preinit
@@ -41,7 +41,6 @@ pi_indicate_led() {
}
pi_indicate_preinit() {
- echo "- preinit -"
preinit_net_echo "Doing OpenWRT Preinit\n"
pi_indicate_led
}
diff --git a/package/base-files/files/lib/preinit/30_failsafe_wait b/package/base-files/files/lib/preinit/30_failsafe_wait
index 04dc57df20..808d9731b7 100644
--- a/package/base-files/files/lib/preinit/30_failsafe_wait
+++ b/package/base-files/files/lib/preinit/30_failsafe_wait
@@ -61,11 +61,10 @@ fs_wait_for_key () {
}
lock -w $keypress_wait
- trap - INT
- trap - USR1
-
keypressed=1
[ "$(cat $keypress_true)" = "true" ] && keypressed=0
+ [ -f "/tmp/failsafe_button" ] && keypressed=1
+
rm -f $keypress_true
rm -f $keypress_wait
rm -f $keypress_sec
diff --git a/package/base-files/files/lib/preinit/50_indicate_regular_preinit b/package/base-files/files/lib/preinit/50_indicate_regular_preinit
index 9cc01f2199..c200dad671 100644
--- a/package/base-files/files/lib/preinit/50_indicate_regular_preinit
+++ b/package/base-files/files/lib/preinit/50_indicate_regular_preinit
@@ -3,7 +3,6 @@
# Copyright (C) 2010 Vertical Communications
indicate_regular_preinit() {
- echo "- regular preinit -"
preinit_net_echo "Continuing with Regular Preinit\n"
pi_indicate_led
}
diff --git a/package/base-files/files/lib/preinit/80_mount_root b/package/base-files/files/lib/preinit/80_mount_root
index ad24fb8ace..9a99ee9109 100644
--- a/package/base-files/files/lib/preinit/80_mount_root
+++ b/package/base-files/files/lib/preinit/80_mount_root
@@ -6,5 +6,4 @@ do_mount_root() {
boot_run_hook preinit_mount_root
}
-boot_hook_add preinit_main do_mount_root
-
+[ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main do_mount_root
diff --git a/package/base-files/files/lib/preinit/99_10_run_init b/package/base-files/files/lib/preinit/99_10_run_init
index fef3a503e2..a8f330f892 100644
--- a/package/base-files/files/lib/preinit/99_10_run_init
+++ b/package/base-files/files/lib/preinit/99_10_run_init
@@ -3,13 +3,7 @@
# 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/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh
index 2e123ab3cf..969aecb7ff 100644
--- a/package/base-files/files/lib/upgrade/common.sh
+++ b/package/base-files/files/lib/upgrade/common.sh
@@ -38,7 +38,7 @@ supivot() { # <new_root> <old_root>
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
+ umount -l $1 $1
return 1
}