diff options
Diffstat (limited to 'target')
32 files changed, 353 insertions, 181 deletions
diff --git a/target/linux/adm5120/base-files/etc/preinit.arch b/target/linux/adm5120/base-files/etc/preinit.arch deleted file mode 100755 index a4087db0ec..0000000000 --- a/target/linux/adm5120/base-files/etc/preinit.arch +++ /dev/null @@ -1,16 +0,0 @@ -. /etc/functions.sh - -insmod input-core -insmod input-polldev -insmod gpio_buttons -insmod button-hotplug - -ifname=eth0 - -failsafe_ip - -netmsg 192.168.1.255 "Press reset now, to enter Failsafe!" - -ifconfig "$ifname" 0.0.0.0 down - -sleep 2 diff --git a/target/linux/adm5120/base-files/lib/preinit/05_enable_leds_adm5120 b/target/linux/adm5120/base-files/lib/preinit/05_enable_leds_adm5120 new file mode 100644 index 0000000000..01b2f7ea12 --- /dev/null +++ b/target/linux/adm5120/base-files/lib/preinit/05_enable_leds_adm5120 @@ -0,0 +1,12 @@ +#!/bin/sh + +enable_leds() { + insmod input-core + insmod input-polldev + insmod gpio_buttons + insmod button-hotplug +} + +boot_hook_add preinit_main enable_leds + + diff --git a/target/linux/adm5120/base-files/lib/preinit/05_set_preinit_face_adm5120 b/target/linux/adm5120/base-files/lib/preinit/05_set_preinit_face_adm5120 new file mode 100644 index 0000000000..ac2a7cbb66 --- /dev/null +++ b/target/linux/adm5120/base-files/lib/preinit/05_set_preinit_face_adm5120 @@ -0,0 +1,9 @@ +#!/bin/sh + +set_preinit_ifname() { + ifname=eth0 +} + +boot_hook_add preinit_main set_preinit_ifname + + diff --git a/target/linux/ar71xx/base-files/lib/preinit/05_enable_leds_ar71xx b/target/linux/ar71xx/base-files/lib/preinit/05_enable_leds_ar71xx new file mode 100644 index 0000000000..0b130fbf2c --- /dev/null +++ b/target/linux/ar71xx/base-files/lib/preinit/05_enable_leds_ar71xx @@ -0,0 +1,16 @@ +# +# Copyright (C) 2009 OpenWrt.org +# + +. /lib/ar71xx.sh + + +preinit_enable_leds() { + insmod input-core + insmod input-polldev + insmod gpio_buttons + insmod button-hotplug +} + +boot_hook_add preinit_main preinit_enable_leds + diff --git a/target/linux/ar71xx/base-files/etc/preinit.arch b/target/linux/ar71xx/base-files/lib/preinit/05_set_iface_mac_ar71xx index f770ca3714..f8bb7b76c6 100644 --- a/target/linux/ar71xx/base-files/etc/preinit.arch +++ b/target/linux/ar71xx/base-files/lib/preinit/05_set_iface_mac_ar71xx @@ -20,13 +20,6 @@ fetch_mac_from_mtd() { [ ! -z $mac ] && ifconfig eth1 hw ether $mac 2>/dev/null } -preinit_load_modules() { - insmod input-core - insmod input-polldev - insmod gpio_buttons - insmod button-hotplug -} - preinit_set_mac_address() { case $(ar71xx_board_name) in tew-632brp) @@ -42,15 +35,5 @@ preinit_set_mac_address() { esac } -preinit_set_mac_address -preinit_load_modules - -ifname=eth0 - -failsafe_ip - -netmsg 192.168.1.255 "Press any button now, to enter Failsafe!" - -ifconfig "$ifname" 0.0.0.0 down +boot_hook_add preinit_main preinit_set_mac_address -sleep 2 diff --git a/target/linux/ar71xx/base-files/lib/preinit/05_set_preinit_iface_ar71xx b/target/linux/ar71xx/base-files/lib/preinit/05_set_preinit_iface_ar71xx new file mode 100644 index 0000000000..8611dce816 --- /dev/null +++ b/target/linux/ar71xx/base-files/lib/preinit/05_set_preinit_iface_ar71xx @@ -0,0 +1,16 @@ +#!/bin/sh + +# +# Copyright (C) 2009 OpenWrt.org +# + +. /lib/ar71xx.sh + +set_preinit_iface() { + ifname=eth0 +} + +boot_hook_add preinit_main set_preinit_iface + + + diff --git a/target/linux/atheros/base-files/etc/preinit.arch b/target/linux/atheros/base-files/etc/preinit.arch deleted file mode 100755 index bdfe67ba56..0000000000 --- a/target/linux/atheros/base-files/etc/preinit.arch +++ /dev/null @@ -1,21 +0,0 @@ -# reset button only supported on ar5315+ at the moment -grep 'Atheros AR231[567]' /proc/cpuinfo > /dev/null && { - if [ -e "/sys/bus/mdio_bus/drivers/Infineon ADM6996/0:00" -o \ - -e "/sys/bus/mdio_bus/drivers/Marvell 88E6060/0:10" ]; then - vconfig set_name_type DEV_PLUS_VID_NO_PAD - ifconfig eth0 up - vconfig add eth0 1 - ifname=eth0.1 - else - ifname=eth0 - fi - failsafe_ip - netmsg 192.168.1.255 "Press reset now, to enter Failsafe!" - sleep 2 - if [ -z "$FAILSAFE" -a \ - \( -e "/sys/bus/mdio_bus/drivers/Infineon ADM6996/0:00" -o \ - -e "/sys/bus/mdio_bus/drivers/Marvell 88E6060/0:10" \) ]; then - vconfig rem eth0.1 - ifconfig eth0 down - fi -} diff --git a/target/linux/atheros/base-files/lib/preinit/15_preinit_iface_atheros b/target/linux/atheros/base-files/lib/preinit/15_preinit_iface_atheros new file mode 100644 index 0000000000..c15b4de1ee --- /dev/null +++ b/target/linux/atheros/base-files/lib/preinit/15_preinit_iface_atheros @@ -0,0 +1,32 @@ +#!/bin/sh + +# reset button only supported on ar5315+ at the moment +preinit_ip() { + if [ -z "$pi_ifname" ]; then + grep 'Atheros AR231[567]' /proc/cpuinfo > /dev/null && { + if [ -e "/sys/bus/mdio_bus/drivers/Infineon ADM6996/0:00" -o \ + -e "/sys/bus/mdio_bus/drivers/Marvell 88E6060/0:10" ]; then + vconfig set_name_type DEV_PLUS_VID_NO_PAD + ifconfig eth0 up + vconfig add eth0 1 + ifname=eth0.1 + else + ifname=eth0 + fi + pi_ifname=$ifname + } + [ -n "$pi_ifname" ] && grep "$pi_ifname" /proc/net/dev >/dev/null && { + ifconfig $pi_ifname $pi_ip netmask $pi_netmask broadcast $pi_broadcast up + } +} + + +# reset button only supported on ar5315+ at the moment + +preinit_ip_deconfig() { + if [ -e "/sys/bus/mdio_bus/drivers/Infineon ADM6996/0:00" -o \ + -e "/sys/bus/mdio_bus/drivers/Marvell 88E6060/0:10" ]; then + vconfig rem eth0.1 2>/dev/null + ifconfig $pi_ifname down + fi +} diff --git a/target/linux/brcm-2.4/base-files/etc/preinit.arch b/target/linux/brcm-2.4/base-files/etc/preinit.arch deleted file mode 100755 index e62360e44c..0000000000 --- a/target/linux/brcm-2.4/base-files/etc/preinit.arch +++ /dev/null @@ -1,71 +0,0 @@ -. /etc/functions.sh - -failsafe() { - lock /tmp/.failsafe - failsafe_ip - - echo "0 1 2 3 4 ${cpu_port:-5u*}" > /proc/switch/eth0/vlan/0/ports - - set_state failsafe - [ -x "/usr/sbin/nvram" ] && { - [ "$(nvram get boot_wait)" != "on" ] && { - nvram set boot_wait=on - nvram commit - } - } - - netmsg 192.168.1.255 "Entering Failsafe!" - telnetd -l /bin/login.sh <> /dev/null 2>&1 - - ash --login -} - -mount none /proc -t proc - -insmod diag -set_state preinit -echo '/sbin/hotplug.failsafe' > /proc/sys/kernel/hotplug - -ifname=eth0 - -# hardware specific overrides -case "$(cat /proc/diag/model)" in - "Linksys WAP54G V1") ifname=eth1;; - "ASUS WL-HDD") ifname=eth1;; - "ASUS WL-300g") ifname=eth1;; - "ASUS (unknown, BCM4702)") ifname=eth1;; - "Sitecom WL-105b") ifname=eth1;; -esac - -check_module () { - module="$1"; shift; params="$*" - - insmod "$module" "$params" - sleep 1 - grep "^$module" /proc/modules - return $? -} - -check_module tg3 -failsafe_ip - -insmod switch-core -check_module switch-robo || check_module switch-adm || { - check_module bcm57xx activate_gpio=0x4 && cpu_port="8u*" -} || rmmod switch-core - -[ -d /proc/switch/eth0 ] && { - echo 1 > /proc/switch/eth0/reset - - # this would be easier if we blasted the message across all ports - # but we don't want packets leaking across interfaces - for port in $(seq 0 4); do { - echo "$port ${cpu_port:-5u*}" > /proc/switch/eth0/vlan/0/ports - netmsg 192.168.1.255 "Press reset now, to enter Failsafe!" - }; done -} || netmsg 192.168.1.255 "Press reset now, to enter Failsafe!" - -ifconfig $ifname 0.0.0.0 down - -sleep 2 - diff --git a/target/linux/brcm-2.4/base-files/lib/preinit/03_init_hotplug_failsafe_brcm-2.4 b/target/linux/brcm-2.4/base-files/lib/preinit/03_init_hotplug_failsafe_brcm-2.4 new file mode 100644 index 0000000000..b0f4a4efa9 --- /dev/null +++ b/target/linux/brcm-2.4/base-files/lib/preinit/03_init_hotplug_failsafe_brcm-2.4 @@ -0,0 +1,9 @@ +#!/bin/sh + +init_hotplug_failsafe() { + echo '/sbin/hotplug.failsafe' > /proc/sys/kernel/hotplug +} + +boot_hook_add preinit_main init_hotplug_failsafe + + diff --git a/target/linux/brcm-2.4/base-files/lib/preinit/05_init_interfaces_brcm-2.4 b/target/linux/brcm-2.4/base-files/lib/preinit/05_init_interfaces_brcm-2.4 new file mode 100644 index 0000000000..81cf1f1380 --- /dev/null +++ b/target/linux/brcm-2.4/base-files/lib/preinit/05_init_interfaces_brcm-2.4 @@ -0,0 +1,38 @@ +#!/bin/sh + +set_preinit_iface() { + ifname=eth0 + + insmod diag + + # hardware specific overrides + case "$(cat /proc/diag/model)" in + "Linksys WAP54G V1") ifname=eth1;; + "ASUS WL-HDD") ifname=eth1;; + "ASUS WL-300g") ifname=eth1;; + "ASUS (unknown, BCM4702)") ifname=eth1;; + "Sitecom WL-105b") ifname=eth1;; + esac +} + +check_module () { + module="$1"; shift; params="$*" + + insmod "$module" "$params" + sleep 1 + grep "^$module" /proc/modules + return $? +} + +init_iface() { + check_module tg3 + insmod switch-core + check_module switch-robo || check_module switch-adm || { + check_module bcm57xx activate_gpio=0x4 && cpu_port="8u*" + } || rmmod switch-core +} + +boot_hook_add preinit_main init_iface +boot_hook_add preinit_main set_preinit_iface + + diff --git a/target/linux/brcm-2.4/base-files/lib/preinit/05_set_failsafe_switch_brcm-2.4 b/target/linux/brcm-2.4/base-files/lib/preinit/05_set_failsafe_switch_brcm-2.4 new file mode 100644 index 0000000000..28e62e5b57 --- /dev/null +++ b/target/linux/brcm-2.4/base-files/lib/preinit/05_set_failsafe_switch_brcm-2.4 @@ -0,0 +1,15 @@ +#!/bin/sh + +failsafe_ip() { + [ -d /proc/switch/eth0 ] && [ "$ifname" = "eth0" ] && { + ifconfig eth0 0.0.0.0 down + echo "0 1 2 3 4 ${cpu_port:-5u*}" > /proc/switch/eth0/vlan/0/ports + } + + [ -n "$pi_ifname" ] && grep "$pi_ifname" /proc/net/dev >/dev/null && { + ifconfig $pi_ifname $pi_ip netmask $pi_netmask broadcast $pi_broadcast up + } +} + +boot_hook_add failsafe failsafe_ip + diff --git a/target/linux/brcm-2.4/base-files/lib/preinit/15_mount_proc_brcm-2.4 b/target/linux/brcm-2.4/base-files/lib/preinit/15_mount_proc_brcm-2.4 new file mode 100644 index 0000000000..fd5add16a5 --- /dev/null +++ b/target/linux/brcm-2.4/base-files/lib/preinit/15_mount_proc_brcm-2.4 @@ -0,0 +1,6 @@ +#!/bin/sh + +do_mount_procfs() { + mount none /proc -t proc +} + diff --git a/target/linux/brcm-2.4/base-files/lib/preinit/15_set_preinit_interface_brcm-2.4 b/target/linux/brcm-2.4/base-files/lib/preinit/15_set_preinit_interface_brcm-2.4 new file mode 100644 index 0000000000..5e8dc9f11f --- /dev/null +++ b/target/linux/brcm-2.4/base-files/lib/preinit/15_set_preinit_interface_brcm-2.4 @@ -0,0 +1,38 @@ +. /etc/functions.sh + +port_net_echo() { + [ -n "$pi_ifname" ] && grep "$pi_ifname" /proc/net/dev >/dev/null ] { + if [ "$pi_preinit_net_messages" = "y" ] || [ "$pi_failsafe_net_message" = "true"] && [ "$pi_preinit_no_failsafe_netmsg" != "y" ]; then + netmsg $pi_broadcast "$1" + } + } +} + +preinit_ip_deconfig() { + if [ -z "$pi_ifname" ]; then + ifconfig $ifname 0.0.0.0 down + else + grep "$pi_ifname" /proc/net/dev >/dev/null && { + ifconfig $pi_ifname 0.0.0.0 down + } + fi +} + +preinit_net_echo() { + preinit_ip + + [ -d /proc/switch/eth0 ] && [ "$pi_ifname" = "eth0" ] && { + echo 1 > /proc/switch/eth0/reset + + # this would be easier if we blasted the message across all ports + # but we don't want packets leaking across interfaces + for port in $(seq 0 4); do { + echo "$port ${cpu_port:-5u*}" > /proc/switch/eth0/vlan/0/ports + port_net_echo $1 + }; done + } || port_net_echo $1 + + preinit_ip_deconfig +} + + diff --git a/target/linux/brcm-2.4/base-files/lib/preinit/20_failsafe_set_boot_wait_brcm-2.4 b/target/linux/brcm-2.4/base-files/lib/preinit/20_failsafe_set_boot_wait_brcm-2.4 new file mode 100644 index 0000000000..da721b8484 --- /dev/null +++ b/target/linux/brcm-2.4/base-files/lib/preinit/20_failsafe_set_boot_wait_brcm-2.4 @@ -0,0 +1,14 @@ +#!/bin/sh + +. /etc/functions.sh + +set_boot_wait() { + [ -x "/usr/sbin/nvram" ] && { + [ "$(nvram get boot_wait)" != "on" ] && { + nvram set boot_wait=on + nvram commit + } + } +} + +boot_hook_add failsafe set_boot_wait diff --git a/target/linux/gemini/base-files/etc/preinit.arch b/target/linux/gemini/base-files/etc/preinit.arch deleted file mode 100755 index ecdb41039c..0000000000 --- a/target/linux/gemini/base-files/etc/preinit.arch +++ /dev/null @@ -1,6 +0,0 @@ -CONFIG_PARTITION="$(grep "VCTL" /proc/mtd | cut -d: -f1)" -MAC1="$(strings /dev/$CONFIG_PARTITION |grep MAC|cut -d: -f2|cut -c3-14|sed -e 's,\(..\),:\1,g' -e 's,^:,,')" -MAC2="$(strings /dev/$CONFIG_PARTITION |grep MAC|cut -d: -f8|cut -c3-14|sed -e 's,\(..\),:\1,g' -e 's,^:,,')" - -ifconfig eth0 hw ether $MAC1 2>/dev/null -ifconfig eth1 hw ether $MAC2 2>/dev/null diff --git a/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini b/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini new file mode 100644 index 0000000000..499608120e --- /dev/null +++ b/target/linux/gemini/base-files/lib/preinit/05_set_ether_mac_gemini @@ -0,0 +1,13 @@ +#!/bin/sh + +set_ether_mac() { + CONFIG_PARTITION="$(grep "VCTL" /proc/mtd | cut -d: -f1)" + MAC1="$(strings /dev/$CONFIG_PARTITION |grep MAC|cut -d: -f2|cut -c3-14|sed -e 's,\(..\),:\1,g' -e 's,^:,,')" + MAC2="$(strings /dev/$CONFIG_PARTITION |grep MAC|cut -d: -f8|cut -c3-14|sed -e 's,\(..\),:\1,g' -e 's,^:,,')" + + ifconfig eth0 hw ether $MAC1 2>/dev/null + ifconfig eth1 hw ether $MAC2 2>/dev/null +} + +boot_hook_add preinit_main set_ether_mac + diff --git a/target/linux/ifxmips/nfs/base-files/etc/preinit.arch b/target/linux/ifxmips/nfs/base-files/etc/preinit.arch deleted file mode 100755 index 7ee8e3e346..0000000000 --- a/target/linux/ifxmips/nfs/base-files/etc/preinit.arch +++ /dev/null @@ -1,5 +0,0 @@ - -grep "/dev/root" /proc/mounts |grep -q nfs && { - echo "- init nfs -" - exec /sbin/init -} diff --git a/target/linux/ifxmips/nfs/base-files/lib/preinit/01_init_nfs_ifxmips b/target/linux/ifxmips/nfs/base-files/lib/preinit/01_init_nfs_ifxmips new file mode 100644 index 0000000000..e2cf52dc4e --- /dev/null +++ b/target/linux/ifxmips/nfs/base-files/lib/preinit/01_init_nfs_ifxmips @@ -0,0 +1,12 @@ +#!/bin/sh + + +init_nfs() { + grep "/dev/root" /proc/mounts |grep -q nfs && { + echo "- init nfs -" + exec /sbin/init + } +} + +boot_hook_add preinit_main init_nfs + diff --git a/target/linux/ixp4xx/base-files/etc/preinit.arch b/target/linux/ixp4xx/base-files/etc/preinit.arch deleted file mode 100755 index f52133d841..0000000000 --- a/target/linux/ixp4xx/base-files/etc/preinit.arch +++ /dev/null @@ -1,15 +0,0 @@ -RB_CONFIG="$(grep "RedBoot config" /proc/mtd | cut -d: -f1)" - -for npe in eth0 eth1 eth2 -do - if [ "$(ifconfig $npe 2>/dev/null | grep -c 00:00:00:00:00:00)" == "1" ]; then - ifconfig $npe hw ether $(fconfig -s -r -d /dev/$RB_CONFIG -n npe_"$npe"_esa) - fi -done - -# Some developers should be shot on sight at Zcom/Netgear -# -- Fixup for the WG302v1, need someone with a WAG302v1 to fix that, too - -if [ "$(ifconfig eth0 2>/dev/null | grep -c 00:00:00:00:00:00)" == "1" ]; then - ifconfig eth0 hw ether $(fconfig -s -r -d /dev/$RB_CONFIG -n zcom_npe_esa) -fi diff --git a/target/linux/ixp4xx/base-files/lib/preinit/05_set_ether_mac_ixp4xx b/target/linux/ixp4xx/base-files/lib/preinit/05_set_ether_mac_ixp4xx new file mode 100644 index 0000000000..e19e0ec250 --- /dev/null +++ b/target/linux/ixp4xx/base-files/lib/preinit/05_set_ether_mac_ixp4xx @@ -0,0 +1,23 @@ +#!/bin/sh + +set_ether_mac() { + + RB_CONFIG="$(grep "RedBoot config" /proc/mtd | cut -d: -f1)" + + for npe in eth0 eth1 eth2 + do + if [ "$(ifconfig $npe 2>/dev/null | grep -c 00:00:00:00:00:00)" == "1" ]; then + ifconfig $npe hw ether $(fconfig -s -r -d /dev/$RB_CONFIG -n npe_"$npe"_esa) + fi + done + + # Some developers should be shot on sight at Zcom/Netgear + # -- Fixup for the WG302v1, need someone with a WAG302v1 to fix that, too + + if [ "$(ifconfig eth0 2>/dev/null | grep -c 00:00:00:00:00:00)" == "1" ]; then + ifconfig eth0 hw ether $(fconfig -s -r -d /dev/$RB_CONFIG -n zcom_npe_esa) + fi +} + +boot_hook_add preinit_main set_ether_mac + diff --git a/target/linux/pxcab/base-files/etc/preinit.arch b/target/linux/pxcab/base-files/etc/preinit.arch deleted file mode 100644 index 00db8b4aca..0000000000 --- a/target/linux/pxcab/base-files/etc/preinit.arch +++ /dev/null @@ -1,2 +0,0 @@ -mount -t proc none /proc -grep 'failsafe=' /proc/cmdline > /dev/null && export FAILSAFE=true diff --git a/target/linux/pxcab/base-files/lib/preinit/15_essential_fs_pxcab b/target/linux/pxcab/base-files/lib/preinit/15_essential_fs_pxcab new file mode 100644 index 0000000000..2c607e2608 --- /dev/null +++ b/target/linux/pxcab/base-files/lib/preinit/15_essential_fs_pxcab @@ -0,0 +1,8 @@ +#!/bin/sh + +#!/bin/sh + +do_mount_procfs() { + mount -t proc none /proc +} + diff --git a/target/linux/pxcab/base-files/lib/preinit/45_failsafe_pxcab b/target/linux/pxcab/base-files/lib/preinit/45_failsafe_pxcab new file mode 100644 index 0000000000..6e5636a8cb --- /dev/null +++ b/target/linux/pxcab/base-files/lib/preinit/45_failsafe_pxcab @@ -0,0 +1,14 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +failsafe_wait() { + FAILSAFE= + grep 'failsafe=' /proc/cmdline > /dev/null && FAILSAFE=true && export FAILSAFE + if [ "$FAILSAFE" != "true" ]; then + preinit_net_echo "Please press button now to enter failsafe" + echo -n "Press CTRL-C or " + fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true && export FAILSAFE + fi +} + diff --git a/target/linux/rdc/base-files/etc/preinit.arch b/target/linux/rdc/base-files/etc/preinit.arch deleted file mode 100644 index fd456f8b23..0000000000 --- a/target/linux/rdc/base-files/etc/preinit.arch +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (C) 2009 OpenWrt.org - -. /etc/functions.sh - -insmod r6040 - -kernel=$(grep magic /proc/mtd | awk -F: '{print $1}') -[ -n $kernel ] && hdr=$(dd if=/dev/$kernel count=4 bs=1 2> /dev/null) -[ "$hdr" = "CSYS" ] && config=$(find_mtd_part config) -if [ -n "$config" ]; then - mac0=$(hexdump -n 6 -e '6/1 ":%X"' -s 24583 $config | cut -c2-) - [ "$mac0" = "FF:FF:FF:FF:FF:FF" -o "$mac0" = "0:0:0:0:0:0" ] && unset mac0 - mac1=$(hexdump -n 6 -e '6/1 ":%X"' -s 24589 $config | cut -c2-) - [ "$mac1" = "FF:FF:FF:FF:FF:FF" -o "$mac0" = "0:0:0:0:0:0" ] && unset mac1 -fi -if [ -n $mac0 ]; then - logger -t kernel -p user.info "r6040: Setting MAC for eth0 to $mac0" - ifconfig eth0 hw ether $mac0 -fi -if [ -n $mac1 ]; then - logger -t kernel -p user.info "r6040: Setting MAC for eth1 to $mac1" - ifconfig eth1 hw ether $mac1 -fi diff --git a/target/linux/rdc/base-files/lib/preinit/05_set_ether_mac_rdc b/target/linux/rdc/base-files/lib/preinit/05_set_ether_mac_rdc new file mode 100644 index 0000000000..43823c48ea --- /dev/null +++ b/target/linux/rdc/base-files/lib/preinit/05_set_ether_mac_rdc @@ -0,0 +1,32 @@ +#!/bin/sh +# Copyright (C) 2009 OpenWrt.org + +. /etc/boot.sh + +r6040_module() { + insmod r6040 +} + +set_ether_mac() { + kernel=$(grep magic /proc/mtd | awk -F: '{print $1}') + [ -n $kernel ] && hdr=$(dd if=/dev/$kernel count=4 bs=1 2> /dev/null) + [ "$hdr" = "CSYS" ] && config=$(find_mtd_part config) + if [ -n "$config" ]; then + mac0=$(hexdump -n 6 -e '6/1 ":%X"' -s 24583 $config | cut -c2-) + [ "$mac0" = "FF:FF:FF:FF:FF:FF" -o "$mac0" = "0:0:0:0:0:0" ] && unset mac0 + mac1=$(hexdump -n 6 -e '6/1 ":%X"' -s 24589 $config | cut -c2-) + [ "$mac1" = "FF:FF:FF:FF:FF:FF" -o "$mac0" = "0:0:0:0:0:0" ] && unset mac1 + fi + if [ -n $mac0 ]; then + logger -t kernel -p user.info "r6040: Setting MAC for eth0 to $mac0" + ifconfig eth0 hw ether $mac0 + fi + if [ -n $mac1 ]; then + logger -t kernel -p user.info "r6040: Setting MAC for eth1 to $mac1" + ifconfig eth1 hw ether $mac1 + fi +} + +boot_hook_add preinit_main r6040_module +boot_hook_add preinit_main set_ether_mac + diff --git a/target/linux/x86/base-files/etc/preinit.arch b/target/linux/x86/base-files/etc/preinit.arch deleted file mode 100644 index 00db8b4aca..0000000000 --- a/target/linux/x86/base-files/etc/preinit.arch +++ /dev/null @@ -1,2 +0,0 @@ -mount -t proc none /proc -grep 'failsafe=' /proc/cmdline > /dev/null && export FAILSAFE=true diff --git a/target/linux/x86/base-files/lib/preinit/15_essential_fs_x86 b/target/linux/x86/base-files/lib/preinit/15_essential_fs_x86 new file mode 100644 index 0000000000..ba22849d1e --- /dev/null +++ b/target/linux/x86/base-files/lib/preinit/15_essential_fs_x86 @@ -0,0 +1,8 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +do_mount_procfs() { + mount -t proc none /proc +} + diff --git a/target/linux/x86/base-files/lib/preinit/45_failsafe_x86 b/target/linux/x86/base-files/lib/preinit/45_failsafe_x86 new file mode 100644 index 0000000000..6e5636a8cb --- /dev/null +++ b/target/linux/x86/base-files/lib/preinit/45_failsafe_x86 @@ -0,0 +1,14 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +failsafe_wait() { + FAILSAFE= + grep 'failsafe=' /proc/cmdline > /dev/null && FAILSAFE=true && export FAILSAFE + if [ "$FAILSAFE" != "true" ]; then + preinit_net_echo "Please press button now to enter failsafe" + echo -n "Press CTRL-C or " + fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true && export FAILSAFE + fi +} + diff --git a/target/linux/x86/olpc/base-files/etc/preinit.arch b/target/linux/x86/olpc/base-files/etc/preinit.arch deleted file mode 100644 index f29f0d448b..0000000000 --- a/target/linux/x86/olpc/base-files/etc/preinit.arch +++ /dev/null @@ -1,2 +0,0 @@ -mount -t proc none /proc -grep 'failsafe=' /proc/cmdline && export FAILSAFE=true diff --git a/target/linux/x86/olpc/base-files/lib/preinit/15_essential_fs_x86 b/target/linux/x86/olpc/base-files/lib/preinit/15_essential_fs_x86 new file mode 100644 index 0000000000..be342433d2 --- /dev/null +++ b/target/linux/x86/olpc/base-files/lib/preinit/15_essential_fs_x86 @@ -0,0 +1,9 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +do_mount_procfs() { + mount -t proc none /proc +} + + diff --git a/target/linux/x86/olpc/base-files/lib/preinit/45_failsafe_x86 b/target/linux/x86/olpc/base-files/lib/preinit/45_failsafe_x86 new file mode 100644 index 0000000000..6e5636a8cb --- /dev/null +++ b/target/linux/x86/olpc/base-files/lib/preinit/45_failsafe_x86 @@ -0,0 +1,14 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +failsafe_wait() { + FAILSAFE= + grep 'failsafe=' /proc/cmdline > /dev/null && FAILSAFE=true && export FAILSAFE + if [ "$FAILSAFE" != "true" ]; then + preinit_net_echo "Please press button now to enter failsafe" + echo -n "Press CTRL-C or " + fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true && export FAILSAFE + fi +} + |