Magellan Linux

Diff of /trunk/initscripts/sysvinit/rc/network

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

trunk/magellan-initscripts/rc/network revision 1276 by niro, Fri May 6 22:09:32 2011 UTC trunk/initscripts/sysvinit/rc/network revision 2383 by niro, Tue Jan 7 12:13:29 2014 UTC
# Line 12  Line 12 
12    
13  source /etc/conf.d/rc  source /etc/conf.d/rc
14  source ${rc_functions}  source ${rc_functions}
15    source /etc/conf.d/network
16    
17    iface_wait_online()
18    {
19     local timeout="$1"
20     local iface="$2"
21    
22     (( timeout *= 10 ))
23    
24     while [ ! -e /sys/class/net/${iface} ]
25     do
26     (( timeout-- > 0 )) || return 1
27     sleep 0.1
28     done
29    
30     return 0
31    }
32    
33    iface_has_link()
34    {
35     local interface="$1"
36     local flags
37    
38     [[ -n ${interface} ]] || return 2
39     interface="/sys/class/net/${interface}"
40     [[ -d ${interface} ]] || return 2
41     flags=$(cat ${interface}/flags)
42     echo $((${flags}|0x41)) > ${interface}/flags # 0x41: IFF_UP|IFF_RUNNING
43     [ "$(cat ${interface}/carrier)" = 1 ] || return 1
44    }
45    
46  # read values from files  # read values from files
47  read_value()  read_value()
# Line 96  checkconfig() Line 126  checkconfig()
126   if [[ -z ${NETMASK} ]]   if [[ -z ${NETMASK} ]]
127   then   then
128   rc_echo -n "NETMASK missing in net.${iface}, "   rc_echo -n "NETMASK missing in net.${iface}, "
129   rc_echo "using 255.255.255.0"   rc_echo "using ${DEFAULT_NETMASK}"
130   NETMASK=255.255.255.0   NETMASK="${DEFAULT_NETMASK}"
131   fi   fi
132    
133   if [[ -z ${BROADCAST} ]]   if [[ -z ${BROADCAST} ]]
# Line 111  checkconfig() Line 141  checkconfig()
141   if [[ -z ${DHCP_PROG} ]]   if [[ -z ${DHCP_PROG} ]]
142   then   then
143   rc_echo -n "DHCP_PROG missing in net.${iface},"   rc_echo -n "DHCP_PROG missing in net.${iface},"
144   rc_echo "using default programm /sbin/dhcpcd"   rc_echo "using default programm ${DEFAULT_DHCP_PROG}"
145   DHCP_PROG="/sbin/dhcpcd"   DHCP_PROG="${DEFAULT_DHCP_PROG}"
146   fi   fi
147   [[ -z ${DHCP_START} ]] && DHCP_START="-t 10"   [[ -z ${DHCP_START} ]] && DHCP_START="${DEFAULT_DHCP_START}"
148   [[ -z ${DHCP_STOP} ]] && DHCP_STOP="-k"   [[ -z ${DHCP_STOP} ]] && DHCP_STOP="${DEFAULT_DHCP_STOP}"
149   ;;   ;;
150    
151   esac   esac
# Line 179  config_wireless_wpa() Line 209  config_wireless_wpa()
209   return 1   return 1
210   fi   fi
211    
212   if [ ! -x /sbin/wpa_supplicant ]   if [ ! -x $(type -P wpa_supplicant) ]
213   then   then
214   rc_echo "WPA: wpa_supplicant not installed. Aborting setup."   rc_echo "WPA: wpa_supplicant not installed. Aborting setup."
215   return 1   return 1
# Line 193  config_wireless_wpa() Line 223  config_wireless_wpa()
223   [[ -f /etc/conf.d/wpa_supplicant ]] && source /etc/conf.d/wpa_supplicant   [[ -f /etc/conf.d/wpa_supplicant ]] && source /etc/conf.d/wpa_supplicant
224    
225   # check the configuration   # check the configuration
226   [[ -z ${WIRELESS_WPA_CONFIG} ]] && WIRELESS_WPA_CONFIG=/etc/wpa_supplicant.auto   [[ -z ${WIRELESS_WPA_CONFIG} ]] && WIRELESS_WPA_CONFIG=/etc/wpa_supplicant/wpa_supplicant.auto
227   [[ -z ${WIRELESS_WPA_SKEL} ]] && WIRELESS_WPA_SKEL=/etc/conf.d/wpa_supplicant.skel   [[ -z ${WIRELESS_WPA_SKEL} ]] && WIRELESS_WPA_SKEL=/etc/conf.d/wpa_supplicant.skel
228    
229   # use wext as default driver, do not abort here anymore   # use wext as default driver, do not abort here anymore
# Line 220  config_wireless_wpa() Line 250  config_wireless_wpa()
250   fi   fi
251    
252   # remove old state dir   # remove old state dir
253   [ -d /var/run/wpa_supplicant ] && rm -rf /var/run/wpa_supplicant   [ -d /run/wpa_supplicant ] && rm -rf /run/wpa_supplicant
254    
255   # now run the wpa_supplicant dameon   # now run the wpa_supplicant dameon
256   wpa_supplicant -B \   wpa_supplicant -B \
# Line 355  config_bridge_devices() Line 385  config_bridge_devices()
385   fi   fi
386    
387   # first check for brctl   # first check for brctl
388   if [[ -z $(which brctl) ]]   if [[ -z $(type -P brctl) ]]
389   then   then
390   rc_echo "brctl not found! Please install 'net-misc/bridge-utils'."   rc_echo "brctl not found! Please install 'net-misc/bridge-utils'."
391   return 1   return 1
# Line 459  networking_start() Line 489  networking_start()
489   source ${rc_network_settings}/net.${iface} || exit 1   source ${rc_network_settings}/net.${iface} || exit 1
490   checkconfig   checkconfig
491    
492     # wait until the device is created
493     iface_wait_online 5 "${iface}" || { rc_echo "device '${iface}' does not exist"; continue; }
494    
495   # setup mac   # setup mac
496   if [[ -n ${FORCE_MAC_TO} ]]   if [[ -n ${FORCE_MAC_TO} ]]
497   then   then
# Line 474  networking_start() Line 507  networking_start()
507   fi   fi
508    
509   # now configure wireless_extensions   # now configure wireless_extensions
510   [ -x /usr/sbin/iwconfig ] && setup_wireless_extensions "${iface}"   [ -x $(type -P iwconfig) ] && setup_wireless_extensions "${iface}"
511    
512   rc_print "Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..."   rc_print "Bringing up interface ${COLBLUE}${iface}${COLDEFAULT} ..."
513    
# Line 487  networking_start() Line 520  networking_start()
520   ${CURS_UP}   ${CURS_UP}
521   ${SET_WWCOL}   ${SET_WWCOL}
522   rc_echo "[DHCP]"   rc_echo "[DHCP]"
523   loadproc ${DHCP_PROG} ${DHCP_START} "${iface}"   if iface_has_link "${iface}"
524     then
525     loadproc ${DHCP_PROG} ${DHCP_START} "${iface}"
526     else
527     rc_echo "Interface '${iface}' has no link. Not running '${DHCP_PROG}'."
528     fi
529   ;;   ;;
530   static|STATIC)   static|STATIC)
531   ${CURS_UP}   ${CURS_UP}
# Line 514  networking_start() Line 552  networking_start()
552   then   then
553   rc_print "Setting up all nameserver for ${COLBLUE}${iface}${COLDEFAULT} ..."   rc_print "Setting up all nameserver for ${COLBLUE}${iface}${COLDEFAULT} ..."
554    
555   # whipe out the old one   # wipe out the old one
556   echo "# Generated by the magellan-initscripts for ${iface}" > /etc/resolv.conf   echo "# Generated by the magellan-initscripts for ${iface}" > /etc/resolv.conf
557   # include head   # include head
558   if [ -f /etc/resolv.conf.head ]   if [ -f /etc/resolv.conf.head ]
# Line 610  networking_stop() Line 648  networking_stop()
648   done   done
649    
650   # remove state dir   # remove state dir
651   if [ -d /var/run/wpa_supplicant ]   if [ -d /run/wpa_supplicant ]
652   then   then
653   rm -rf /var/run/wpa_supplicant   rm -rf /run/wpa_supplicant
654   fi   fi
655    
656   # delete user routes   # delete user routes

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