add preinit modularization work by Daniel Dickinson (cshore)
[openwrt/staging/yousong.git] / package / base-files / files / lib / preinit / 10_indicate_preinit
1 #!/bin/sh
2 # Copyright (C) 2006 OpenWrt.org
3 # Copyright (C) 2010 Vertical Communications
4
5 preinit_ip() {
6 # if the preinit interface isn't specified and ifname is set in
7 # preinit.arch use that interface
8 if [ -z "$pi_ifname" ]; then
9 pi_ifname=$ifname
10 fi
11
12 [ -n "$pi_ifname" ] && grep "$pi_ifname" /proc/net/dev >/dev/null && {
13 ifconfig $pi_ifname $pi_ip netmask $pi_netmask broadcast $pi_broadcast up
14 }
15 }
16
17 preinit_ip_deconfig() {
18 [ -n "$pi_ifname" ] && grep "$pi_ifname" /proc/net/dev >/dev/null && {
19 ifconfig $pi_ifname 0.0.0.0 down
20 }
21 }
22
23 preinit_net_echo() {
24 [ -n "$pi_ifname" ] && grep "$pi_ifname" /proc/net/dev >/dev/null && {
25 {
26 [ "$pi_preinit_net_messages" = "y" ] || {
27 [ "$pi_failsafe_net_message" = "true" ] &&
28 [ "$pi_preinit_no_failsafe_netmsg" != "y" ]
29 }
30
31 } && netmsg $pi_broadcast "$1"
32 }
33 }
34
35 preinit_echo() {
36 preinit_net_echo $1
37 echo $1
38 }
39
40 pi_indicate_led() {
41 set_state preinit
42 }
43
44 pi_indicate_preinit() {
45 echo "- preinit -"
46 preinit_net_echo "Doing OpenWRT Preinit\n"
47 pi_indicate_led
48 }
49
50 boot_hook_add preinit_main preinit_ip
51 boot_hook_add preinit_main pi_indicate_preinit
52