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 2305 by niro, Thu Jan 2 13:28:42 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     sleep 0.1
19     done
20    
21     return 0
22    }
23    
24  # read values from files  # read values from files
25  read_value()  read_value()
26  {  {
# Line 85  checkconfig() Line 104  checkconfig()
104   if [[ -z ${NETMASK} ]]   if [[ -z ${NETMASK} ]]
105   then   then
106   echo -n "NETMASK missing in net.${iface}, "   echo -n "NETMASK missing in net.${iface}, "
107   echo "using 255.255.255.0"   echo "using ${DEFAULT_NETMASK}"
108   NETMASK=255.255.255.0   NETMASK="${DEFAULT_NETMASK}"
109   fi   fi
110    
111   if [[ -z ${BROADCAST} ]]   if [[ -z ${BROADCAST} ]]
# Line 100  checkconfig() Line 119  checkconfig()
119   if [[ -z ${DHCP_PROG} ]]   if [[ -z ${DHCP_PROG} ]]
120   then   then
121   echo -n "DHCP_PROG missing in net.${iface},"   echo -n "DHCP_PROG missing in net.${iface},"
122   echo "using default programm /sbin/dhcpcd"   echo "using default programm ${DEFAULT_DHCP_PROG}"
123   DHCP_PROG="/sbin/dhcpcd"   DHCP_PROG="${DEFAULT_DHCP_PROG}"
124   fi   fi
125   [[ -z ${DHCP_START} ]] && DHCP_START="-t 10"   [[ -z ${DHCP_START} ]] && DHCP_START="${DEFAULT_DHCP_START}"
126   [[ -z ${DHCP_STOP} ]] && DHCP_STOP="-k"   [[ -z ${DHCP_STOP} ]] && DHCP_STOP="${DEFAULT_DHCP_STOP}"
127   ;;   ;;
128    
129   esac   esac
# Line 164  config_wireless_wpa() Line 183  config_wireless_wpa()
183   return 1   return 1
184   fi   fi
185    
186   if [ ! -x /sbin/wpa_supplicant ]   if [ ! -x $(type -P wpa_supplicant) ]
187   then   then
188   echo "WPA: wpa_supplicant not installed. Aborting setup."   echo "WPA: wpa_supplicant not installed. Aborting setup."
189   return 1   return 1
# Line 174  config_wireless_wpa() Line 193  config_wireless_wpa()
193   [[ -f /etc/conf.d/wpa_supplicant ]] && source /etc/conf.d/wpa_supplicant   [[ -f /etc/conf.d/wpa_supplicant ]] && source /etc/conf.d/wpa_supplicant
194    
195   # check the configuration   # check the configuration
196   [[ -z ${WIRELESS_WPA_CONFIG} ]] && WIRELESS_WPA_CONFIG=/etc/wpa_supplicant.auto   [[ -z ${WIRELESS_WPA_CONFIG} ]] && WIRELESS_WPA_CONFIG=/etc/wpa_supplicant/wpa_supplicant.auto
197   [[ -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
198    
199   # 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 220  config_wireless_wpa()
220   fi   fi
221    
222   # remove old state dir   # remove old state dir
223   [ -d /var/run/wpa_supplicant ] && rm -rf /var/run/wpa_supplicant   [ -d /run/wpa_supplicant ] && rm -rf /run/wpa_supplicant
224    
225   # now run the wpa_supplicant dameon   # now run the wpa_supplicant dameon
226   wpa_supplicant -B \   wpa_supplicant -B \
# Line 325  config_bridge_devices() Line 344  config_bridge_devices()
344   fi   fi
345    
346   # first check for brctl   # first check for brctl
347   if [[ -z $(which brctl) ]]   if [[ -z $(type -P brctl) ]]
348   then   then
349   echo "brctl not found! Please install 'net-misc/bridge-utils'."   echo "brctl not found! Please install 'net-misc/bridge-utils'."
350   return 1   return 1
# Line 425  networking_start() Line 444  networking_start()
444   source /etc/conf.d/net.${iface} || exit 1   source /etc/conf.d/net.${iface} || exit 1
445   checkconfig   checkconfig
446    
447     # wait until the device is created
448     wait_online 5 "${iface}" || { echo "device '${iface}' does not exist"; continue; }
449    
450   # setup mac   # setup mac
451   if [[ -n ${FORCE_MAC_TO} ]]   if [[ -n ${FORCE_MAC_TO} ]]
452   then   then
# Line 438  networking_start() Line 460  networking_start()
460   fi   fi
461    
462   # now configure wireless_extensions   # now configure wireless_extensions
463   [ -x /usr/sbin/iwconfig ] && setup_wireless_extensions "${iface}"   [ -x $(type -P iwconfig) ] && setup_wireless_extensions "${iface}"
464    
465   # activate the interface   # activate the interface
466   ifconfig "${iface}" up   ifconfig "${iface}" up
# Line 552  networking_stop() Line 574  networking_stop()
574   done   done
575    
576   # remove state dir   # remove state dir
577   if [ -d /var/run/wpa_supplicant ]   if [ -d /run/wpa_supplicant ]
578   then   then
579   rm -rf /var/run/wpa_supplicant   rm -rf /run/wpa_supplicant
580   fi   fi
581    
582   # delete user routes   # delete user routes

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