summaryrefslogtreecommitdiffstats
path: root/package/base-files
diff options
context:
space:
mode:
Diffstat (limited to 'package/base-files')
-rw-r--r--package/base-files/Makefile20
-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/done20
-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/05_firstboot_skip (renamed from package/base-files/files/lib/firstboot/05_firstboot_skip)0
-rw-r--r--package/base-files/files.old/lib/firstboot/10_determine_parts (renamed from package/base-files/files/lib/firstboot/10_determine_parts)0
-rw-r--r--package/base-files/files.old/lib/firstboot/10_no_fo_clear_overlay (renamed from package/base-files/files/lib/firstboot/10_no_fo_clear_overlay)0
-rw-r--r--package/base-files/files.old/lib/firstboot/10_reset_has_mini_fo (renamed from package/base-files/files/lib/firstboot/10_reset_has_mini_fo)0
-rw-r--r--package/base-files/files.old/lib/firstboot/20_has_mini_fo (renamed from package/base-files/files/lib/firstboot/20_has_mini_fo)0
-rw-r--r--package/base-files/files.old/lib/firstboot/20_no_fo_mount_jffs (renamed from package/base-files/files/lib/firstboot/20_no_fo_mount_jffs)4
-rw-r--r--package/base-files/files.old/lib/firstboot/20_reset_clear_jffs (renamed from package/base-files/files/lib/firstboot/20_reset_clear_jffs)0
-rw-r--r--package/base-files/files.old/lib/firstboot/30_is_rootfs_mounted (renamed from package/base-files/files/lib/firstboot/30_is_rootfs_mounted)2
-rw-r--r--package/base-files/files.old/lib/firstboot/30_no_fo_pivot (renamed from package/base-files/files/lib/firstboot/30_no_fo_pivot)0
-rw-r--r--package/base-files/files.old/lib/firstboot/30_reset_copy_rom (renamed from package/base-files/files/lib/firstboot/30_reset_copy_rom)0
-rw-r--r--package/base-files/files.old/lib/firstboot/40_copy_ramoverlay (renamed from package/base-files/files/lib/firstboot/40_copy_ramoverlay)0
-rw-r--r--package/base-files/files.old/lib/firstboot/40_no_fo_copy_ramoverlay (renamed from package/base-files/files/lib/firstboot/40_no_fo_copy_ramoverlay)0
-rw-r--r--package/base-files/files.old/lib/firstboot/50_pivot (renamed from package/base-files/files/lib/firstboot/50_pivot)0
-rw-r--r--package/base-files/files.old/lib/firstboot/99_10_no_fo_cleanup (renamed from package/base-files/files/lib/firstboot/99_10_no_fo_cleanup)0
-rw-r--r--package/base-files/files.old/lib/firstboot/99_10_with_fo_cleanup (renamed from package/base-files/files/lib/firstboot/99_10_with_fo_cleanup)2
-rw-r--r--package/base-files/files.old/lib/preinit/05_mount_skip (renamed from package/base-files/files/lib/preinit/05_mount_skip)0
-rw-r--r--package/base-files/files.old/lib/preinit/10_check_for_mtd (renamed from package/base-files/files/lib/preinit/10_check_for_mtd)2
-rw-r--r--package/base-files/files.old/lib/preinit/10_essential_fs (renamed from package/base-files/files/lib/preinit/10_essential_fs)6
-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_ready (renamed from package/base-files/files/lib/preinit/20_check_jffs2_ready)0
-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)8
-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)6
-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)2
-rw-r--r--package/base-files/files.old/lib/preinit/40_mount_jffs2 (renamed from package/base-files/files/lib/preinit/40_mount_jffs2)2
-rw-r--r--package/base-files/files.old/lib/preinit/41_merge_overlay_hooks (renamed from package/base-files/files/lib/preinit/41_merge_overlay_hooks)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/70_pivot_jffs2_root (renamed from package/base-files/files/lib/preinit/70_pivot_jffs2_root)2
-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/90_mount_no_jffs2 (renamed from package/base-files/files/lib/preinit/90_mount_no_jffs2)0
-rw-r--r--package/base-files/files.old/lib/preinit/90_restore_config (renamed from package/base-files/files/lib/preinit/90_restore_config)0
-rw-r--r--package/base-files/files.old/lib/preinit/99_10_mount_no_mtd (renamed from package/base-files/files/lib/preinit/99_10_mount_no_mtd)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.old/sbin/firstboot44
-rwxr-xr-xpackage/base-files/files.old/sbin/mount_root (renamed from package/base-files/files/sbin/mount_root)2
-rwxr-xr-xpackage/base-files/files/bin/ipcalc.sh15
-rw-r--r--package/base-files/files/etc/banner13
-rw-r--r--package/base-files/files/etc/config/network8
l---------package/base-files/files/etc/functions.sh1
-rw-r--r--package/base-files/files/etc/hotplug.d/net/00-sysctl6
-rwxr-xr-xpackage/base-files/files/etc/init.d/boot45
-rwxr-xr-xpackage/base-files/files/etc/init.d/done2
-rwxr-xr-xpackage/base-files/files/etc/init.d/led12
-rwxr-xr-xpackage/base-files/files/etc/init.d/rcS25
-rwxr-xr-xpackage/base-files/files/etc/init.d/sysctl2
-rwxr-xr-xpackage/base-files/files/etc/init.d/umount2
-rwxr-xr-xpackage/base-files/files/etc/init.d/usb2
-rw-r--r--package/base-files/files/etc/inittab3
-rwxr-xr-xpackage/base-files/files/etc/preinit3
-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
-rwxr-xr-xpackage/base-files/files/etc/rc.common31
-rw-r--r--package/base-files/files/etc/sysctl.conf8
-rw-r--r--package/base-files/files/etc/uci-defaults/10_migrate-shadow (renamed from package/base-files/files/etc/uci-defaults/migrate-shadow)0
-rw-r--r--package/base-files/files/etc/uci-defaults/11_migrate-sysctl17
-rw-r--r--package/base-files/files/etc/uci-defaults/12_network-generate-ula18
-rwxr-xr-xpackage/base-files/files/lib/functions.sh219
-rw-r--r--package/base-files/files/lib/functions/boot.sh150
-rw-r--r--package/base-files/files/lib/functions/leds.sh68
-rw-r--r--package/base-files/files/lib/functions/network.sh336
-rw-r--r--package/base-files/files/lib/functions/uci-defaults.sh6
-rw-r--r--package/base-files/files/lib/preinit/10_indicate_preinit2
-rw-r--r--package/base-files/files/lib/preinit/30_failsafe_wait16
-rw-r--r--package/base-files/files/lib/preinit/50_indicate_regular_preinit1
-rw-r--r--package/base-files/files/lib/preinit/80_mount_root16
-rw-r--r--package/base-files/files/lib/preinit/99_10_run_init6
-rw-r--r--package/base-files/files/lib/upgrade/common.sh28
-rwxr-xr-xpackage/base-files/files/sbin/firstboot33
-rwxr-xr-xpackage/base-files/files/sbin/sysupgrade38
85 files changed, 1488 insertions, 420 deletions
diff --git a/package/base-files/Makefile b/package/base-files/Makefile
index 50ad7d4a0..050cc77b5 100644
--- a/package/base-files/Makefile
+++ b/package/base-files/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2007-2012 OpenWrt.org
+# Copyright (C) 2007-2013 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
#
# This is free software, licensed under the GNU General Public License v2.
@@ -11,10 +11,11 @@ include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/version.mk
PKG_NAME:=base-files
-PKG_RELEASE:=115
+PKG_RELEASE:=138
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
@@ -28,7 +29,7 @@ endif
define Package/base-files
SECTION:=base
CATEGORY:=Base system
- DEPENDS:=+netifd +libc
+ DEPENDS:=+netifd +libc +procd
TITLE:=Base filesystem for OpenWrt
URL:=http://openwrt.org/
VERSION:=$(PKG_RELEASE)-$(REVISION)
@@ -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 c284f8f3f..c284f8f3f 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 f01169776..f01169776 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 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/etc/init.d/watchdog b/package/base-files/files.old/etc/init.d/watchdog
index 299c89142..299c89142 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 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/lib/firstboot/05_firstboot_skip b/package/base-files/files.old/lib/firstboot/05_firstboot_skip
index 5f44df621..5f44df621 100644
--- a/package/base-files/files/lib/firstboot/05_firstboot_skip
+++ b/package/base-files/files.old/lib/firstboot/05_firstboot_skip
diff --git a/package/base-files/files/lib/firstboot/10_determine_parts b/package/base-files/files.old/lib/firstboot/10_determine_parts
index 3f56e32a8..3f56e32a8 100644
--- a/package/base-files/files/lib/firstboot/10_determine_parts
+++ b/package/base-files/files.old/lib/firstboot/10_determine_parts
diff --git a/package/base-files/files/lib/firstboot/10_no_fo_clear_overlay b/package/base-files/files.old/lib/firstboot/10_no_fo_clear_overlay
index 8a7d9b066..8a7d9b066 100644
--- a/package/base-files/files/lib/firstboot/10_no_fo_clear_overlay
+++ b/package/base-files/files.old/lib/firstboot/10_no_fo_clear_overlay
diff --git a/package/base-files/files/lib/firstboot/10_reset_has_mini_fo b/package/base-files/files.old/lib/firstboot/10_reset_has_mini_fo
index 4e285840a..4e285840a 100644
--- a/package/base-files/files/lib/firstboot/10_reset_has_mini_fo
+++ b/package/base-files/files.old/lib/firstboot/10_reset_has_mini_fo
diff --git a/package/base-files/files/lib/firstboot/20_has_mini_fo b/package/base-files/files.old/lib/firstboot/20_has_mini_fo
index 8ca6a4fe5..8ca6a4fe5 100644
--- a/package/base-files/files/lib/firstboot/20_has_mini_fo
+++ b/package/base-files/files.old/lib/firstboot/20_has_mini_fo
diff --git a/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs b/package/base-files/files.old/lib/firstboot/20_no_fo_mount_jffs
index 8a1d4e06d..c03714fa6 100644
--- a/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs
+++ b/package/base-files/files.old/lib/firstboot/20_no_fo_mount_jffs
@@ -5,8 +5,8 @@
no_fo_mount_jffs() {
# initialize jffs2
- mount "$mtdpart" /overlay -t jffs2 || exit
-
+ mount -o noatime "$mtdpart" /overlay -t jffs2 || exit
+
# workaround to ensure that union can attach properly
sync
ls /overlay >/dev/null
diff --git a/package/base-files/files/lib/firstboot/20_reset_clear_jffs b/package/base-files/files.old/lib/firstboot/20_reset_clear_jffs
index a3cd24fe9..a3cd24fe9 100644
--- a/package/base-files/files/lib/firstboot/20_reset_clear_jffs
+++ b/package/base-files/files.old/lib/firstboot/20_reset_clear_jffs
diff --git a/package/base-files/files/lib/firstboot/30_is_rootfs_mounted b/package/base-files/files.old/lib/firstboot/30_is_rootfs_mounted
index e2ba01d50..7233fd903 100644
--- a/package/base-files/files/lib/firstboot/30_is_rootfs_mounted
+++ b/package/base-files/files.old/lib/firstboot/30_is_rootfs_mounted
@@ -4,7 +4,7 @@
# Copyright (C) 2010 Vertical Communications
skip_if_rootfs_mounted() {
- mount "$mtdpart" /rom/overlay -t jffs2 || exit
+ mount -o noatime -t jffs2 "$mtdpart" /rom/overlay || exit
}
boot_hook_add switch2jffs skip_if_rootfs_mounted
diff --git a/package/base-files/files/lib/firstboot/30_no_fo_pivot b/package/base-files/files.old/lib/firstboot/30_no_fo_pivot
index b5c2601ee..b5c2601ee 100644
--- a/package/base-files/files/lib/firstboot/30_no_fo_pivot
+++ b/package/base-files/files.old/lib/firstboot/30_no_fo_pivot
diff --git a/package/base-files/files/lib/firstboot/30_reset_copy_rom b/package/base-files/files.old/lib/firstboot/30_reset_copy_rom
index d91c68947..d91c68947 100644
--- a/package/base-files/files/lib/firstboot/30_reset_copy_rom
+++ b/package/base-files/files.old/lib/firstboot/30_reset_copy_rom
diff --git a/package/base-files/files/lib/firstboot/40_copy_ramoverlay b/package/base-files/files.old/lib/firstboot/40_copy_ramoverlay
index 39c2edacb..39c2edacb 100644
--- a/package/base-files/files/lib/firstboot/40_copy_ramoverlay
+++ b/package/base-files/files.old/lib/firstboot/40_copy_ramoverlay
diff --git a/package/base-files/files/lib/firstboot/40_no_fo_copy_ramoverlay b/package/base-files/files.old/lib/firstboot/40_no_fo_copy_ramoverlay
index ced7c1b66..ced7c1b66 100644
--- a/package/base-files/files/lib/firstboot/40_no_fo_copy_ramoverlay
+++ b/package/base-files/files.old/lib/firstboot/40_no_fo_copy_ramoverlay
diff --git a/package/base-files/files/lib/firstboot/50_pivot b/package/base-files/files.old/lib/firstboot/50_pivot
index 53801d7a8..53801d7a8 100644
--- a/package/base-files/files/lib/firstboot/50_pivot
+++ b/package/base-files/files.old/lib/firstboot/50_pivot
diff --git a/package/base-files/files/lib/firstboot/99_10_no_fo_cleanup b/package/base-files/files.old/lib/firstboot/99_10_no_fo_cleanup
index 6dedcb1e8..6dedcb1e8 100644
--- a/package/base-files/files/lib/firstboot/99_10_no_fo_cleanup
+++ b/package/base-files/files.old/lib/firstboot/99_10_no_fo_cleanup
diff --git a/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup b/package/base-files/files.old/lib/firstboot/99_10_with_fo_cleanup
index 0181b39d4..560169901 100644
--- a/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup
+++ b/package/base-files/files.old/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/05_mount_skip b/package/base-files/files.old/lib/preinit/05_mount_skip
index c2b7ee79d..c2b7ee79d 100644
--- a/package/base-files/files/lib/preinit/05_mount_skip
+++ b/package/base-files/files.old/lib/preinit/05_mount_skip
diff --git a/package/base-files/files/lib/preinit/10_check_for_mtd b/package/base-files/files.old/lib/preinit/10_check_for_mtd
index 66f185e1a..6a7bd307f 100644
--- a/package/base-files/files/lib/preinit/10_check_for_mtd
+++ b/package/base-files/files.old/lib/preinit/10_check_for_mtd
@@ -5,7 +5,7 @@
mount_no_mtd() {
mtd unlock rootfs
- mount -o remount,rw /dev/root /
+ mount -o noatime,remount,rw /dev/root /
}
check_for_mtd() {
diff --git a/package/base-files/files/lib/preinit/10_essential_fs b/package/base-files/files.old/lib/preinit/10_essential_fs
index ab317dc20..fc04eb7ff 100644
--- a/package/base-files/files/lib/preinit/10_essential_fs
+++ b/package/base-files/files.old/lib/preinit/10_essential_fs
@@ -3,11 +3,11 @@
# Copyright (C) 2010 Vertical Communications
do_mount_procfs() {
- mount proc /proc -t proc
+ mount -o noatime -t proc proc /proc
}
do_mount_sysfs() {
- mount sysfs /sys -t sysfs
+ mount -o noatime -tsysfs sysfs /sys
}
calc_tmpfs_size() {
@@ -16,7 +16,7 @@ calc_tmpfs_size() {
do_mount_tmpfs() {
calc_tmpfs_size
- mount tmpfs /tmp -t tmpfs -o size=$pi_size,nosuid,nodev,mode=1777
+ mount -o noatime -t tmpfs -o size=$pi_size,nosuid,nodev,mode=1777 tmpfs /tmp
}
boot_hook_add preinit_essential do_mount_procfs
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/lib/preinit/20_check_jffs2_ready b/package/base-files/files.old/lib/preinit/20_check_jffs2_ready
index 3c5cf67e8..3c5cf67e8 100644
--- a/package/base-files/files/lib/preinit/20_check_jffs2_ready
+++ b/package/base-files/files.old/lib/preinit/20_check_jffs2_ready
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 832b1cf39..7535b3ff9 100644
--- a/package/base-files/files/lib/preinit/20_device_fs_mount
+++ b/package/base-files/files.old/lib/preinit/20_device_fs_mount
@@ -6,19 +6,19 @@ do_move_devtmpfs() {
local mnt="$(grep devtmpfs /proc/mounts)"
mnt="${mnt#* }"; mnt="${mnt%% *}"
- [ "$mnt" = "/dev" ] || mount -o move "$mnt" /dev
+ [ "$mnt" = "/dev" ] || mount -o noatime,move "$mnt" /dev
}
do_mount_devfs() {
- mount devfs /dev -t devfs
+ mount -o noatime -t devfs devfs /dev
}
do_mount_hotplug() {
- mount -t tmpfs tmpfs /dev -o mode=0755,size=512K
+ mount -t tmpfs -o noatime,mode=0755,size=512K tmpfs /dev
}
do_mount_udev() {
- mount -n -t tmpfs -o mode=0755 udev /dev
+ mount -n -t tmpfs -o noatime,mode=0755 udev /dev
}
choose_device_fs() {
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 5b3e2ad00..8379e5e74 100644
--- a/package/base-files/files/lib/preinit/30_device_fs_daemons
+++ b/package/base-files/files.old/lib/preinit/30_device_fs_daemons
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2006-2013 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
init_devfs() {
@@ -8,8 +8,8 @@ init_devfs() {
init_hotplug2() {
[ -c /dev/console ] || mknod /dev/console c 5 1
- /sbin/hotplug2 --set-worker /lib/hotplug2/worker_fork.so --set-rules-file /etc/hotplug2-init.rules --no-persistent --set-coldplug-cmd /sbin/udevtrigger
- /sbin/hotplug2 --set-worker /lib/hotplug2/worker_fork.so --set-rules-file /etc/hotplug2-init.rules --persistent &
+ /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() {
diff --git a/package/base-files/files/lib/preinit/40_init_shm b/package/base-files/files.old/lib/preinit/40_init_shm
index 8971116a4..8971116a4 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 2d5010b91..b55a7f2e8 100644
--- a/package/base-files/files/lib/preinit/40_mount_devpts
+++ b/package/base-files/files.old/lib/preinit/40_mount_devpts
@@ -7,7 +7,7 @@ init_devpts() {
}
do_mount_devpts() {
- mount devpts /dev/pts -t devpts
+ mount -o noatime -t devpts devpts /dev/pts
}
boot_hook_add preinit_essential init_devpts
diff --git a/package/base-files/files/lib/preinit/40_mount_jffs2 b/package/base-files/files.old/lib/preinit/40_mount_jffs2
index 00f45a890..ded785ed5 100644
--- a/package/base-files/files/lib/preinit/40_mount_jffs2
+++ b/package/base-files/files.old/lib/preinit/40_mount_jffs2
@@ -4,7 +4,7 @@
find_mount_jffs2() {
mkdir -p /tmp/overlay
- mount "$(find_mtd_part rootfs_data)" /tmp/overlay -t jffs2
+ mount -o noatime -t jffs2 "$(find_mtd_part rootfs_data)" /tmp/overlay
mtd -qq unlock rootfs_data
}
diff --git a/package/base-files/files/lib/preinit/41_merge_overlay_hooks b/package/base-files/files.old/lib/preinit/41_merge_overlay_hooks
index 4ca6877be..4ca6877be 100644
--- a/package/base-files/files/lib/preinit/41_merge_overlay_hooks
+++ b/package/base-files/files.old/lib/preinit/41_merge_overlay_hooks
diff --git a/package/base-files/files/lib/preinit/50_choose_console b/package/base-files/files.old/lib/preinit/50_choose_console
index ecbc2eaf4..ecbc2eaf4 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 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/lib/preinit/60_init_hotplug b/package/base-files/files.old/lib/preinit/60_init_hotplug
index dc05e0ed0..dc05e0ed0 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/lib/preinit/70_pivot_jffs2_root b/package/base-files/files.old/lib/preinit/70_pivot_jffs2_root
index 821bfb14f..b76f111ca 100644
--- a/package/base-files/files/lib/preinit/70_pivot_jffs2_root
+++ b/package/base-files/files.old/lib/preinit/70_pivot_jffs2_root
@@ -5,7 +5,7 @@
rootfs_pivot() {
check_skip || jffs2_not_mounted || {
echo "switching to jffs2"
- mount -o move /tmp/overlay /overlay 2>&-
+ mount -o noatime,move /tmp/overlay /overlay 2>&-
fopivot /overlay /rom && pi_mount_skip_next=true
}
}
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/lib/preinit/90_init_console b/package/base-files/files.old/lib/preinit/90_init_console
index ca05755fd..ca05755fd 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/lib/preinit/90_mount_no_jffs2 b/package/base-files/files.old/lib/preinit/90_mount_no_jffs2
index d8ad4ae11..d8ad4ae11 100644
--- a/package/base-files/files/lib/preinit/90_mount_no_jffs2
+++ b/package/base-files/files.old/lib/preinit/90_mount_no_jffs2
diff --git a/package/base-files/files/lib/preinit/90_restore_config b/package/base-files/files.old/lib/preinit/90_restore_config
index 210bf6184..210bf6184 100644
--- a/package/base-files/files/lib/preinit/90_restore_config
+++ b/package/base-files/files.old/lib/preinit/90_restore_config
diff --git a/package/base-files/files/lib/preinit/99_10_mount_no_mtd b/package/base-files/files.old/lib/preinit/99_10_mount_no_mtd
index c4f38e415..c4f38e415 100644
--- a/package/base-files/files/lib/preinit/99_10_mount_no_mtd
+++ b/package/base-files/files.old/lib/preinit/99_10_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/sbin/mount_root b/package/base-files/files.old/sbin/mount_root
index 2d73dac53..1c48ebab1 100755
--- a/package/base-files/files/sbin/mount_root
+++ b/package/base-files/files.old/sbin/mount_root
@@ -10,7 +10,7 @@ failsafe_hook=
initramfs_hook=
preinit_mount_root=
-. /lib/functions/boot.sh
+. /lib/functions.sh
for pi_source_file in /lib/preinit/*; do
. $pi_source_file
diff --git a/package/base-files/files/bin/ipcalc.sh b/package/base-files/files/bin/ipcalc.sh
index d6ef16870..7463d6bdd 100755
--- a/package/base-files/files/bin/ipcalc.sh
+++ b/package/base-files/files/bin/ipcalc.sh
@@ -22,6 +22,11 @@ function int2ip(ip,ret,x) {
return ret
}
+function compl32(v) {
+ ret=xor(v, 0xffffffff)
+ return ret
+}
+
BEGIN {
slpos=index(ARGV[1],"/")
if (slpos == 0) {
@@ -29,27 +34,27 @@ BEGIN {
netmask=ip2int(ARGV[2])
} else {
ipaddr=ip2int(substr(ARGV[1],0,slpos-1))
- netmask=compl(2**(32-int(substr(ARGV[1],slpos+1)))-1)
+ netmask=compl32(2**(32-int(substr(ARGV[1],slpos+1)))-1)
ARGV[4]=ARGV[3]
ARGV[3]=ARGV[2]
}
network=and(ipaddr,netmask)
- broadcast=or(network,compl(netmask))
+ broadcast=or(network,compl32(netmask))
- start=or(network,and(ip2int(ARGV[3]),compl(netmask)))
+ start=or(network,and(ip2int(ARGV[3]),compl32(netmask)))
limit=network+1
if (start<limit) start=limit
end=start+ARGV[4]
- limit=or(network,compl(netmask))-1
+ limit=or(network,compl32(netmask))-1
if (end>limit) end=limit
print "IP="int2ip(ipaddr)
print "NETMASK="int2ip(netmask)
print "BROADCAST="int2ip(broadcast)
print "NETWORK="int2ip(network)
- print "PREFIX="32-bitcount(compl(netmask))
+ print "PREFIX="32-bitcount(compl32(netmask))
# range calculations:
# ipcalc <ip> <netmask> <start> <num>
diff --git a/package/base-files/files/etc/banner b/package/base-files/files/etc/banner
index 058cb5573..3eed7dfc0 100644
--- a/package/base-files/files/etc/banner
+++ b/package/base-files/files/etc/banner
@@ -4,13 +4,10 @@
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
-----------------------------------------------------
- ATTITUDE ADJUSTMENT (%C, %R)
+ BARRIER BREAKER (%C, %R)
-----------------------------------------------------
- * 1/4 oz Vodka Pour all ingredients into mixing
- * 1/4 oz Gin tin with ice, strain into glass.
- * 1/4 oz Amaretto
- * 1/4 oz Triple sec
- * 1/4 oz Peach schnapps
- * 1/4 oz Sour mix
- * 1 splash Cranberry juice
+ * 1/2 oz Galliano Pour all ingredients into
+ * 4 oz cold Coffee an irish coffee mug filled
+ * 1 1/2 oz Dark Rum with crushed ice. Stir.
+ * 2 tsp. Creme de Cacao
-----------------------------------------------------
diff --git a/package/base-files/files/etc/config/network b/package/base-files/files/etc/config/network
index a35fd2ef9..87b124aa3 100644
--- a/package/base-files/files/etc/config/network
+++ b/package/base-files/files/etc/config/network
@@ -12,3 +12,11 @@ config interface lan
option proto static
option ipaddr 192.168.1.1
option netmask 255.255.255.0
+ option ip6assign 60
+
+config interface wan6
+ option ifname @wan
+ option proto dhcpv6
+
+config globals globals
+ option ula_prefix auto
diff --git a/package/base-files/files/etc/functions.sh b/package/base-files/files/etc/functions.sh
deleted file mode 120000
index 13b3190e7..000000000
--- a/package/base-files/files/etc/functions.sh
+++ /dev/null
@@ -1 +0,0 @@
-../lib/functions.sh \ No newline at end of file
diff --git a/package/base-files/files/etc/hotplug.d/net/00-sysctl b/package/base-files/files/etc/hotplug.d/net/00-sysctl
new file mode 100644
index 000000000..5d9da8ac0
--- /dev/null
+++ b/package/base-files/files/etc/hotplug.d/net/00-sysctl
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+if [ -f /etc/sysctl.conf ] && [ "$ACTION" = add ]; then
+ sed -ne "/^[[:space:]]*net\..*\.$DEVICENAME\./p" /etc/sysctl.conf | \
+ sysctl -e -p - | logger -t sysctl
+fi
diff --git a/package/base-files/files/etc/init.d/boot b/package/base-files/files/etc/init.d/boot
index 43837a80f..4f35eac7b 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() {
@@ -66,10 +45,14 @@ start() {
touch /var/log/lastlog
touch /tmp/resolv.conf.auto
ln -sf /tmp/resolv.conf.auto /tmp/resolv.conf
- grep -q debugfs /proc/filesystems && mount -t debugfs debugfs /sys/kernel/debug
+ grep -q debugfs /proc/filesystems && mount -o noatime -t debugfs debugfs /sys/kernel/debug
[ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
- load_modules /etc/modules.d/*
+ if [ -f /sbin/kmodloader ]; then
+ /sbin/kmodloader
+ else
+ load_modules /etc/modules.d/*
+ fi
# allow wifi modules time to settle
sleep 1
@@ -84,20 +67,16 @@ 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)
[ -n "$rootdev" ] && ln -s "$rootdev" /dev/root
}
-}
-stop() {
- service_stop /sbin/klogd
- service_stop /sbin/syslogd
+ # 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
}
diff --git a/package/base-files/files/etc/init.d/done b/package/base-files/files/etc/init.d/done
index 827866912..8040766dc 100755
--- a/package/base-files/files/etc/init.d/done
+++ b/package/base-files/files/etc/init.d/done
@@ -5,7 +5,7 @@ START=95
boot() {
[ -d /tmp/root ] && {
lock /tmp/.switch2jffs
- firstboot switch2jffs
+ switch2jffs
lock -u /tmp/.switch2jffs
}
diff --git a/package/base-files/files/etc/init.d/led b/package/base-files/files/etc/init.d/led
index 43964bf0b..729796bcc 100755
--- a/package/base-files/files/etc/init.d/led
+++ b/package/base-files/files/etc/init.d/led
@@ -24,6 +24,13 @@ load_led() {
config_get delayoff $1 delayoff
config_get interval $1 interval "50"
config_get port_state $1 port_state
+ config_get delay $1 delay "150"
+ config_get message $1 message ""
+
+ if [ "$trigger" = "rssi" ]; then
+ # handled by rssileds userspace process
+ return
+ fi
[ -e /sys/class/leds/${sysfs}/brightness ] && {
echo "setting up led ${name}"
@@ -61,6 +68,11 @@ load_led() {
echo $port_state > /sys/class/leds/${sysfs}/port_state
;;
+ "morse")
+ echo $message > /sys/class/leds/${sysfs}/message
+ echo $delay > /sys/class/leds/${sysfs}/delay
+ ;;
+
switch[0-9]*)
local port_mask
diff --git a/package/base-files/files/etc/init.d/rcS b/package/base-files/files/etc/init.d/rcS
index 3ec9bfef6..9599bbf32 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/init.d/sysctl b/package/base-files/files/etc/init.d/sysctl
index 239779055..3480d6641 100755
--- a/package/base-files/files/etc/init.d/sysctl
+++ b/package/base-files/files/etc/init.d/sysctl
@@ -1,7 +1,7 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
-START=99
+START=11
start() {
[ -f /etc/sysctl.conf ] && sysctl -p -e >&-
}
diff --git a/package/base-files/files/etc/init.d/umount b/package/base-files/files/etc/init.d/umount
index a4e477e2e..5a750b93c 100755
--- a/package/base-files/files/etc/init.d/umount
+++ b/package/base-files/files/etc/init.d/umount
@@ -4,5 +4,5 @@
STOP=99
stop() {
sync
- umount -a -r
+ umount -a -d -r
}
diff --git a/package/base-files/files/etc/init.d/usb b/package/base-files/files/etc/init.d/usb
index 7b443b651..43cdfd9a9 100755
--- a/package/base-files/files/etc/init.d/usb
+++ b/package/base-files/files/etc/init.d/usb
@@ -4,6 +4,6 @@
START=39
start() {
[ -d /proc/bus/usb ] && {
- /bin/mount -t usbfs none /proc/bus/usb
+ mount -o noatime -t usbfs none /proc/bus/usb
}
}
diff --git a/package/base-files/files/etc/inittab b/package/base-files/files/etc/inittab
index ca90fd8a2..781718593 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 0fdfa8cf8..ff26f96d6 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=
@@ -22,7 +24,6 @@ pi_init_path="/bin:/sbin:/usr/bin:/usr/sbin"
pi_init_cmd="/sbin/init"
. /lib/functions.sh
-. /lib/functions/boot.sh
boot_hook_init preinit_essential
boot_hook_init preinit_main
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 000000000..dcdf7de80
--- /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 000000000..229b503a6
--- /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
+ jffs2reset -y && 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 000000000..7a8cfe91b
--- /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/etc/rc.common b/package/base-files/files/etc/rc.common
index fa2df6cd2..78e2dd494 100755
--- a/package/base-files/files/etc/rc.common
+++ b/package/base-files/files/etc/rc.common
@@ -75,10 +75,41 @@ $EXTRA_HELP
EOF
}
+# for procd
+start_service() {
+ return 0
+}
+
+stop_service() {
+ return 0
+}
+
${INIT_TRACE:+set -x}
. "$initscript"
+[ -n "$USE_PROCD" ] && {
+ . $IPKG_INSTROOT/lib/functions/procd.sh
+
+ rc_procd() {
+ procd_open_service "$(basename "$initscript")" "$initscript"
+ "$@"
+ procd_close_service
+ }
+
+ start() {
+ rc_procd start_service "$@"
+ }
+
+ stop() {
+ procd_kill "$(basename "$initscript")" "$1"
+ }
+
+ reload() {
+ start
+ }
+}
+
ALL_COMMANDS="start stop reload restart boot shutdown enable disable enabled depends ${EXTRA_COMMANDS}"
list_contains ALL_COMMANDS "$action" || action=help
[ "$action" = "reload" ] && action='eval reload "$@" || restart "$@" && :'
diff --git a/package/base-files/files/etc/sysctl.conf b/package/base-files/files/etc/sysctl.conf
index b39bc5747..890e77af8 100644
--- a/package/base-files/files/etc/sysctl.conf
+++ b/package/base-files/files/etc/sysctl.conf
@@ -12,12 +12,8 @@ net.ipv4.tcp_timestamps=1
net.ipv4.tcp_sack=1
net.ipv4.tcp_dsack=1
-net.ipv4.netfilter.ip_conntrack_checksum=0
-net.ipv4.netfilter.ip_conntrack_max=16384
-net.ipv4.netfilter.ip_conntrack_tcp_timeout_established=3600
-net.ipv4.netfilter.ip_conntrack_udp_timeout=60
-net.ipv4.netfilter.ip_conntrack_udp_timeout_stream=180
-net.ipv6.conf.all.forwarding=1
+net.ipv6.conf.default.forwarding=2
+net.ipv6.conf.all.forwarding=2
net.netfilter.nf_conntrack_acct=1
net.netfilter.nf_conntrack_checksum=0
diff --git a/package/base-files/files/etc/uci-defaults/migrate-shadow b/package/base-files/files/etc/uci-defaults/10_migrate-shadow
index b7ea5718c..b7ea5718c 100644
--- a/package/base-files/files/etc/uci-defaults/migrate-shadow
+++ b/package/base-files/files/etc/uci-defaults/10_migrate-shadow
diff --git a/package/base-files/files/etc/uci-defaults/11_migrate-sysctl b/package/base-files/files/etc/uci-defaults/11_migrate-sysctl
new file mode 100644
index 000000000..b3796a4d2
--- /dev/null
+++ b/package/base-files/files/etc/uci-defaults/11_migrate-sysctl
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+if [ ! -f "/rom/etc/sysctl.conf" ] || cmp -s "/rom/etc/sysctl.conf" "/etc/sysctl.conf"; then
+ exit 0
+fi
+
+fingerprint="$(md5sum /etc/sysctl.conf)"
+fingerprint="${fingerprint%% *}"
+
+if [ "$fingerprint" = "1b05ebb41f72cb84e5510573cd4aca26" ] || \
+ [ "$fingerprint" = "62deb895be1a7f496040187b7c930e4e" ]; then
+ logger -t migrate-sysctl "Updating sysctl.conf to use current defaults"
+ cp "/rom/etc/sysctl.conf" "/etc/sysctl.conf"
+fi
+
+exit 0
+
diff --git a/package/base-files/files/etc/uci-defaults/12_network-generate-ula b/package/base-files/files/etc/uci-defaults/12_network-generate-ula
new file mode 100644
index 000000000..f3e493145
--- /dev/null
+++ b/package/base-files/files/etc/uci-defaults/12_network-generate-ula
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+[ "$(uci get network.globals.ula_prefix)" != "auto" ] && exit 0
+# Sometimes results are empty, therefore try until it works...
+local r1 r2 r3
+while [ -z "$r1" -o -z "$r2" -o -z "$r3" ]; do
+ r1=$(printf "%02x" $(($(</dev/urandom tr -dc 0-9 | dd bs=9 count=1) % 256)))
+ r2=$(printf "%01x" $(($(</dev/urandom tr -dc 0-9 | dd bs=9 count=1) % 65536)))
+ r3=$(printf "%01x" $(($(</dev/urandom tr -dc 0-9 | dd bs=9 count=1) % 65536)))
+done
+
+uci -q batch <<-EOF >/dev/null
+ set network.globals.ula_prefix=fd$r1:$r2:$r3::/48
+ commit network
+EOF
+
+exit 0
+
diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index b3a3885f2..f51bfea45 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -1,14 +1,12 @@
#!/bin/sh
-# Copyright (C) 2006-2011 OpenWrt.org
+# Copyright (C) 2006-2013 OpenWrt.org
# Copyright (C) 2006 Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de>
+# Copyright (C) 2010 Vertical Communications
debug () {
${DEBUG:-:} "$@"
}
-mount() {
- busybox mount "$@"
-}
# newline
N="
@@ -200,7 +198,7 @@ config_list_foreach() {
[ -z "$len" ] && return 0
while [ $c -le "$len" ]; do
config_get val "${section}" "${option}_ITEM$c"
- eval "$function \"\$val\" \"$@\""
+ eval "$function \"\$val\" \"\$@\""
c="$(($c + 1))"
done
}
@@ -220,13 +218,85 @@ include() {
done
}
-find_mtd_part() {
+find_mtd_index() {
local PART="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')"
+ local INDEX="${PART##mtd}"
+
+ echo ${INDEX}
+}
+
+find_mtd_part() {
+ local INDEX=$(find_mtd_index "$1")
local PREFIX=/dev/mtdblock
- PART="${PART##mtd}"
[ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/
- echo "${PART:+$PREFIX$PART}"
+ echo "${INDEX:+$PREFIX$INDEX}"
+}
+
+find_mtd_chardev() {
+ local INDEX=$(find_mtd_index "$1")
+ local PREFIX=/dev/mtd
+
+ [ -d /dev/mtd ] && PREFIX=/dev/mtd/
+ echo "${INDEX:+$PREFIX$INDEX}"
+}
+
+mtd_get_mac_ascii()
+{
+ local mtdname="$1"
+ local key="$2"
+ local part
+ local mac_dirty
+
+ . /lib/functions.sh
+
+ part=$(find_mtd_part "$mtdname")
+ if [ -z "$part" ]; then
+ echo "mtd_get_mac_ascii: partition $mtdname not found!" >&2
+ return
+ fi
+
+ mac_dirty=$(strings "$part" | sed -n 's/'"$key"'=//p')
+ # "canonicalize" mac
+ printf "%02x:%02x:%02x:%02x:%02x:%02x" 0x${mac_dirty//:/ 0x}
+}
+
+mtd_get_mac_binary() {
+ local mtdname="$1"
+ local offset="$2"
+ local part
+
+ part=$(find_mtd_part "$mtdname")
+ if [ -z "$part" ]; then
+ echo "mtd_get_mac_binary: partition $mtdname not found!" >&2
+ return
+ fi
+
+ dd bs=1 skip=$offset count=6 if=$part 2>/dev/null | hexdump -v -n 6 -e '5/1 "%02x:" 1/1 "%02x"'
+}
+
+macaddr_add() {
+ local mac=$1
+ local val=$2
+ local oui=${mac%:*:*:*}
+ local nic=${mac#*:*:*:}
+
+ nic=$(printf "%06x" $((0x${nic//:/} + $val & 0xffffff)) | sed 's/^\(.\{2\}\)\(.\{2\}\)\(.\{2\}\)/\1:\2:\3/')
+ echo $oui:$nic
+}
+
+macaddr_setbit_la()
+{
+ local mac=$1
+
+ printf "%02x:%s" $((0x${mac%%:*} | 0x02)) ${mac#*:}
+}
+
+macaddr_2bin()
+{
+ local mac=$1
+
+ echo -ne \\x${mac//:/\\x}
}
strtok() { # <string> { <variable> [<separator>] ... }
@@ -337,4 +407,137 @@ pi_include() {
return 0
}
+boot_hook_splice_start() {
+ export -n PI_HOOK_SPLICE=1
+}
+
+boot_hook_splice_finish() {
+ local hook
+ for hook in $PI_STACK_LIST; do
+ local v; eval "v=\${${hook}_splice:+\$${hook}_splice }$hook"
+ export -n "${hook}=${v% }"
+ export -n "${hook}_splice="
+ done
+ export -n PI_HOOK_SPLICE=
+}
+
+boot_hook_init() {
+ local hook="${1}_hook"
+ export -n "PI_STACK_LIST=${PI_STACK_LIST:+$PI_STACK_LIST }$hook"
+ export -n "$hook="
+}
+
+boot_hook_add() {
+ local hook="${1}_hook${PI_HOOK_SPLICE:+_splice}"
+ local func="${2}"
+
+ [ -n "$func" ] && {
+ local v; eval "v=\$$hook"
+ export -n "$hook=${v:+$v }$func"
+ }
+}
+
+boot_hook_shift() {
+ local hook="${1}_hook"
+ local rvar="${2}"
+
+ local v; eval "v=\$$hook"
+ [ -n "$v" ] && {
+ local first="${v%% *}"
+
+ [ "$v" != "${v#* }" ] && \
+ export -n "$hook=${v#* }" || \
+ export -n "$hook="
+
+ export -n "$rvar=$first"
+ return 0
+ }
+
+ return 1
+}
+
+boot_run_hook() {
+ local hook="$1"
+ local func
+
+ while boot_hook_shift "$hook" func; do
+ local ran; eval "ran=\$PI_RAN_$func"
+ [ -n "$ran" ] || {
+ export -n "PI_RAN_$func=1"
+ $func "$1" "$2"
+ }
+ done
+}
+
+jffs2_ready() {
+ mtdpart="$(find_mtd_part rootfs_data)"
+ [ -z "$mtdpart" ] && return 1
+ magic=$(hexdump $mtdpart -n 4 -e '4/1 "%02x"')
+ [ "$magic" != "deadc0de" ]
+}
+
+dupe() { # <new_root> <old_root>
+ cd $1
+ echo -n "creating directories... "
+ {
+ cd $2
+ find . -xdev -type d
+ echo "./dev ./overlay ./mnt ./proc ./tmp"
+ # xdev skips mounted directories
+ cd $1
+ } | xargs mkdir -p
+ echo "done"
+
+ echo -n "setting up symlinks... "
+ for file in $(cd $2; find . -xdev -type f;); do
+ case "$file" in
+ ./rom/note) ;; #nothing
+ ./etc/config*|\
+ ./usr/lib/opkg/info/*) cp -af $2/$file $file;;
+ *) ln -sf /rom/${file#./*} $file;;
+ esac
+ done
+ for file in $(cd $2; find . -xdev -type l;); do
+ cp -af $2/${file#./*} $file
+ done
+ echo "done"
+}
+
+pivot() { # <new_root> <old_root>
+ mount -o noatime,move /proc $1/proc && \
+ pivot_root $1 $1$2 && {
+ mount -o noatime,move $2/dev /dev
+ mount -o noatime,move $2/tmp /tmp
+ mount -o noatime,move $2/sys /sys 2>&-
+ mount -o noatime,move $2/overlay /overlay 2>&-
+ return 0
+ }
+}
+
+fopivot() { # <rw_root> <ro_root> <dupe?>
+ root=$1
+ {
+ if grep -q overlay /proc/filesystems; then
+ mount -o noatime,lowerdir=/,upperdir=$1 -t overlayfs "overlayfs:$1" /mnt && root=/mnt
+ elif grep -q mini_fo /proc/filesystems; then
+ mount -t mini_fo -o noatime,base=/,sto=$1 "mini_fo:$1" /mnt 2>&- && root=/mnt
+ else
+ mount --bind -o noatime / /mnt
+ mount --bind -o noatime,union "$1" /mnt && root=/mnt
+ fi
+ } || {
+ [ "$3" = "1" ] && {
+ mount | grep "on $1 type" 2>&- 1>&- || mount -o noatime,bind $1 $1
+ dupe $1 $rom
+ }
+ }
+ pivot $root $2
+}
+
+ramoverlay() {
+ mkdir -p /tmp/root
+ mount -t tmpfs -o noatime,mode=0755 root /tmp/root
+ fopivot /tmp/root /rom 1
+}
+
[ -z "$IPKG_INSTROOT" -a -f /lib/config/uci.sh ] && . /lib/config/uci.sh
diff --git a/package/base-files/files/lib/functions/boot.sh b/package/base-files/files/lib/functions/boot.sh
deleted file mode 100644
index 8c3f27ba4..000000000
--- a/package/base-files/files/lib/functions/boot.sh
+++ /dev/null
@@ -1,150 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2006-2010 OpenWrt.org
-# Copyright (C) 2010 Vertical Communications
-
-mount() {
- /bin/busybox mount -o noatime "$@"
-}
-
-boot_hook_splice_start() {
- export -n PI_HOOK_SPLICE=1
-}
-
-boot_hook_splice_finish() {
- local hook
- for hook in $PI_STACK_LIST; do
- local v; eval "v=\${${hook}_splice:+\$${hook}_splice }$hook"
- export -n "${hook}=${v% }"
- export -n "${hook}_splice="
- done
- export -n PI_HOOK_SPLICE=
-}
-
-boot_hook_init() {
- local hook="${1}_hook"
- export -n "PI_STACK_LIST=${PI_STACK_LIST:+$PI_STACK_LIST }$hook"
- export -n "$hook="
-}
-
-boot_hook_add() {
- local hook="${1}_hook${PI_HOOK_SPLICE:+_splice}"
- local func="${2}"
-
- [ -n "$func" ] && {
- local v; eval "v=\$$hook"
- export -n "$hook=${v:+$v }$func"
- }
-}
-
-boot_hook_shift() {
- local hook="${1}_hook"
- local rvar="${2}"
-
- local v; eval "v=\$$hook"
- [ -n "$v" ] && {
- local first="${v%% *}"
-
- [ "$v" != "${v#* }" ] && \
- export -n "$hook=${v#* }" || \
- export -n "$hook="
-
- export -n "$rvar=$first"
- return 0
- }
-
- return 1
-}
-
-boot_run_hook() {
- local hook="$1"
- local func
-
- while boot_hook_shift "$hook" func; do
- local ran; eval "ran=\$PI_RAN_$func"
- [ -n "$ran" ] || {
- export -n "PI_RAN_$func=1"
- $func "$1" "$2"
- }
- done
-}
-
-find_mtd_part() {
- local PART="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')"
- local PREFIX=/dev/mtdblock
-
- PART="${PART##mtd}"
- [ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/
- echo "${PART:+$PREFIX$PART}"
-}
-
-jffs2_ready () {
- mtdpart="$(find_mtd_part rootfs_data)"
- [ -z "$mtdpart" ] && return 1
- magic=$(hexdump $mtdpart -n 4 -e '4/1 "%02x"')
- [ "$magic" != "deadc0de" ]
-}
-
-dupe() { # <new_root> <old_root>
- cd $1
- echo -n "creating directories... "
- {
- cd $2
- find . -xdev -type d
- echo "./dev ./overlay ./mnt ./proc ./tmp"
- # xdev skips mounted directories
- cd $1
- } | xargs mkdir -p
- echo "done"
-
- echo -n "setting up symlinks... "
- for file in $(cd $2; find . -xdev -type f;); do
- case "$file" in
- ./rom/note) ;; #nothing
- ./etc/config*|\
- ./usr/lib/opkg/info/*) cp -af $2/$file $file;;
- *) ln -sf /rom/${file#./*} $file;;
- esac
- done
- for file in $(cd $2; find . -xdev -type l;); do
- cp -af $2/${file#./*} $file
- done
- echo "done"
-}
-
-pivot() { # <new_root> <old_root>
- mount -o move /proc $1/proc && \
- pivot_root $1 $1$2 && {
- mount -o move $2/dev /dev
- mount -o move $2/tmp /tmp
- mount -o move $2/sys /sys 2>&-
- mount -o move $2/overlay /overlay 2>&-
- return 0
- }
-}
-
-fopivot() { # <rw_root> <ro_root> <dupe?>
- root=$1
- {
- if grep -q overlay /proc/filesystems; then
- mount -t overlayfs -olowerdir=/,upperdir=$1 "overlayfs:$1" /mnt && root=/mnt
- elif grep -q mini_fo /proc/filesystems; then
- mount -t mini_fo -o base=/,sto=$1 "mini_fo:$1" /mnt 2>&- && root=/mnt
- else
- mount --bind / /mnt
- mount --bind -o union "$1" /mnt && root=/mnt
- fi
- } || {
- [ "$3" = "1" ] && {
- mount | grep "on $1 type" 2>&- 1>&- || mount -o bind $1 $1
- dupe $1 $rom
- }
- }
- pivot $root $2
-}
-
-ramoverlay() {
- mkdir -p /tmp/root
- mount -t tmpfs -o mode=0755 root /tmp/root
- fopivot /tmp/root /rom 1
-}
-
diff --git a/package/base-files/files/lib/functions/leds.sh b/package/base-files/files/lib/functions/leds.sh
new file mode 100644
index 000000000..743c7da78
--- /dev/null
+++ b/package/base-files/files/lib/functions/leds.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+# Copyright (C) 2013 OpenWrt.org
+
+led_set_attr() {
+ [ -f "/sys/class/leds/$1/$2" ] && echo "$3" > "/sys/class/leds/$1/$2"
+}
+
+led_timer() {
+ led_set_attr $1 "trigger" "timer"
+ led_set_attr $1 "delay_on" "$2"
+ led_set_attr $1 "delay_off" "$3"
+}
+
+led_on() {
+ led_set_attr $1 "trigger" "none"
+ led_set_attr $1 "brightness" 255
+}
+
+led_off() {
+ led_set_attr $1 "trigger" "none"
+ led_set_attr $1 "brightness" 0
+}
+
+led_morse() {
+ led_set_attr $1 "trigger" "morse"
+ led_set_attr $1 "delay" "$2"
+ led_set_attr $1 "message" "$3"
+}
+
+status_led_set_timer() {
+ led_timer $status_led "$1" "$2"
+ [ -n "$status_led2" ] && led_timer $status_led2 "$1" "$2"
+}
+
+status_led_set_heartbeat() {
+ led_set_attr $status_led "trigger" "heartbeat"
+}
+
+status_led_set_morse() {
+ led_morse $status_led "$1" "$2"
+ [ -n "$status_led2" ] && led_morse $status_led2 "$1" "$2"
+}
+
+status_led_on() {
+ led_on $status_led
+ [ -n "$status_led2" ] && led_on $status_led2
+}
+
+status_led_off() {
+ led_off $status_led
+ [ -n "$status_led2" ] && led_off $status_led2
+}
+
+status_led_blink_slow() {
+ led_timer $status_led 1000 1000
+}
+
+status_led_blink_fast() {
+ led_timer $status_led 100 100
+}
+
+status_led_blink_preinit() {
+ led_timer $status_led 200 200
+}
+
+status_led_blink_failsafe() {
+ led_timer $status_led 50 50
+}
diff --git a/package/base-files/files/lib/functions/network.sh b/package/base-files/files/lib/functions/network.sh
index d2d4aae0d..d86a504bf 100644
--- a/package/base-files/files/lib/functions/network.sh
+++ b/package/base-files/files/lib/functions/network.sh
@@ -1,127 +1,281 @@
. /usr/share/libubox/jshn.sh
-__network_ipaddr()
+__network_set_cache()
{
- local __var="$1"
- local __iface="$2"
- local __family="$3"
- local __prefix="${4:-0}"
+ if [ -n "$3" ]; then
+ eval "export -- __NETWORK_CV_$1='$3'"
+ __NETWORK_CACHE="${__NETWORK_CACHE:+$__NETWORK_CACHE }__NETWORK_CV_$1"
+ elif json_get_var "__NETWORK_CV_$1" "$2"; then
+ __NETWORK_CACHE="${__NETWORK_CACHE:+$__NETWORK_CACHE }__NETWORK_CV_$1"
+ fi
+}
- local __tmp="$(ubus call network.interface."$__iface" status 2>/dev/null)"
+__network_export()
+{
+ local __v="__NETWORK_CV_$2"
+ eval "export -- \"$1=\${$__v:+\$$__v$3}\"; [ -n \"\${$__v+x}\" ]"
+}
+
+__network_parse_ifstatus()
+{
+ local __iface="$1"
+ local __key="${__iface}"
+ local __tmp
+ local __old_ns
- json_load "${__tmp:-{}}"
- json_get_type __tmp "ipv${__family}_address"
+ __network_export __tmp "${__key}__parsed" && return 0
+ __tmp="$(ubus call network.interface."$__iface" status 2>/dev/null)"
+ [ -n "$__tmp" ] || return 1
- if [ "$__tmp" = array ]; then
+ json_set_namespace "network" __old_ns
+ json_load "$__tmp"
- json_select "ipv${__family}_address"
- json_get_type __tmp 1
+ __network_set_cache "${__key}__parsed" "" "1"
- if [ "$__tmp" = object ]; then
+ for __tmp in "" "_inactive"; do
- json_select 1
- json_get_var $__var address
+ __key="${__key}${__tmp}"
- [ $__prefix -gt 0 ] && {
- json_get_var __tmp mask
- eval "export -- \"$__var=\${$__var}/$__tmp\""
- }
+ # parse addresses
+ local __family
+ for __family in 4 6; do
+ if json_is_a "ipv${__family}_address" array; then
- return 0
+ json_select "ipv${__family}_address"
+
+ if json_is_a 1 object; then
+
+ json_select 1
+ __network_set_cache "${__key}_address${__family}" address
+ __network_set_cache "${__key}_mask${__family}" mask
+ json_select ".."
+
+ fi
+
+ json_select ".."
+
+ fi
+ done
+
+ # parse prefixes
+ if json_is_a "ipv6_prefix" array; then
+ json_select "ipv6_prefix"
+
+ if json_is_a 1 object; then
+ json_select 1
+ __network_set_cache "${__key}_prefix6_address" address
+ __network_set_cache "${__key}_prefix6_mask" mask
+ json_select ".."
+ fi
+
+ json_select ".."
fi
- fi
- return 1
-}
+ # parse routes
+ if json_is_a route array; then
-network_get_ipaddr() { __network_ipaddr "$1" "$2" 4 0; }
-network_get_ipaddr6() { __network_ipaddr "$1" "$2" 6 0; }
+ json_select "route"
-network_get_subnet() { __network_ipaddr "$1" "$2" 4 1; }
-network_get_subnet6() { __network_ipaddr "$1" "$2" 6 1; }
+ local __idx=1
+ while json_is_a "$__idx" object; do
+ json_select "$((__idx++))"
+ json_get_var __tmp table
-__network_gateway()
+ if [ -z "$__tmp" ]; then
+ json_get_var __tmp target
+
+ case "${__tmp}" in
+ 0.0.0.0)
+ __network_set_cache "${__key}_gateway4" nexthop
+ ;;
+ ::)
+ __network_set_cache "${__key}_gateway6" nexthop
+ ;;
+ esac
+ fi
+
+ json_select ".."
+
+ done
+
+ json_select ".."
+
+ fi
+
+ # parse dns info
+ local __field
+ for __field in "dns_server" "dns_search"; do
+ if json_is_a "$__field" array; then
+
+ json_select "$__field"
+
+ local __idx=1
+ local __dns=""
+
+ while json_is_a "$__idx" string; do
+
+ json_get_var __tmp "$((__idx++))"
+ __dns="${__dns:+$__dns }$__tmp"
+
+ done
+
+ json_select ".."
+
+ if [ -n "$__dns" ]; then
+ __network_set_cache "${__key}_${__field}" "" "$__dns"
+ fi
+ fi
+ done
+
+ # parse up state, device and physdev
+ for __field in "up" "l3_device" "device"; do
+ if json_get_type __tmp "$__field"; then
+ __network_set_cache "${__key}_${__field}" "$__field"
+ fi
+ done
+
+ # descend into inactive table
+ json_is_a "inactive" object && json_select "inactive"
+
+ done
+
+ json_cleanup
+ json_set_namespace "$__old_ns"
+
+ return 0
+}
+
+
+__network_ipaddr()
{
local __var="$1"
local __iface="$2"
local __family="$3"
+ local __prefix="$4"
+ local __tmp
- local __tmp="$(ubus call network.interface."$__iface" status 2>/dev/null)"
- local __idx=1
- local __enabled
+ __network_parse_ifstatus "$__iface" || return 1
- json_load "${__tmp:-{}}"
+ if [ $__prefix -eq 1 ]; then
+ __network_export __tmp "${__iface}_mask${__family}" && \
+ __network_export "$__var" "${__iface}_address${__family}" "/$__tmp"
+ return $?
+ fi
- if json_get_type __tmp route && [ "$__tmp" = array ]; then
+ __network_export "$__var" "${__iface}_address${__family}"
+ return $?
- json_select route
+}
- while json_get_type __tmp "$__idx" && [ "$__tmp" = object ]; do
+# determine IPv4 address of given logical interface
+# 1: destination variable
+# 2: interface
+network_get_ipaddr() { __network_ipaddr "$1" "$2" 4 0; }
- json_select "$((__idx++))"
- json_get_var __tmp target
- json_get_var __enabled enabled
+# determine IPv6 address of given logical interface
+# 1: destination variable
+# 2: interface
+network_get_ipaddr6() { __network_ipaddr "$1" "$2" 6 0; }
- case "${__enabled}/${__family}/${__tmp}" in
- 1/4/0.0.0.0|1/6/::)
- json_get_var "$__var" nexthop
- return $?
- ;;
- esac
+# determine IPv4 subnet of given logical interface
+# 1: destination variable
+# 2: interface
+network_get_subnet() { __network_ipaddr "$1" "$2" 4 1; }
- json_select ".."
+# determine IPv6 subnet of given logical interface
+# 1: destination variable
+# 2: interface
+network_get_subnet6() { __network_ipaddr "$1" "$2" 6 1; }
- done
- fi
+# determine IPv6 prefix
+network_get_prefix6() {
+ local __var="$1"
+ local __iface="$2"
+ local __address
+ local __mask
- return 1
+ __network_parse_ifstatus "$__iface" || return 1
+ __network_export __mask "${__iface}_prefix6_mask" || return 1
+ __network_export "$__var" "${__iface}_prefix6_address" "/$__mask"
+ return $?
}
-network_get_gateway() { __network_gateway "$1" "$2" 4; }
-network_get_gateway6() { __network_gateway "$1" "$2" 6; }
-
-__network_dns() {
+__network_gateway()
+{
local __var="$1"
local __iface="$2"
- local __field="$3"
+ local __family="$3"
+ local __inactive="$4"
- local __tmp="$(ubus call network.interface."$__iface" status 2>/dev/null)"
- local __dns=""
- local __idx=1
+ __network_parse_ifstatus "$__iface" || return 1
- json_load "${__tmp:-{}}"
+ if [ "$__inactive" = 1 -o "$__inactive" = "true" ]; then
+ __network_export "$__var" "${__iface}_inactive_gateway${__family}" && \
+ return 0
+ fi
- if json_get_type __tmp "$__field" && [ "$__tmp" = array ]; then
+ __network_export "$__var" "${__iface}_gateway${__family}"
+ return $?
+}
- json_select "$__field"
+# determine IPv4 gateway of given logical interface
+# 1: destination variable
+# 2: interface
+# 3: consider inactive gateway if "true" (optional)
+network_get_gateway() { __network_gateway "$1" "$2" 4 "${3:-0}"; }
- while json_get_type __tmp "$__idx" && [ "$__tmp" = string ]; do
+# determine IPv6 gateway of given logical interface
+# 1: destination variable
+# 2: interface
+# 3: consider inactive gateway if "true" (optional)
+network_get_gateway6() { __network_gateway "$1" "$2" 6 "${3:-0}"; }
- json_get_var __tmp "$((__idx++))"
- __dns="${__dns:+$__dns }$__tmp"
- done
+__network_dns() {
+ local __var="$1"
+ local __iface="$2"
+ local __field="$3"
+ local __inactive="$4"
+
+ __network_parse_ifstatus "$__iface" || return 1
+
+ if [ "$__inactive" = 1 -o "$__inactive" = "true" ]; then
+ __network_export "$__var" "${__iface}_inactive_${__field}" && \
+ return 0
fi
- eval "export -- \"$__var=$__dns\""
- [ -n "$__dns" ]
+ __network_export "$__var" "${__iface}_${__field}"
+ return $?
}
-network_get_dnsserver() { __network_dns "$1" "$2" dns_server; }
-network_get_dnssearch() { __network_dns "$1" "$2" dns_search; }
+# determine the DNS servers of the given logical interface
+# 1: destination variable
+# 2: interface
+# 3: consider inactive servers if "true" (optional)
+network_get_dnsserver() { __network_dns "$1" "$2" dns_server "${3:-0}"; }
+
+# determine the domains of the given logical interface
+# 1: destination variable
+# 2: interface
+# 3: consider inactive domains if "true" (optional)
+network_get_dnssearch() { __network_dns "$1" "$2" dns_search "${3:-0}"; }
-__network_wan() {
+__network_wan()
+{
local __var="$1"
local __family="$2"
+ local __inactive="$3"
local __iface
for __iface in $(ubus list | sed -ne 's/^network\.interface\.//p'); do
- if __network_gateway "$__var" "$__iface" "$__family"; then
- eval "export -- \"$__var=$__iface\""
- return 0
+ if [ "$__iface" != loopback ]; then
+ if __network_gateway "$__var" "$__iface" "$__family" "$__inactive"; then
+ eval "export -- \"$__var=$__iface\""
+ return 0
+ fi
fi
done
@@ -129,8 +283,15 @@ __network_wan() {
return 1
}
-network_find_wan() { __network_wan "$1" 4; }
-network_find_wan6() { __network_wan "$1" 6; }
+# find the logical interface which holds the current IPv4 default route
+# 1: destination variable
+# 2: consider inactive default routes if "true" (optional)
+network_find_wan() { __network_wan "$1" 4 "${2:-0}"; }
+
+# find the logical interface which holds the current IPv6 default route
+# 1: destination variable
+# 2: consider inactive dafault routes if "true" (optional)
+network_find_wan6() { __network_wan "$1" 6 "${2:-0}"; }
__network_device()
@@ -139,20 +300,27 @@ __network_device()
local __iface="$2"
local __field="$3"
- local __tmp="$(ubus call network.interface."$__iface" status 2>/dev/null)"
- [ -n "$__tmp" ] || return 1
-
- json_load "$__tmp"
- json_get_var "$__var" "$__field"
+ __network_parse_ifstatus "$__iface" || return 1
+ __network_export "$__var" "${__iface}_${__field}"
+ return $?
}
+# test whether the given logical interface is running
+# 1: interface
network_is_up()
{
local __up
__network_device __up "$1" up && [ $__up -eq 1 ]
}
+# determine the layer 3 linux network device of the given logical interface
+# 1: destination variable
+# 2: interface
network_get_device() { __network_device "$1" "$2" l3_device; }
+
+# determine the layer 2 linux network device of the given logical interface
+# 1: destination variable
+# 2: interface
network_get_physdev() { __network_device "$1" "$2" device; }
@@ -168,5 +336,19 @@ __network_defer()
ubus call network.device set_state "$(json_dump)" 2>/dev/null
}
+# defer netifd actions on the given linux network device
+# 1: device name
network_defer_device() { __network_defer "$1" 1; }
+
+# continue netifd actions on the given linux network device
+# 1: device name
network_ready_device() { __network_defer "$1" 0; }
+
+# flush the internal value cache to force re-reading values from ubus
+network_flush_cache()
+{
+ local __tmp
+ for __tmp in $__NETWORK_CACHE __NETWORK_CACHE; do
+ unset "$__tmp"
+ done
+}
diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh
index 477c00cfd..bf6fe1e30 100644
--- a/package/base-files/files/lib/functions/uci-defaults.sh
+++ b/package/base-files/files/lib/functions/uci-defaults.sh
@@ -150,6 +150,8 @@ set network.loopback.ifname='lo'
set network.loopback.proto='static'
set network.loopback.ipaddr='127.0.0.1'
set network.loopback.netmask='255.0.0.0'
+set network.globals='globals'
+set network.globals.ula_prefix='auto'
EOF
}
@@ -174,6 +176,7 @@ set network.lan.type='bridge'
set network.lan.proto='static'
set network.lan.ipaddr='192.168.1.1'
set network.lan.netmask='255.255.255.0'
+set network.lan.ip6assign='60'
EOF
}
@@ -184,6 +187,9 @@ ucidef_set_interface_wan() {
set network.wan='interface'
set network.wan.ifname='$ifname'
set network.wan.proto='dhcp'
+set network.wan6='interface'
+set network.wan6.ifname='@wan'
+set network.wan6.proto='dhcpv6'
EOF
}
diff --git a/package/base-files/files/lib/preinit/10_indicate_preinit b/package/base-files/files/lib/preinit/10_indicate_preinit
index ab6930518..da70b97c4 100644
--- a/package/base-files/files/lib/preinit/10_indicate_preinit
+++ b/package/base-files/files/lib/preinit/10_indicate_preinit
@@ -27,7 +27,6 @@ preinit_net_echo() {
[ "$pi_failsafe_net_message" = "true" ] &&
[ "$pi_preinit_no_failsafe_netmsg" != "y" ]
}
-
} && netmsg $pi_broadcast "$1"
}
}
@@ -42,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 04dc57df2..bcf24f8bb 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
@@ -75,10 +74,13 @@ fs_wait_for_key () {
failsafe_wait() {
FAILSAFE=
- pi_failsafe_net_message=true
- preinit_net_echo "Please press button now to enter failsafe"
- pi_failsafe_net_message=false
- fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true && export FAILSAFE
+ grep -q 'failsafe=' /proc/cmdline && FAILSAFE=true && export FAILSAFE
+ if [ "$FAILSAFE" != "true" ]; then
+ pi_failsafe_net_message=true
+ preinit_net_echo "Please press button now to enter failsafe"
+ pi_failsafe_net_message=false
+ fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true && export FAILSAFE
+ fi
}
boot_hook_add preinit_main failsafe_wait
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 9cc01f219..c200dad67 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 cc8781687..0292d82d4 100644
--- a/package/base-files/files/lib/preinit/80_mount_root
+++ b/package/base-files/files/lib/preinit/80_mount_root
@@ -3,8 +3,16 @@
# Copyright (C) 2010 Vertical Communications
do_mount_root() {
- boot_run_hook preinit_mount_root
-}
-
-boot_hook_add preinit_main do_mount_root
+ mount_root
+ boot_run_hook preinit_mount_root
+ [ -f /sysupgrade.tgz ] && {
+ echo "- config restore -"
+ cd /
+ mv sysupgrade.tgz /tmp
+ tar xzf /tmp/sysupgrade.tgz
+ rm -f /tmp/sysupgrade.tgz
+ sync
+ }
+}
+[ "$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 fef3a503e..a8f330f89 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 e6de34849..6bb36db48 100644
--- a/package/base-files/files/lib/upgrade/common.sh
+++ b/package/base-files/files/lib/upgrade/common.sh
@@ -21,8 +21,8 @@ install_bin() { # <file> [ <symlink> ... ]
files=$1
[ -x "$src" ] && files="$src $(libs $src)"
install_file $files
- [ -e /lib/ld-linux.so.3 ] && {
- install_file /lib/ld-linux.so.3
+ [ -e /lib/ld.so.1 ] && {
+ install_file /lib/ld.so.1
}
shift
for link in "$@"; do {
@@ -33,19 +33,19 @@ install_bin() { # <file> [ <symlink> ... ]
}; done
}
-pivot() { # <new_root> <old_root>
+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 move /proc $1/proc && \
+ mount -o noatime,move /proc $1/proc && \
pivot_root $1 $1$2 || {
- umount $1 $1
+ umount -l $1 $1
return 1
}
- mount -o move $2/sys /sys
- mount -o move $2/dev /dev
- mount -o move $2/tmp /tmp
- mount -o move $2/overlay /overlay 2>&-
+ 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
}
@@ -62,7 +62,7 @@ run_ramfs() { # <command> [...]
done
install_file /etc/resolv.conf /lib/functions.sh /lib/functions.sh /lib/upgrade/*.sh $RAMFS_COPY_DATA
- pivot $RAM_ROOT /mnt || {
+ supivot $RAM_ROOT /mnt || {
echo "Failed to switch over to ramfs. Please reboot."
exit 1
}
@@ -71,7 +71,7 @@ run_ramfs() { # <command> [...]
umount -l /mnt
grep /overlay /proc/mounts > /dev/null && {
- mount -o remount,ro /overlay
+ mount -o noatime,remount,ro /overlay
umount -l /overlay
}
@@ -99,7 +99,7 @@ kill_remaining() { # [ <signal> ]
case "$name" in
# Skip essential services
- *ash*|*init*|*watchdog*|*ssh*|*dropbear*|*telnet*|*login*|*hostapd*|*wpa_supplicant*) : ;;
+ *procd*|*ash*|*init*|*watchdog*|*ssh*|*dropbear*|*telnet*|*login*|*hostapd*|*wpa_supplicant*) : ;;
# Killable process
*)
@@ -157,14 +157,14 @@ get_image() { # <source> [ <command> ]
*) 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"')"
+ local magic="$(eval $cmd $from 2>/dev/null | 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}"
+ eval "$cmd $from 2>/dev/null ${conc:+| $conc}"
}
get_magic_word() {
diff --git a/package/base-files/files/sbin/firstboot b/package/base-files/files/sbin/firstboot
index 4da299189..081febb7b 100755
--- a/package/base-files/files/sbin/firstboot
+++ b/package/base-files/files/sbin/firstboot
@@ -1,34 +1,3 @@
#!/bin/sh
-switch2jffs_hook=
-jffs2reset_hook=
-no_fo_hook=
-
-. /lib/functions/boot.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
- elif [ -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 "$mtdpart" /overlay -t jffs2
- fopivot /overlay /rom 1
- fi
-fi
-
+/sbin/jffs2reset
diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade
index 802848ade..1ad6ea44a 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -12,6 +12,7 @@ export DELAY=
export CONF_IMAGE=
export CONF_BACKUP=
export CONF_RESTORE=
+export NEED_IMAGE=
export HELP=0
export FORCE=0
@@ -24,8 +25,8 @@ while [ -n "$1" ]; do
-q) export VERBOSE="$(($VERBOSE - 1))";;
-n) export SAVE_CONFIG=0;;
-c) export SAVE_OVERLAY=1;;
- -b|--create-backup) export CONF_BACKUP="$2"; shift;;
- -r|--restore-backup) export CONF_RESTORE="$2"; shift;;
+ -b|--create-backup) export CONF_BACKUP="$2" NEED_IMAGE=1; shift;;
+ -r|--restore-backup) export CONF_RESTORE="$2" NEED_IMAGE=1; shift;;
-f) export CONF_IMAGE="$2"; shift;;
-F|--force) export FORCE=1;;
-h|--help) export HELP=1; break;;
@@ -44,38 +45,41 @@ export CONF_TAR=/tmp/sysupgrade.tgz
export ARGV="$*"
export ARGC="$#"
-[ -z "$ARGV" -a -z "$CONF_BACKUP" -o $HELP -gt 0 ] && {
+[ -z "$ARGV" -a -z "$NEED_IMAGE" -o $HELP -gt 0 ] && {
cat <<EOF
-Usage: $0 [options] <image file or URL>
+Usage: $0 [<upgrade-option>...] <image file or URL>
+ $0 [-q] [-i] <backup-command> <file>
-Options:
+upgrade-option:
-d <delay> add a delay before rebooting
-f <config> restore configuration from .tar.gz (file or url)
-i interactive mode
-c attempt to preserve all changed files in /etc/
- -b / --create-backup <file>
+ -n do not save configuration over reflash
+ -F | --force
+ Flash image even if image checks fail, this is dangerous!
+ -q less verbose
+ -v more verbose
+ -h | --help display this help
+
+backup-command:
+ -b | --create-backup <file>
create .tar.gz of files specified in sysupgrade.conf
then exit. Does not flash an image. If file is '-',
i.e. stdout, verbosity is set to 0 (i.e. quiet).
- -r / --restore-backup <file>
+ -r | --restore-backup <file>
restore a .tar.gz created with sysupgrade -b
then exit. Does not flash an image. If file is '-',
the archive is read from stdin.
- -n do not save configuration over reflash
- -F / --force
- Flash image even if image checks fail, this is dangerous!
- -q less verbose
- -v more verbose
- -h / --help display this help
EOF
exit 1
}
-[ -n "$ARGV" -a -n "$CONF_BACKUP" ] && {
+[ -n "$ARGV" -a -n "$NEED_IMAGE" ] && {
cat <<-EOF
- -b/--create-backup does not perform a firmware upgrade. Do not
- specify both -b and a firmware image.
+ -b|--create-backup and -r|--restore-backup do not perform a firmware upgrade.
+ Do not specify both -b|-r and a firmware image.
EOF
exit 1
}
@@ -175,6 +179,8 @@ fi
run_hooks "" $sysupgrade_pre_upgrade
+ubus call system upgrade
+
kill_remaining TERM
sleep 3
kill_remaining KILL