Magellan Linux

Diff of /trunk/initscripts/systemd/units/scripts/network.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2382 by niro, Tue Jan 7 12:02:04 2014 UTC revision 2383 by niro, Tue Jan 7 12:13:29 2014 UTC
# Line 22  iface_wait_online() Line 22  iface_wait_online()
22   return 0   return 0
23  }  }
24    
25    iface_has_link()
26    {
27     local interface="$1"
28     local flags
29    
30     [[ -n ${interface} ]] || return 2
31     interface="/sys/class/net/${interface}"
32     [[ -d ${interface} ]] || return 2
33     flags=$(cat ${interface}/flags)
34     echo $((${flags}|0x41)) > ${interface}/flags # 0x41: IFF_UP|IFF_RUNNING
35     [ "$(cat ${interface}/carrier)" = 1 ] || return 1
36    }
37    
38  # read values from files  # read values from files
39  read_value()  read_value()
40  {  {
# Line 469  networking_start() Line 482  networking_start()
482   # setup static or dhcp   # setup static or dhcp
483   case ${NETWORKING} in   case ${NETWORKING} in
484   dhcp|DHCP)   dhcp|DHCP)
485   ${DHCP_PROG} ${DHCP_START} "${iface}" ;;   if iface_has_link "${iface}"
486     then
487     ${DHCP_PROG} ${DHCP_START} "${iface}"
488     else
489     echo "Interface '${iface}' has no link. Not running '${DHCP_PROG}'."
490     fi
491     ;;
492   static|STATIC)   static|STATIC)
493   ifconfig "${iface}" "${IP}" netmask "${NETMASK}" broadcast "${BROADCAST}" ;;   ifconfig "${iface}" "${IP}" netmask "${NETMASK}" broadcast "${BROADCAST}" ;;
494   esac   esac

Legend:
Removed from v.2382  
changed lines
  Added in v.2383