summaryrefslogtreecommitdiffstats
path: root/package/base-files/files/lib/preinit/10_indicate_preinit
blob: 4a0109cc1736daf550f5ff17ea59c2e17a61841e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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