slitaz-boot-scripts diff etc/init.d/network.sh @ rev 271
bootopts.sh: fix lang= option
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue May 31 16:07:05 2011 +0200 (2011-05-31) |
parents | 68435a9c0843 |
children | ae2a29072c7d |
line diff
1.1 --- a/etc/init.d/network.sh Tue Mar 15 06:09:03 2011 +0100 1.2 +++ b/etc/init.d/network.sh Tue May 31 16:07:05 2011 +0200 1.3 @@ -10,8 +10,7 @@ 1.4 . $2 1.5 fi 1.6 1.7 - 1.8 -Boot() { 1.9 +boot() { 1.10 # Set hostname. 1.11 echo -n "Setting hostname..." 1.12 /bin/hostname -F /etc/hostname 1.13 @@ -24,17 +23,16 @@ 1.14 status 1.15 } 1.16 1.17 - 1.18 +# Use ethernet 1.19 eth() { 1.20 -# Use ethernet 1.21 - ifconfig $INTERFACE up 1.22 + ifconfig $INTERFACE up 1.23 } 1.24 1.25 -wifi() { 1.26 - # For wifi. Users just have to enable it through yes and usually 1.27 - # essid any will work and the interface is autodetected. 1.28 +# For wifi. Users just have to enable it through yes and usually 1.29 +# essid any will work and the interface is autodetected. 1.30 +wifi() { 1.31 if [ "$WIFI" = "yes" ] || grep -q "wifi" /proc/cmdline; then 1.32 - ifconfig $INTERFACE down 1.33 + ifconfig $INTERFACE down 1.34 1.35 # Confirm if $WIFI_INTERFACE is the wifi interface 1.36 if [ ! -d /sys/class/net/$WIFI_INTERFACE/wireless ]; then 1.37 @@ -52,22 +50,19 @@ 1.38 iwconfig $WIFI_INTERFACE txpower on 1.39 fi 1.40 status 1.41 - 1.42 + 1.43 [ -n "$WPA_DRIVER" ] || WPA_DRIVER="wext" 1.44 - 1.45 - 1.46 IWCONFIG_ARGS="" 1.47 [ -n "$WIFI_MODE" ] && IWCONFIG_ARGS="$IWCONFIG_ARGS mode $WIFI_MODE" 1.48 [ -n "$WIFI_CHANNEL" ] && IWCONFIG_ARGS="$IWCONFIG_ARGS channel $WIFI_CHANNEL" 1.49 # unencrypted network 1.50 - if [ "$WIFI_KEY" == "" -o "$WIFI_KEY_TYPE" == "none" ]; 1.51 -then 1.52 + if [ "$WIFI_KEY" == "" -o "$WIFI_KEY_TYPE" == "none" ]; then 1.53 iwconfig $WIFI_INTERFACE essid "$WIFI_ESSID" $IWCONFIG_ARGS 1.54 fi 1.55 # encrypted network 1.56 [ -n "$WIFI_KEY" ] && case "$WIFI_KEY_TYPE" in 1.57 wep|WEP) 1.58 - IWCONFIG_ARGS="$IWCONFIG_ARGS key $WIFI_KEY" 1.59 + IWCONFIG_ARGS="$IWCONFIG_ARGS key $WIFI_KEY" 1.60 iwconfig $WIFI_INTERFACE essid "$WIFI_ESSID" $IWCONFIG_ARGS 1.61 # wpa_supplicant can also deal with wep encryption but iwconfig is preferred 1.62 # Tip: Use unquoted strings for hexadecimal key in wep_key0 1.63 @@ -87,9 +82,11 @@ 1.64 #EOF 1.65 # echo "Starting wpa_supplicant for NONE/WEP..." 1.66 # wpa_supplicant -B -W -c/tmp/wpa.conf -D$WPA_DRIVER -i$WIFI_INTERFACE 1.67 - ;; 1.68 - wpa|WPA) cat /etc/wpa_supplicant.conf > /tmp/wpa.conf # load pre-configured multiple profiles 1.69 - cat >> /tmp/wpa.conf <<EOF 1.70 + ;; 1.71 + wpa|WPA) 1.72 + # load pre-configured multiple profiles 1.73 + cat /etc/wpa_supplicant.conf > /tmp/wpa.conf 1.74 + cat >> /tmp/wpa.conf <<EOF 1.75 ctrl_interface=/var/run/wpa_supplicant 1.76 ctrl_interface_group=0 1.77 ap_scan=1 1.78 @@ -103,8 +100,8 @@ 1.79 } 1.80 EOF 1.81 echo "Starting wpa_supplicant for WPA-PSK..." 1.82 - wpa_supplicant -B -W -c/tmp/wpa.conf -D$WPA_DRIVER -i$WIFI_INTERFACE 1.83 - ;; 1.84 + wpa_supplicant -B -W -c/tmp/wpa.conf \ 1.85 + -D$WPA_DRIVER -i$WIFI_INTERFACE ;; 1.86 any|ANY) cat /etc/wpa_supplicant.conf > /tmp/wpa.conf 1.87 cat >> /tmp/wpa.conf <<EOF 1.88 ctrl_interface=/var/run/wpa_supplicant 1.89 @@ -121,16 +118,12 @@ 1.90 } 1.91 EOF 1.92 echo "Starting wpa_supplicant for any key type..." 1.93 - wpa_supplicant -B -W -c/tmp/wpa.conf -D$WPA_DRIVER -i$WIFI_INTERFACE 1.94 - ;; 1.95 + wpa_supplicant -B -W -c/tmp/wpa.conf \ 1.96 + -D$WPA_DRIVER -i$WIFI_INTERFACE ;; 1.97 esac 1.98 - 1.99 rm -f /tmp/wpa.conf 1.100 - 1.101 INTERFACE=$WIFI_INTERFACE 1.102 - 1.103 fi 1.104 - 1.105 } 1.106 1.107 wpa() 1.108 @@ -139,22 +132,22 @@ 1.109 wpa_cli -a$DHCP_SCRIPT -B 1.110 } 1.111 1.112 +# For a dynamic IP with DHCP. 1.113 dhcp() { 1.114 - 1.115 -# For a dynamic IP with DHCP. 1.116 if [ "$DHCP" = "yes" ] ; then 1.117 echo "Starting udhcpc client on: $INTERFACE..." 1.118 - if [ -d /var/run/wpa_supplicant ] && [ "$WIFI" = "yes" ]; then # wpa wireless && wpa_ctrl_open interface is up 1.119 - wpa 1.120 - else # fallback on udhcpc: wep, eth 1.121 - /sbin/udhcpc -b -T 1 -A 12 -i $INTERFACE -p /var/run/udhcpc.$INTERFACE.pid 1.122 + # Is wpa wireless && wpa_ctrl_open interface up ? 1.123 + if [ -d /var/run/wpa_supplicant ] && [ "$WIFI" = "yes" ]; then 1.124 + wpa 1.125 + else # fallback on udhcpc: wep, eth 1.126 + /sbin/udhcpc -b -T 1 -A 12 -i $INTERFACE -p \ 1.127 + /var/run/udhcpc.$INTERFACE.pid 1.128 fi 1.129 fi 1.130 - 1.131 } 1.132 1.133 +# For a static IP. 1.134 static_ip() { 1.135 -# For a static IP. 1.136 if [ "$STATIC" = "yes" ] ; then 1.137 echo "Configuring static IP on $INTERFACE: $IP..." 1.138 /sbin/ifconfig $INTERFACE $IP netmask $NETMASK up 1.139 @@ -193,13 +186,13 @@ 1.140 static_ip 1.141 # change default lxpanel panel iface 1.142 [ -f /etc/lxpanel/default/panels/panel ] \ 1.143 - && sed -i "s/iface=.*/iface=$INTERFACE/" /etc/lxpanel/default/panels/panel 1.144 + && sed -i "s/iface=.*/iface=$INTERFACE/" \ 1.145 + /etc/lxpanel/default/panels/panel 1.146 } 1.147 1.148 - 1.149 # looking for arguments: 1.150 if [ -z "$1" ]; then 1.151 - Boot 1.152 + boot 1.153 Start 1.154 else 1.155 case $1 in 1.156 @@ -217,7 +210,6 @@ 1.157 echo -e " Default configuration file is \033[1m/etc/network.conf\033[0m" 1.158 echo -e " You can specify another configuration file in the second argument:" 1.159 echo -e " \033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart] file.conf" 1.160 - echo "" 1.161 - 1.162 + echo "" ;; 1.163 esac 1.164 fi