10_indicate_preinit 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/sh
  2. # Copyright (C) 2006 OpenWrt.org
  3. # Copyright (C) 2010 Vertical Communications
  4. preinit_ip() {
  5. # if the preinit interface isn't specified and ifname is set in
  6. # preinit.arch use that interface
  7. if [ -z "$pi_ifname" ]; then
  8. pi_ifname=$ifname
  9. fi
  10. [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
  11. ip link set dev $pi_ifname up
  12. ip -4 address add $pi_ip/$pi_netmask broadcast $pi_broadcast dev $pi_ifname
  13. }
  14. }
  15. preinit_ip_deconfig() {
  16. [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
  17. ip -4 address flush dev $pi_ifname
  18. ip link set dev $pi_ifname down
  19. }
  20. }
  21. preinit_net_echo() {
  22. [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
  23. {
  24. [ "$pi_preinit_net_messages" = "y" ] || {
  25. [ "$pi_failsafe_net_message" = "true" ] &&
  26. [ "$pi_preinit_no_failsafe_netmsg" != "y" ]
  27. }
  28. } && netmsg $pi_broadcast "$1"
  29. }
  30. }
  31. preinit_echo() {
  32. preinit_net_echo $1
  33. echo $1
  34. }
  35. pi_indicate_preinit() {
  36. preinit_net_echo "Doing OpenWrt Preinit\n"
  37. set_state preinit
  38. }
  39. boot_hook_add preinit_main preinit_ip
  40. boot_hook_add preinit_main pi_indicate_preinit