Magellan Linux

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

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

revision 1378 by niro, Sat Jun 4 22:39:03 2011 UTC revision 2312 by niro, Thu Jan 2 14:21:05 2014 UTC
# Line 2  Line 2 
2  # $Id$  # $Id$
3  # Magellan network configuration script for systemd  # Magellan network configuration script for systemd
4    
5    # get default settings
6    source /etc/conf.d/network
7    
8    wait_online()
9    {
10     local timeout="$1"
11     local iface="$2"
12    
13     (( timeout *= 10 ))
14    
15     while [ ! -e /sys/class/net/${iface} ]
16     do
17     (( timeout-- > 0 )) || return 1
18     echo "waiting 0.1 seconds for device '${iface}' - timeout->'${timeout}'"
19     sleep 0.1
20     done
21    
22     return 0
23    }
24    
25  # read values from files  # read values from files
26  read_value()  read_value()
27  {  {
# Line 85  checkconfig() Line 105  checkconfig()
105   if [[ -z ${NETMASK} ]]   if [[ -z ${NETMASK} ]]
106   then   then
107   echo -n "NETMASK missing in net.${iface}, "   echo -n "NETMASK missing in net.${iface}, "
108   echo "using 255.255.255.0"   echo "using ${DEFAULT_NETMASK}"
109   NETMASK=255.255.255.0   NETMASK="${DEFAULT_NETMASK}"
110   fi   fi
111    
112   if [[ -z ${BROADCAST} ]]   if [[ -z ${BROADCAST} ]]
# Line 100  checkconfig() Line 120  checkconfig()
120   if [[ -z ${DHCP_PROG} ]]   if [[ -z ${DHCP_PROG} ]]
121   then   then
122   echo -n "DHCP_PROG missing in net.${iface},"   echo -n "DHCP_PROG missing in net.${iface},"
123   echo "using default programm /sbin/dhcpcd"   echo "using default programm ${DEFAULT_DHCP_PROG}"
124   DHCP_PROG="/sbin/dhcpcd"   DHCP_PROG="${DEFAULT_DHCP_PROG}"
125   fi   fi
126   [[ -z ${DHCP_START} ]] && DHCP_START="-t 10"   [[ -z ${DHCP_START} ]] && DHCP_START="${DEFAULT_DHCP_START}"
127   [[ -z ${DHCP_STOP} ]] && DHCP_STOP="-k"   [[ -z ${DHCP_STOP} ]] && DHCP_STOP="${DEFAULT_DHCP_STOP}"
128   ;;   ;;
129    
130   esac   esac
# Line 164  config_wireless_wpa() Line 184  config_wireless_wpa()
184   return 1   return 1
185   fi   fi
186    
187   if [ ! -x /sbin/wpa_supplicant ]   if [ ! -x $(type -P wpa_supplicant) ]
188   then   then
189   echo "WPA: wpa_supplicant not installed. Aborting setup."   echo "WPA: wpa_supplicant not installed. Aborting setup."
190   return 1   return 1
# Line 174  config_wireless_wpa() Line 194  config_wireless_wpa()
194   [[ -f /etc/conf.d/wpa_supplicant ]] && source /etc/conf.d/wpa_supplicant   [[ -f /etc/conf.d/wpa_supplicant ]] && source /etc/conf.d/wpa_supplicant
195    
196   # check the configuration   # check the configuration
197   [[ -z ${WIRELESS_WPA_CONFIG} ]] && WIRELESS_WPA_CONFIG=/etc/wpa_supplicant.auto   [[ -z ${WIRELESS_WPA_CONFIG} ]] && WIRELESS_WPA_CONFIG=/etc/wpa_supplicant/wpa_supplicant.auto
198   [[ -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
199    
200   # use wext as default driver, do not abort here anymore   # use wext as default driver, do not abort here anymore
# Line 201  config_wireless_wpa() Line 221  config_wireless_wpa()
221   fi   fi
222    
223   # remove old state dir   # remove old state dir
224   [ -d /var/run/wpa_supplicant ] && rm -rf /var/run/wpa_supplicant   [ -d /run/wpa_supplicant ] && rm -rf /run/wpa_supplicant
225    
226   # now run the wpa_supplicant dameon   # now run the wpa_supplicant dameon
227   wpa_supplicant -B \   wpa_supplicant -B \
# Line 325  config_bridge_devices() Line 345  config_bridge_devices()
345   fi   fi
346    
347   # first check for brctl   # first check for brctl
348   if [[ -z $(which brctl) ]]   if [[ -z $(type -P brctl) ]]
349   then   then
350   echo "brctl not found! Please install 'net-misc/bridge-utils'."   echo "brctl not found! Please install 'net-misc/bridge-utils'."
351   return 1   return 1
# Line 425  networking_start() Line 445  networking_start()
445   source /etc/conf.d/net.${iface} || exit 1   source /etc/conf.d/net.${iface} || exit 1
446   checkconfig   checkconfig
447    
448     # wait until the device is created
449     wait_online 5 "${iface}" || { echo "device '${iface}' does not exist"; continue; }
450    
451   # setup mac   # setup mac
452   if [[ -n ${FORCE_MAC_TO} ]]   if [[ -n ${FORCE_MAC_TO} ]]
453   then   then
# Line 438  networking_start() Line 461  networking_start()
461   fi   fi
462    
463   # now configure wireless_extensions   # now configure wireless_extensions
464   [ -x /usr/sbin/iwconfig ] && setup_wireless_extensions "${iface}"   [ -x $(type -P iwconfig) ] && setup_wireless_extensions "${iface}"
465    
466   # activate the interface   # activate the interface
467   ifconfig "${iface}" up   ifconfig "${iface}" up
# Line 552  networking_stop() Line 575  networking_stop()
575   done   done
576    
577   # remove state dir   # remove state dir
578   if [ -d /var/run/wpa_supplicant ]   if [ -d /run/wpa_supplicant ]
579   then   then
580   rm -rf /var/run/wpa_supplicant   rm -rf /run/wpa_supplicant
581   fi   fi
582    
583   # delete user routes   # delete user routes

Legend:
Removed from v.1378  
changed lines
  Added in v.2312