slitaz-tools diff tinyutils/netbox @ rev 226

netbox: simplify wifi tab, add firmware install
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Jul 10 21:15:09 2008 +0000 (2008-07-10)
parents cc5a810e2c09
children 74935d005590
line diff
     1.1 --- a/tinyutils/netbox	Tue Jul 08 08:39:26 2008 +0000
     1.2 +++ b/tinyutils/netbox	Thu Jul 10 21:15:09 2008 +0000
     1.3 @@ -450,9 +450,8 @@
     1.4      </frame>'
     1.5  NET_BOX="$NET_BOX$tmp"
     1.6  tmp='<frame Wireless>
     1.7 -    <notebook labels="Interface|Extra parameters|WPA'
     1.8 +    <notebook labels="Interface|Extra parameters'
     1.9  [ -d /lib/modules/`uname -r`/kernel/drivers/net/wireless ] && tmp="$tmp|Kernel Modules"
    1.10 -[ -x /usr/sbin/ndiswrapper ] && tmp="$tmp|Ndiswrapper"
    1.11  tmp2='">
    1.12        <vbox>
    1.13        <hbox>
    1.14 @@ -464,13 +463,29 @@
    1.15            <variable>WIFI_INTERFACE</variable>
    1.16          </entry>
    1.17          <text use-markup="true">
    1.18 -          <label>"<b>ESSID       :</b>"</label>
    1.19 +          <label>"<b>ESSID :</b>"</label>
    1.20          </text>
    1.21  	<combobox>'
    1.22  . /etc/network.conf
    1.23  tmp2="$tmp2<item>$WIFI_ESSID</item>$ESSIDS"
    1.24  tmp3='</combobox>
    1.25        </hbox>
    1.26 +      <hbox>
    1.27 +        <text use-markup="true">
    1.28 +          <label>"<b>Key :</b>"</label>
    1.29 +        </text>
    1.30 +        <entry>
    1.31 +          <input>. /etc/network.conf; echo "$WIFI_KEY"</input>
    1.32 +          <variable>WIFI_KEY</variable>
    1.33 +        </entry>
    1.34 +	<combobox>
    1.35 +	  <item>none</item>
    1.36 +	  <item>WEP</item>
    1.37 +	  <item>WPA</item>
    1.38 +	  <item>any</item>
    1.39 +          <variable>WIFI_KEY_TYPE</variable>
    1.40 +	</combobox>
    1.41 +      </hbox>
    1.42        </vbox>
    1.43        <vbox>
    1.44        <hbox>
    1.45 @@ -492,85 +507,10 @@
    1.46  done
    1.47  tmp3='</combobox>
    1.48        </hbox>
    1.49 -      <hbox>
    1.50 -        <text use-markup="true">
    1.51 -          <label>"<b>Key        :</b>"</label>
    1.52 -        </text>
    1.53 -        <entry>
    1.54 -          <input>. /etc/network.conf; echo "$WIFI_KEY"</input>
    1.55 -          <variable>WIFI_KEY</variable>
    1.56 -        </entry>
    1.57 -      </hbox>
    1.58        </vbox>'
    1.59  tmp="$tmp$tmp2$tmp3"
    1.60  tmp2='<vbox>
    1.61        <hbox>
    1.62 -        <text use-markup="true">
    1.63 -          <label>"<b>WPA_OPTIONS</b>"</label>
    1.64 -        </text>
    1.65 -        <entry editable="false">'
    1.66 -[ -n "$WPA_OPTIONS" ] && tmp2="$tmp2<default>$WPA_OPTIONS</default>"
    1.67 -tmp3='
    1.68 -          <variable>WPA_OPTS</variable>
    1.69 -        </entry>
    1.70 -        <button>
    1.71 -          <input file icon="help"></input>
    1.72 -	  <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x30 -title "wpa_supplicant help (q to quit)" -e "wpa_supplicant --help | less"</action>
    1.73 -        </button>
    1.74 -        <button>
    1.75 -          <input file icon="accessories-text-editor"></input>
    1.76 -          <action type="lauch">leafpad /etc/daemons.conf</action>
    1.77 -        </button>
    1.78 -      </hbox>
    1.79 -      <hbox>
    1.80 -        <text use-markup="true">
    1.81 -          <label>"<b>Configuration:</b>"</label>
    1.82 -        </text>
    1.83 -        <entry editable="false">
    1.84 -          <default>/etc/wpa_supplicant.conf</default>
    1.85 -          <variable>WPA_CONF</variable>
    1.86 -        </entry>
    1.87 -        <button>
    1.88 -          <input file icon="accessories-text-editor"></input>
    1.89 -          <action type="lauch">leafpad $WPA_CONF</action>
    1.90 -        </button>
    1.91 -      </hbox>
    1.92 -      <hbox>
    1.93 -        <button>
    1.94 -          <label>Start WPA</label>
    1.95 -          <input file icon="forward"></input>
    1.96 -          <action>sed -i "s/RUN_DAEMONS=\"\(.*\)wpa_supplicant \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
    1.97 -          <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"wpa_supplicant \1\"/" /etc/rcS.conf</action>
    1.98 -          <action>/etc/init.d/wpa_supplicant start</action>
    1.99 -        </button>
   1.100 -        <button>
   1.101 -          <label>Stop WPA</label>
   1.102 -          <input file icon="stop"></input>
   1.103 -          <action>sed -i "s/RUN_DAEMONS=\"\(.*\)wpa_supplicant \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
   1.104 -          <action>/etc/init.d/wpa_supplicant stop</action>
   1.105 -        </button>
   1.106 -      </hbox>
   1.107 -      </vbox>'
   1.108 -[ -x /usr/bin/wpa_supplicant ] && tmp="$tmp$tmp2$tmp3"
   1.109 -tmp2='<vbox>
   1.110 -      <hbox>
   1.111 -      <text wrap="true" width-chars="64" use-markup="true">
   1.112 -        <label>
   1.113 -"<i>The package <b>wpa_supplicant</b> is not yet installed</i>"
   1.114 -        </label>
   1.115 -      </text>
   1.116 -      <button>
   1.117 -        <input file icon="go-jump"></input>
   1.118 -	<label>Install</label>
   1.119 -        <action>[ -f /var/lib/tazpkg/packages.list ] || tazpkg recharge</action>
   1.120 -	<action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x17 -title "wpa_supplicant install" -e "tazpkg get-install wpa_supplicant ; echo -e "----\n\nENTER to continue..." && read close"</action>
   1.121 -        <action type="exit">Exit</action>
   1.122 -      </button>
   1.123 -      </hbox>
   1.124 -      </vbox>'
   1.125 -[ -x /usr/bin/wpa_supplicant ] || tmp="$tmp$tmp2"
   1.126 -tmp2='<vbox>
   1.127 -      <hbox>
   1.128          <button>
   1.129            <label>Load</label>
   1.130            <input file icon="forward"></input>
   1.131 @@ -593,13 +533,28 @@
   1.132          <input file icon="computer"></input>
   1.133  	  <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x25 -title "Modules (q to quit)" -e "lsmod | less"</action>
   1.134          </button>
   1.135 +      </hbox>'
   1.136 +tmp2="$tmp2$tmp3"
   1.137 +tmp3=$(for i in /usr/bin/get*firmware; do [ -x $i ] || continue; [ -d /var/lib/tazpkg/installed/${i#/usr/bin/get-} ] && continue; echo "<item>${i#/usr/bin/get-}</item>"; done)
   1.138 +[ -n "$tmp3" ] && tmp3="
   1.139 +      <hbox>
   1.140 +        <text use-markup=\"true\">
   1.141 +          <label>\"<b>Firmware :</b>\"</label>
   1.142 +        </text>
   1.143 +        <combobox><variable>FIRMWARE</variable>$tmp3</combobox>
   1.144 +      <button>
   1.145 +        <label>Install</label>
   1.146 +        <input file icon=\"go-jump\"></input>
   1.147 +	<action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x25 -title \"Install \$FIRMWARE\" -e \"get-\$FIRMWARE\"</action>
   1.148 +      </button>
   1.149        </hbox>
   1.150 -      </vbox>'
   1.151 -[ -d /lib/modules/`uname -r`/kernel/drivers/net/wireless ] && tmp="$tmp$tmp2$tmp3"
   1.152 -tmp2='<vbox>
   1.153 +"
   1.154 +tmp2="$tmp2$tmp3"
   1.155 +tmp3=""
   1.156 +[ -x /usr/sbin/ndiswrapper ] && tmp3='
   1.157        <hbox>
   1.158          <text use-markup="true">
   1.159 -          <label>"<b>Drivers :</b>"</label>
   1.160 +          <label>"<b>Ndiswrapper drivers :</b>"</label>
   1.161          </text>
   1.162          <entry>
   1.163            <input>. /etc/network.conf; echo "$NDISWRAPPER_DRIVERS"</input>
   1.164 @@ -613,26 +568,32 @@
   1.165  	  <action>modprobe ndiswrapper</action>
   1.166          </button>
   1.167        </hbox>
   1.168 -      </vbox>'
   1.169 -[ -x /usr/sbin/ndiswrapper ] && tmp="$tmp$tmp2"
   1.170 +'
   1.171 +tmp3="$tmp3</vbox>"
   1.172 +[ -d /lib/modules/`uname -r`/kernel/drivers/net/wireless ] && tmp="$tmp$tmp2$tmp3"
   1.173  tmp2='</notebook>
   1.174        <hbox>
   1.175          <button>
   1.176            <label>Start</label>
   1.177            <input file icon="forward"></input>
   1.178 +	  <action>[ "$WIFI_KEY_TYPE" = "WPA" -a ! -x /usr/bin/wpa_supplicant ] && xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x17 -title "wpa_supplicant install" -e "tazpkg get-install wpa_supplicant ; echo -e "----\n\nENTER to continue..." && read close"</action>
   1.179            <action>sed -i s/`cat /etc/network.conf | grep ^WIFI_INTERFACE=`/WIFI_INTERFACE=\"$WIFI_INTERFACE\"/ /etc/network.conf</action>
   1.180            <action>sed -i s/`cat /etc/network.conf | grep ^WIFI_ESSID=`/WIFI_ESSID=\"$WIFI_ESSID\"/ /etc/network.conf</action>
   1.181            <action>sed -i s/`cat /etc/network.conf | grep ^WIFI_KEY=`/WIFI_KEY=\"$WIFI_KEY\"/ /etc/network.conf</action>
   1.182 +          <action>sed -i s/`cat /etc/network.conf | grep ^WIFI_KEY_TYPE=`/WIFI_KEY_TYPE=\"$WIFI_KEY_TYPE\"/ /etc/network.conf</action>
   1.183            <action>sed -i s/`cat /etc/network.conf | grep ^WIFI_MODE=`/WIFI_MODE=\"$WIFI_MODE\"/ /etc/network.conf</action>
   1.184            <action>sed -i s/`cat /etc/network.conf | grep ^WIFI_CHANNEL=`/WIFI_CHANNEL=\"$WIFI_CHANNEL\"/ /etc/network.conf</action>
   1.185            <action>[ -s /var/run/udhcpc.$WIFI_INTERFACE.pid ] && kill `cat /var/run/udhcpc.$WIFI_INTERFACE.pid`</action>
   1.186            <action>ifconfig $WIFI_INTERFACE down</action>
   1.187 +          <action>iwconfig $WIFI_INTERFACE txpower on</action>
   1.188            <action>/etc/init.d/network.sh</action>
   1.189          </button>
   1.190          <button>
   1.191            <label>Stop</label>
   1.192            <input file icon="stop"></input>
   1.193 +          <action>[ -x /etc/init.d/wpa_supplicant ] && /etc/init.d/wpa_supplicant stop</action>
   1.194            <action>ifconfig $WIFI_INTERFACE down</action>
   1.195 +          <action>iwconfig $WIFI_INTERFACE txpower off</action>
   1.196            <action>[ -s /var/run/udhcpc.$WIFI_INTERFACE.pid ] && kill `cat /var/run/udhcpc.$WIFI_INTERFACE.pid`</action>
   1.197          </button>
   1.198        </hbox>