wok rev 1123

nomad nomadbox, tool to configure multiple wifi access points
author Pierre-Jean Fichet <sygne@ombres.eu>
date Mon Jul 21 20:36:23 2008 +0200 (2008-07-21)
parents a08b2e53cf96
children 5de14ce3ba76
files nomad/process.log nomad/receipt nomad/stuff/nomad nomad/stuff/nomad.conf nomad/stuff/nomadbox nomad/taz/nomad-0.1/files.list nomad/taz/nomad-0.1/fs/etc/nomad.conf nomad/taz/nomad-0.1/fs/usr/sbin/nomad nomad/taz/nomad-0.1/fs/usr/sbin/nomadbox nomad/taz/nomad-0.1/md5sum nomad/taz/nomad-0.1/receipt
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/nomad/process.log	Mon Jul 21 20:36:23 2008 +0200
     1.3 @@ -0,0 +1,5 @@
     1.4 +date 20080721 20:20:43
     1.5 +package nomad (compile)
     1.6 +no compile_rules
     1.7 +executing genpkg_rules
     1.8 +nomad-0.1.tazpkg (done)
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/nomad/receipt	Mon Jul 21 20:36:23 2008 +0200
     2.3 @@ -0,0 +1,21 @@
     2.4 +# SliTaz package receipt.
     2.5 +
     2.6 +PACKAGE="nomad"
     2.7 +VERSION="0.1"
     2.8 +CATEGORY="extra"
     2.9 +SHORT_DESC="user friendly wifi configure for nomads."
    2.10 +MAINTAINER="sygne@ombres.eu"
    2.11 +DEPENDS="gtkdialog wireless_tools"
    2.12 +
    2.13 +
    2.14 +# Rules to gen a SliTaz package suitable for Tazpkg.
    2.15 +genpkg_rules()
    2.16 +{
    2.17 +	mkdir -p $fs/usr/sbin
    2.18 +	cp -a stuff/nomad $fs/usr/sbin/
    2.19 +	cp -a stuff/nomadbox $fs/usr/sbin/
    2.20 +
    2.21 +	mkdir $fs/etc
    2.22 +	cp -a stuff/nomad.conf $fs/etc/
    2.23 +}
    2.24 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/nomad/stuff/nomad	Mon Jul 21 20:36:23 2008 +0200
     3.3 @@ -0,0 +1,131 @@
     3.4 +#! /bin/sh
     3.5 +# nomad: configure wifi and change acces point easily.
     3.6 +
     3.7 +# Copyright (C) <2008>  <Pierre-Jean Fichet> <sygnes@ombres.eu>
     3.8 +#
     3.9 +# This program is free software: you can redistribute it and/or modify
    3.10 +# it under the terms of the GNU General Public License as published by
    3.11 +# the Free Software Foundation, either version 3 of the License, or
    3.12 +# (at your option) any later version.
    3.13 +#
    3.14 +# This program is distributed in the hope that it will be useful,
    3.15 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.16 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.17 +# GNU General Public License for more details.
    3.18 +#
    3.19 +# You should have received a copy of the GNU General Public License
    3.20 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    3.21 +
    3.22 +
    3.23 +CONFIG="/etc/nomad.conf"
    3.24 +
    3.25 +. $CONFIG
    3.26 +. /etc/init.d/rc.functions
    3.27 +
    3.28 +
    3.29 +case "$1" in
    3.30 +	# we want to configure au new interface
    3.31 +	new)
    3.32 +		TYPE="wifi"
    3.33 +		WIFI_INTERFACE="$2"
    3.34 +		ESSID="$3"
    3.35 +		KEYTYPE="$4"
    3.36 +		KEY="$5"
    3.37 +		DRIVER="$6"
    3.38 +		if [ "$KEYTYPE" = "wpa" ]; then
    3.39 +			WPA="
    3.40 +ap_scan=1
    3.41 +network={
    3.42 +	ssid=\"$ESSID\"
    3.43 +	scan_ssid=1
    3.44 +	proto=WPA
    3.45 +	key_mgmt=WPA-PSK
    3.46 +	psk=\"$KEY\"
    3.47 +	priority=5
    3.48 +}"
    3.49 +		fi
    3.50 +	;;
    3.51 +
    3.52 +	# we want to poweroff wifi
    3.53 +	stop)
    3.54 +		echo -n "pidof wpa_supplicant: "
    3.55 +		if pidof wpa_supplicant; then
    3.56 +			echo -n "stopping wpa_supplicant..."
    3.57 +			killall wpa_supplicant
    3.58 +			status
    3.59 +		else
    3.60 +			echo "None"
    3.61 +		fi
    3.62 +		echo -n "power off wifi..."
    3.63 +		iwconfig $WIFI_INTERFACE txpower off
    3.64 +		status
    3.65 +	;;
    3.66 +
    3.67 +
    3.68 +	*)
    3.69 +	# we want to join a known access point
    3.70 +	if [ "$1" != "" ] && grep -q "$1() {" $CONFIG ; then
    3.71 +		$1	# here we launch the function to set variables
    3.72 +	# we don't know how to use nomad
    3.73 +	else
    3.74 +		echo -n -e "\033[01musage:\033[0m `basename $0` ["
    3.75 +		for line in `grep "() {" $CONFIG | sed "/#.*/d" | sed -e "s/() {//g"`
    3.76 +			do
    3.77 +			echo -n "$line|"
    3.78 +			done
    3.79 +		echo -n "stop]"
    3.80 +		echo ""
    3.81 +		echo -e "\033[1mOr   :\033[0m `basename $0` new \
    3.82 +WIFI_INTERFACE ESSID KEYTYPE KEY DRIVER"
    3.83 +    	echo "	KEYTYPE is: wpa or wep"
    3.84 +    	echo "	DRIVER is wext or another-wpa_supplicant-driver"
    3.85 +		echo ""
    3.86 +		echo -e "	But first, you have to edit \033[1m/etc/nomad.conf\033[0m "
    3.87 +		echo ""
    3.88 +		echo -e "You can also use \033[1mnomadbox\033[0m, if you want a graphical interface for nomad"
    3.89 +		echo ""
    3.90 +		exit 1
    3.91 +	fi
    3.92 +	;;
    3.93 +esac
    3.94 +
    3.95 +
    3.96 +#Si ethernet
    3.97 +if [ "$TYPE" = "ethernet" ]; then
    3.98 +	if [ "$DHCP" = "yes" ] ; then
    3.99 +		echo "Starting udhcpc client on: $INTERFACE... "
   3.100 +		/sbin/udhcpc -b -i $INTERFACE -p /var/run/udhcpc.$INTERFACE.pid
   3.101 +		status
   3.102 +	fi
   3.103 +	# For a static IP.
   3.104 +	if [ "$STATIC" = "yes" ] ; then
   3.105 +		echo -n "Configuring static IP on $INTERFACE: $IP... "
   3.106 +		/sbin/ifconfig $INTERFACE $IP netmask $NETMASK up
   3.107 +		/sbin/route add default gateway $GATEWAY
   3.108 +		status
   3.109 +		# Multi-DNS server in $DNS_SERVER.
   3.110 +		/bin/mv /etc/resolv.conf /tmp/resolv.conf.$$
   3.111 +		for NS in $DNS_SERVER
   3.112 +		do
   3.113 +			echo "nameserver $NS" >> /etc/resolv.conf
   3.114 +		done
   3.115 +	fi
   3.116 +	
   3.117 +#si wifi		
   3.118 +elif [ "$TYPE" = "wifi" ]; then
   3.119 +	iwconfig $WIFI_INTERFACE txpower on
   3.120 +	status
   3.121 +	iwconfig $WIFI_INTERFACE essid $ESSID
   3.122 +	if [ -n "$WPA" ]; then
   3.123 +		echo "$WPA" >/tmp/wpa.conf
   3.124 +		echo "starting wpa_supplicant for $INTERFACE..."
   3.125 +		wpa_supplicant -B -w -c/tmp/wpa.conf -D$DRIVER -i$WIFI_INTERFACE
   3.126 +		status
   3.127 +		rm  /tmp/wpa.conf
   3.128 +	elif [ -n "$KEY" ]; then
   3.129 +		iwconfig $WIFI_INTERFACE key $KEY
   3.130 +	fi
   3.131 +	/sbin/udhcpc -b -i $WIFI_INTERFACE -p /var/run/udhcpc.$WIFI_INTERFACE.pid
   3.132 +fi
   3.133 +
   3.134 +exit 0
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/nomad/stuff/nomad.conf	Mon Jul 21 20:36:23 2008 +0200
     4.3 @@ -0,0 +1,42 @@
     4.4 +## Configuration of nomad.
     4.5 +## You can specify as any places to connect as you want.
     4.6 +## Nomad will recognize them if they follow this format:
     4.7 +
     4.8 +########################################################################
     4.9 +# Name_I_want() {
    4.10 +#	BOOT="yes" or "no"
    4.11 +#	TYPE="wifi" or "ethernet"
    4.12 +#
    4.13 +#	#if ethernet:
    4.14 +#	DHCP="yes" or "no"
    4.15 +#	STATIC="yes" or "no"
    4.16 +#		IP="192.168.0.6
    4.17 +#		GATEWAY="192.168.0.1"
    4.18 +#		DNS_SERVER="192.168.0.1"
    4.19 +#
    4.20 +#	#if wifi:
    4.21 +#	ESSID="MY-ESSID"
    4.22 +#		#if wpa (need wpa_supplicant):
    4.23 +#		DRIVER="wext" or "my-wpa-driver"
    4.24 +#		WPA='	#my wpa_supplicant configuration, ex:
    4.25 +#				ap_scan=1
    4.26 +#				network={
    4.27 +#					ssid="SSID-WICH-NEED-WPA"
    4.28 +#					scan_ssid=1
    4.29 +#					proto=WPA
    4.30 +#					key_mgmt=WPA-PSK
    4.31 +#					psk=52b72d55b8ca0913c5339a2f
    4.32 +#					priority=5
    4.33 +#					}'
    4.34 +#		#if wep:
    4.35 +#		KEY="my-wep-key"
    4.36 +# }
    4.37 +########################################################################
    4.38 +
    4.39 +
    4.40 +## first, we have to say which interface is ethernet, which is wifi:
    4.41 +INTERFACE="eth0"
    4.42 +WIFI_INTERFACE="wlan0"
    4.43 +
    4.44 +## place here your differents access points:
    4.45 +
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/nomad/stuff/nomadbox	Mon Jul 21 20:36:23 2008 +0200
     5.3 @@ -0,0 +1,195 @@
     5.4 +#! /bin/sh
     5.5 +# nomad: configure wifi and change acces point easily -- gtkdialog version.
     5.6 +
     5.7 +# Copyright (C) <2008>  <Pierre-Jean Fichet> <sygnes@ombres.eu>
     5.8 +#
     5.9 +# This program is free software: you can redistribute it and/or modify
    5.10 +# it under the terms of the GNU General Public License as published by
    5.11 +# the Free Software Foundation, either version 3 of the License, or
    5.12 +# (at your option) any later version.
    5.13 +#
    5.14 +# This program is distributed in the hope that it will be useful,
    5.15 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.16 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    5.17 +# GNU General Public License for more details.
    5.18 +#
    5.19 +# You should have received a copy of the GNU General Public License
    5.20 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    5.21 +
    5.22 +. /etc/nomad.conf
    5.23 +
    5.24 +for line in `grep "() {" /etc/nomad.conf | sed "/#.*/d" | sed -e "s/() {//g"`
    5.25 +	do
    5.26 +	ITEM="<item>$line</item>"
    5.27 +	ITEMS="$ITEMS$ITEM"
    5.28 +	done
    5.29 +
    5.30 +for linessid in `iwlist $WIFI_INTERFACE scanning | grep "ESSID" | grep -v "<hidden>" | sed -n 's/ESSID:"//p' | sed -n 's/"//p'`
    5.31 +	do
    5.32 +	ESSID="<item>$linessid</item>"
    5.33 +	ESSIDS="$ESSIDS$ESSID"
    5.34 +	done
    5.35 +
    5.36 +export IWCONFIG='
    5.37 +<window title="Wireless status" icon-name="network-wireless">
    5.38 +  <vbox>
    5.39 +    <text use-markup="true">
    5.40 +      <label>"<b>Wireless status</b>"</label>
    5.41 +    </text>
    5.42 +    <frame Iwconfig>
    5.43 +      <text wrap="false" width-chars="58">
    5.44 +        <input>iwconfig 2>&1</input>
    5.45 +      </text>
    5.46 +    </frame>
    5.47 +    <hbox>
    5.48 +      <button>
    5.49 +        <input file icon="exit"></input>
    5.50 +        <action type="closewindow">IWCONFIG</action>
    5.51 +      </button>
    5.52 +    </hbox>
    5.53 +  </vbox>
    5.54 +</window>
    5.55 +'
    5.56 +
    5.57 +export SCAN="
    5.58 +<window title=\"Wireless Scan\" icon-name=\"network-wireless\">
    5.59 +  <vbox>
    5.60 +    <text use-markup=\"true\">
    5.61 +      <label>\"<b>Scan for wifi access points</b>\"</label>
    5.62 +    </text>
    5.63 +    <frame iwlist scan>
    5.64 +      <text use-markup=\"false\">
    5.65 +      <input>iwlist $WIFI_INTERFACE scanning | grep \"ESSID\|Encryption\|Quality\" | sed -e \"s/^ *ESSID/ESSID/g\" 2>&1</input>
    5.66 +      </text>
    5.67 +    </frame>
    5.68 +    <hbox>
    5.69 +      <button>
    5.70 +        <input file icon=\"exit\"></input>
    5.71 +        <action type=\"closewindow\">SCAN</action>
    5.72 +      </button>
    5.73 +    </hbox>
    5.74 +  </vbox>
    5.75 +</window>
    5.76 +"
    5.77 +
    5.78 +
    5.79 +
    5.80 +
    5.81 +
    5.82 +export NOMADBOX="
    5.83 +<window title=\"NomadBox\" icon-name=\"network-wireless\">
    5.84 + 	<vbox>
    5.85 +		<text use-markup=\"true\">
    5.86 +			<label>\"<b>Slitaz NomadBox</b>\"</label>
    5.87 +		</text>
    5.88 +	    <text wrap=\"true\" width-chars=\"52\" use-markup=\"true\">
    5.89 +			<label>\"Connect to a wireless station.\"</label>
    5.90 +    	</text>
    5.91 +
    5.92 +	<notebook labels=\"Connection|Configuration\">    
    5.93 +		<frame Choose where to connect>
    5.94 +			<vbox>
    5.95 +			<hbox>
    5.96 +				<text use-markup=\"true\">
    5.97 +					<label>\"<b>Interface:</b>\"</label>
    5.98 +				</text>
    5.99 +				<combobox>
   5.100 +					<variable>INTERFACE</variable>
   5.101 +					$ITEMS
   5.102 +				</combobox>
   5.103 +				<button>
   5.104 +					<label>Start</label>
   5.105 +					<input file icon=\"forward\"></input>
   5.106 +					<action>nomad \$INTERFACE</action>
   5.107 +				</button>
   5.108 +			</hbox>
   5.109 +				<hbox>
   5.110 +					<button>
   5.111 +						<label>Wifi On</label>
   5.112 +						<input file icon=\"forward\"></input>
   5.113 +						<action>iwconfig \$WIFI_INTERFACE txpower auto</action>
   5.114 +					</button>
   5.115 +					<button>
   5.116 +						<label>Wifi Stop</label>
   5.117 +						<input file icon=\"stop\"></input>
   5.118 +						<action>nomad stop</action>
   5.119 +					</button>
   5.120 +				</hbox>
   5.121 +			</vbox>
   5.122 +		</frame>
   5.123 +		<frame Configure a new wifi connection>
   5.124 +		<vbox>
   5.125 +			
   5.126 +			<hbox>
   5.127 +				<text><label>\"Interface	:\"</label></text>
   5.128 +				<combobox>
   5.129 +					<variable>NEWINTERFACE</variable>
   5.130 +					<item>wlan0</item>
   5.131 +					<item>eth1</item>
   5.132 +					<item>eth0</item>
   5.133 +					<item></item>
   5.134 +				</combobox>
   5.135 +			</hbox>
   5.136 +			<hbox>
   5.137 +				<text><label>\"ESSID :\"</label></text>
   5.138 +				<combobox>
   5.139 +					<variable>NEWESSID</variable>
   5.140 +					<item></item>
   5.141 +					$ESSIDS
   5.142 +				</combobox>
   5.143 +			</hbox>
   5.144 +
   5.145 +			<hbox>
   5.146 +				<text>
   5.147 +				<label>\"Key type :\"</label>
   5.148 +				</text>
   5.149 +				<combobox>
   5.150 +					<variable>NEWKEYTYPE</variable>
   5.151 +					<item>Without Key</item>
   5.152 +					<item>wep</item>
   5.153 +					<item>wpa</item>
   5.154 +				</combobox>
   5.155 +			</hbox>
   5.156 +			<hbox>
   5.157 +				<text>
   5.158 +				<label>\"wpa-Driver :\"</label>
   5.159 +				</text>
   5.160 +				<combobox>
   5.161 +					<variable>DRIVER</variable>
   5.162 +					<item>wext</item>
   5.163 +					<item></item>
   5.164 +				</combobox>
   5.165 +			</hbox>
   5.166 +			<hbox>
   5.167 +				<text><label>\"Key    :\"</label></text>
   5.168 +				<entry>	
   5.169 +					<variable>NEWKEY</variable>
   5.170 +				</entry>
   5.171 +			</hbox>
   5.172 +			<hbox>
   5.173 +				<button>
   5.174 +					<label>Iwconfig</label>
   5.175 +					<input file icon=\"computer\"></input>
   5.176 +					<action type=\"launch\">IWCONFIG</action>
   5.177 +				</button>
   5.178 +				<button>
   5.179 +					<label>Scan</label>
   5.180 +					<input file icon=\"network-wireless\"></input>
   5.181 +					<action type=\"launch\">SCAN</action>
   5.182 +				</button>
   5.183 +				<button>
   5.184 +					<label>Start</label>
   5.185 +					<input file icon=\"forward\"></input>
   5.186 +					<action>nomad new \$NEWINTERFACE \$NEWESSID \$NEWKEYTYPE \$NEWKEY \$DRIVER</action>
   5.187 +				</button>
   5.188 +			</hbox>
   5.189 +			</vbox>
   5.190 +			</frame>
   5.191 +	</notebook>
   5.192 +	</vbox>
   5.193 +</window>
   5.194 +"
   5.195 + 
   5.196 +gtkdialog --program=NOMADBOX
   5.197 +
   5.198 +exit 0
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/nomad/taz/nomad-0.1/files.list	Mon Jul 21 20:36:23 2008 +0200
     6.3 @@ -0,0 +1,3 @@
     6.4 +/etc/nomad.conf
     6.5 +/usr/sbin/nomadbox
     6.6 +/usr/sbin/nomad
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/nomad/taz/nomad-0.1/fs/etc/nomad.conf	Mon Jul 21 20:36:23 2008 +0200
     7.3 @@ -0,0 +1,42 @@
     7.4 +## Configuration of nomad.
     7.5 +## You can specify as any places to connect as you want.
     7.6 +## Nomad will recognize them if they follow this format:
     7.7 +
     7.8 +########################################################################
     7.9 +# Name_I_want() {
    7.10 +#	BOOT="yes" or "no"
    7.11 +#	TYPE="wifi" or "ethernet"
    7.12 +#
    7.13 +#	#if ethernet:
    7.14 +#	DHCP="yes" or "no"
    7.15 +#	STATIC="yes" or "no"
    7.16 +#		IP="192.168.0.6
    7.17 +#		GATEWAY="192.168.0.1"
    7.18 +#		DNS_SERVER="192.168.0.1"
    7.19 +#
    7.20 +#	#if wifi:
    7.21 +#	ESSID="MY-ESSID"
    7.22 +#		#if wpa (need wpa_supplicant):
    7.23 +#		DRIVER="wext" or "my-wpa-driver"
    7.24 +#		WPA='	#my wpa_supplicant configuration, ex:
    7.25 +#				ap_scan=1
    7.26 +#				network={
    7.27 +#					ssid="SSID-WICH-NEED-WPA"
    7.28 +#					scan_ssid=1
    7.29 +#					proto=WPA
    7.30 +#					key_mgmt=WPA-PSK
    7.31 +#					psk=52b72d55b8ca0913c5339a2f
    7.32 +#					priority=5
    7.33 +#					}'
    7.34 +#		#if wep:
    7.35 +#		KEY="my-wep-key"
    7.36 +# }
    7.37 +########################################################################
    7.38 +
    7.39 +
    7.40 +## first, we have to say which interface is ethernet, which is wifi:
    7.41 +INTERFACE="eth0"
    7.42 +WIFI_INTERFACE="wlan0"
    7.43 +
    7.44 +## place here your differents access points:
    7.45 +
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/nomad/taz/nomad-0.1/fs/usr/sbin/nomad	Mon Jul 21 20:36:23 2008 +0200
     8.3 @@ -0,0 +1,127 @@
     8.4 +#! /bin/sh
     8.5 +# nomad: configure wifi and change acces point easily.
     8.6 +
     8.7 +# Copyright (C) <2008>  <Pierre-Jean Fichet> <sygnes@ombres.eu>
     8.8 +#
     8.9 +# This program is free software: you can redistribute it and/or modify
    8.10 +# it under the terms of the GNU General Public License as published by
    8.11 +# the Free Software Foundation, either version 3 of the License, or
    8.12 +# (at your option) any later version.
    8.13 +#
    8.14 +# This program is distributed in the hope that it will be useful,
    8.15 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.16 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    8.17 +# GNU General Public License for more details.
    8.18 +#
    8.19 +# You should have received a copy of the GNU General Public License
    8.20 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    8.21 +
    8.22 +
    8.23 +CONFIG="/etc/nomad.conf"
    8.24 +
    8.25 +. $CONFIG
    8.26 +. /etc/init.d/rc.functions
    8.27 +
    8.28 +
    8.29 +case "$1" in
    8.30 +	# we want to configure au new interface
    8.31 +	new)
    8.32 +		TYPE="wifi"
    8.33 +		WIFI_INTERFACE="$2"
    8.34 +		ESSID="$3"
    8.35 +		KEYTYPE="$4"
    8.36 +		KEY="$5"
    8.37 +		DRIVER="$6"
    8.38 +		if [ "$KEYTYPE" = "wpa" ]; then
    8.39 +			WPA="
    8.40 +ap_scan=1
    8.41 +network={
    8.42 +	ssid=\"$ESSID\"
    8.43 +	scan_ssid=1
    8.44 +	proto=WPA
    8.45 +	key_mgmt=WPA-PSK
    8.46 +	psk=\"$KEY\"
    8.47 +	priority=5
    8.48 +}"
    8.49 +		fi
    8.50 +	;;
    8.51 +
    8.52 +	# we want to poweroff wifi
    8.53 +	stop)
    8.54 +		echo -n "pidof wpa_supplicant: "
    8.55 +		if pidof wpa_supplicant; then
    8.56 +			echo -n "stopping wpa_supplicant..."
    8.57 +			killall wpa_supplicant
    8.58 +			status
    8.59 +		else
    8.60 +			echo "None"
    8.61 +		fi
    8.62 +		echo -n "power off wifi..."
    8.63 +		iwconfig $WIFI_INTERFACE txpower off
    8.64 +		status
    8.65 +	;;
    8.66 +
    8.67 +
    8.68 +	*)
    8.69 +	# we want to join a known access point
    8.70 +	if [ "$1" != "" ] && grep -q "$1() {" $CONFIG ; then
    8.71 +		$1	# here we launch the function to set variables
    8.72 +	# we don't know how to use nomad
    8.73 +	else
    8.74 +		echo -n -e "\033[01musage:\033[0m `basename $0` ["
    8.75 +		for line in `grep "() {" $CONFIG | sed "/#.*/d" | sed -e "s/() {//g"`
    8.76 +			do
    8.77 +			echo -n "$line|"
    8.78 +			done
    8.79 +		echo -n "stop]"
    8.80 +		echo ""
    8.81 +		echo -e "\033[1mOr   :\033[0m `basename $0` new \
    8.82 +WIFI_INTERFACE ESSID KEYTYPE KEY DRIVER"
    8.83 +    	echo "	KEYTYPE is: wpa or wep"
    8.84 +    	echo "	DRIVER is wext or another-wpa_supplicant-driver"
    8.85 +		echo ""
    8.86 +		exit 1
    8.87 +	fi
    8.88 +	;;
    8.89 +esac
    8.90 +
    8.91 +
    8.92 +#Si ethernet
    8.93 +if [ "$TYPE" = "ethernet" ]; then
    8.94 +	if [ "$DHCP" = "yes" ] ; then
    8.95 +		echo "Starting udhcpc client on: $INTERFACE... "
    8.96 +		/sbin/udhcpc -b -i $INTERFACE -p /var/run/udhcpc.$INTERFACE.pid
    8.97 +		status
    8.98 +	fi
    8.99 +	# For a static IP.
   8.100 +	if [ "$STATIC" = "yes" ] ; then
   8.101 +		echo -n "Configuring static IP on $INTERFACE: $IP... "
   8.102 +		/sbin/ifconfig $INTERFACE $IP netmask $NETMASK up
   8.103 +		/sbin/route add default gateway $GATEWAY
   8.104 +		status
   8.105 +		# Multi-DNS server in $DNS_SERVER.
   8.106 +		/bin/mv /etc/resolv.conf /tmp/resolv.conf.$$
   8.107 +		for NS in $DNS_SERVER
   8.108 +		do
   8.109 +			echo "nameserver $NS" >> /etc/resolv.conf
   8.110 +		done
   8.111 +	fi
   8.112 +	
   8.113 +#si wifi		
   8.114 +elif [ "$TYPE" = "wifi" ]; then
   8.115 +	iwconfig $WIFI_INTERFACE txpower on
   8.116 +	status
   8.117 +	iwconfig $WIFI_INTERFACE essid $ESSID
   8.118 +	if [ -n "$WPA" ]; then
   8.119 +		echo "$WPA" >/tmp/wpa.conf
   8.120 +		echo "starting wpa_supplicant for $INTERFACE..."
   8.121 +		wpa_supplicant -B -w -c/tmp/wpa.conf -D$DRIVER -i$WIFI_INTERFACE
   8.122 +		status
   8.123 +		rm  /tmp/wpa.conf
   8.124 +	elif [ -n "$KEY" ]; then
   8.125 +		iwconfig $WIFI_INTERFACE key $KEY
   8.126 +	fi
   8.127 +	/sbin/udhcpc -b -i $WIFI_INTERFACE -p /var/run/udhcpc.$WIFI_INTERFACE.pid
   8.128 +fi
   8.129 +
   8.130 +exit 0
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/nomad/taz/nomad-0.1/fs/usr/sbin/nomadbox	Mon Jul 21 20:36:23 2008 +0200
     9.3 @@ -0,0 +1,195 @@
     9.4 +#! /bin/sh
     9.5 +# nomad: configure wifi and change acces point easily -- gtkdialog version.
     9.6 +
     9.7 +# Copyright (C) <2008>  <Pierre-Jean Fichet> <sygnes@ombres.eu>
     9.8 +#
     9.9 +# This program is free software: you can redistribute it and/or modify
    9.10 +# it under the terms of the GNU General Public License as published by
    9.11 +# the Free Software Foundation, either version 3 of the License, or
    9.12 +# (at your option) any later version.
    9.13 +#
    9.14 +# This program is distributed in the hope that it will be useful,
    9.15 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.16 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    9.17 +# GNU General Public License for more details.
    9.18 +#
    9.19 +# You should have received a copy of the GNU General Public License
    9.20 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    9.21 +
    9.22 +. /etc/nomad.conf
    9.23 +
    9.24 +for line in `grep "() {" /etc/nomad.conf | sed "/#.*/d" | sed -e "s/() {//g"`
    9.25 +	do
    9.26 +	ITEM="<item>$line</item>"
    9.27 +	ITEMS="$ITEMS$ITEM"
    9.28 +	done
    9.29 +
    9.30 +for linessid in `iwlist $WIFI_INTERFACE scanning | grep "ESSID" | grep -v "<hidden>" | sed -n 's/ESSID:"//p' | sed -n 's/"//p'`
    9.31 +	do
    9.32 +	ESSID="<item>$linessid</item>"
    9.33 +	ESSIDS="$ESSIDS$ESSID"
    9.34 +	done
    9.35 +
    9.36 +export IWCONFIG='
    9.37 +<window title="Wireless status" icon-name="network-wireless">
    9.38 +  <vbox>
    9.39 +    <text use-markup="true">
    9.40 +      <label>"<b>Wireless status</b>"</label>
    9.41 +    </text>
    9.42 +    <frame Iwconfig>
    9.43 +      <text wrap="false" width-chars="58">
    9.44 +        <input>iwconfig 2>&1</input>
    9.45 +      </text>
    9.46 +    </frame>
    9.47 +    <hbox>
    9.48 +      <button>
    9.49 +        <input file icon="exit"></input>
    9.50 +        <action type="closewindow">IWCONFIG</action>
    9.51 +      </button>
    9.52 +    </hbox>
    9.53 +  </vbox>
    9.54 +</window>
    9.55 +'
    9.56 +
    9.57 +export SCAN="
    9.58 +<window title=\"Wireless Scan\" icon-name=\"network-wireless\">
    9.59 +  <vbox>
    9.60 +    <text use-markup=\"true\">
    9.61 +      <label>\"<b>Scan for wifi access points</b>\"</label>
    9.62 +    </text>
    9.63 +    <frame iwlist scan>
    9.64 +      <text use-markup=\"false\">
    9.65 +      <input>iwlist $WIFI_INTERFACE scanning | grep \"ESSID\|Encryption\|Quality\" | sed -e \"s/^ *ESSID/ESSID/g\" 2>&1</input>
    9.66 +      </text>
    9.67 +    </frame>
    9.68 +    <hbox>
    9.69 +      <button>
    9.70 +        <input file icon=\"exit\"></input>
    9.71 +        <action type=\"closewindow\">SCAN</action>
    9.72 +      </button>
    9.73 +    </hbox>
    9.74 +  </vbox>
    9.75 +</window>
    9.76 +"
    9.77 +
    9.78 +
    9.79 +
    9.80 +
    9.81 +
    9.82 +export NOMADBOX="
    9.83 +<window title=\"NomadBox\" icon-name=\"network-wireless\">
    9.84 + 	<vbox>
    9.85 +		<text use-markup=\"true\">
    9.86 +			<label>\"<b>Slitaz NomadBox</b>\"</label>
    9.87 +		</text>
    9.88 +	    <text wrap=\"true\" width-chars=\"52\" use-markup=\"true\">
    9.89 +			<label>\"Connect to a wireless station.\"</label>
    9.90 +    	</text>
    9.91 +
    9.92 +	<notebook labels=\"Connection|Configuration\">    
    9.93 +		<frame Choose where to connect>
    9.94 +			<vbox>
    9.95 +			<hbox>
    9.96 +				<text use-markup=\"true\">
    9.97 +					<label>\"<b>Interface:</b>\"</label>
    9.98 +				</text>
    9.99 +				<combobox>
   9.100 +					<variable>INTERFACE</variable>
   9.101 +					$ITEMS
   9.102 +				</combobox>
   9.103 +				<button>
   9.104 +					<label>Start</label>
   9.105 +					<input file icon=\"forward\"></input>
   9.106 +					<action>nomad \$INTERFACE</action>
   9.107 +				</button>
   9.108 +			</hbox>
   9.109 +				<hbox>
   9.110 +					<button>
   9.111 +						<label>Wifi On</label>
   9.112 +						<input file icon=\"forward\"></input>
   9.113 +						<action>iwconfig \$WIFI_INTERFACE txpower auto</action>
   9.114 +					</button>
   9.115 +					<button>
   9.116 +						<label>Wifi Stop</label>
   9.117 +						<input file icon=\"stop\"></input>
   9.118 +						<action>nomad stop</action>
   9.119 +					</button>
   9.120 +				</hbox>
   9.121 +			</vbox>
   9.122 +		</frame>
   9.123 +		<frame Configure a new wifi connection>
   9.124 +		<vbox>
   9.125 +			
   9.126 +			<hbox>
   9.127 +				<text><label>\"Interface	:\"</label></text>
   9.128 +				<combobox>
   9.129 +					<variable>NEWINTERFACE</variable>
   9.130 +					<item>wlan0</item>
   9.131 +					<item>eth1</item>
   9.132 +					<item>eth0</item>
   9.133 +					<item></item>
   9.134 +				</combobox>
   9.135 +			</hbox>
   9.136 +			<hbox>
   9.137 +				<text><label>\"ESSID :\"</label></text>
   9.138 +				<combobox>
   9.139 +					<variable>NEWESSID</variable>
   9.140 +					<item></item>
   9.141 +					$ESSIDS
   9.142 +				</combobox>
   9.143 +			</hbox>
   9.144 +
   9.145 +			<hbox>
   9.146 +				<text>
   9.147 +				<label>\"Key type :\"</label>
   9.148 +				</text>
   9.149 +				<combobox>
   9.150 +					<variable>NEWKEYTYPE</variable>
   9.151 +					<item>Without Key</item>
   9.152 +					<item>wep</item>
   9.153 +					<item>wpa</item>
   9.154 +				</combobox>
   9.155 +			</hbox>
   9.156 +			<hbox>
   9.157 +				<text>
   9.158 +				<label>\"wpa-Driver :\"</label>
   9.159 +				</text>
   9.160 +				<combobox>
   9.161 +					<variable>DRIVER</variable>
   9.162 +					<item>wext</item>
   9.163 +					<item></item>
   9.164 +				</combobox>
   9.165 +			</hbox>
   9.166 +			<hbox>
   9.167 +				<text><label>\"Key    :\"</label></text>
   9.168 +				<entry>	
   9.169 +					<variable>NEWKEY</variable>
   9.170 +				</entry>
   9.171 +			</hbox>
   9.172 +			<hbox>
   9.173 +				<button>
   9.174 +					<label>Iwconfig</label>
   9.175 +					<input file icon=\"computer\"></input>
   9.176 +					<action type=\"launch\">IWCONFIG</action>
   9.177 +				</button>
   9.178 +				<button>
   9.179 +					<label>Scan</label>
   9.180 +					<input file icon=\"network-wireless\"></input>
   9.181 +					<action type=\"launch\">SCAN</action>
   9.182 +				</button>
   9.183 +				<button>
   9.184 +					<label>Start</label>
   9.185 +					<input file icon=\"forward\"></input>
   9.186 +					<action>nomad new \$NEWINTERFACE \$NEWESSID \$NEWKEYTYPE \$NEWKEY \$DRIVER</action>
   9.187 +				</button>
   9.188 +			</hbox>
   9.189 +			</vbox>
   9.190 +			</frame>
   9.191 +	</notebook>
   9.192 +	</vbox>
   9.193 +</window>
   9.194 +"
   9.195 + 
   9.196 +gtkdialog --program=NOMADBOX
   9.197 +
   9.198 +exit 0
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/nomad/taz/nomad-0.1/md5sum	Mon Jul 21 20:36:23 2008 +0200
    10.3 @@ -0,0 +1,3 @@
    10.4 +c3f71937dc0ae32b34db0a65f45c069f  /etc/nomad.conf
    10.5 +758ada5291678255a3755bab64ca0c67  /usr/sbin/nomadbox
    10.6 +9291dae920d28679e21cc52b99fd3fb1  /usr/sbin/nomad
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/nomad/taz/nomad-0.1/receipt	Mon Jul 21 20:36:23 2008 +0200
    11.3 @@ -0,0 +1,23 @@
    11.4 +# SliTaz package receipt.
    11.5 +
    11.6 +PACKED_SIZE="20.0k"
    11.7 +UNPACKED_SIZE="48.0k"
    11.8 +PACKAGE="nomad"
    11.9 +VERSION="0.1"
   11.10 +CATEGORY="extra"
   11.11 +SHORT_DESC="user friendly wifi configure for nomads."
   11.12 +MAINTAINER="sygne@ombres.eu"
   11.13 +DEPENDS="gtkdialog wireless_tools"
   11.14 +
   11.15 +
   11.16 +# Rules to gen a SliTaz package suitable for Tazpkg.
   11.17 +genpkg_rules()
   11.18 +{
   11.19 +	mkdir -p $fs/usr/sbin
   11.20 +	cp -a stuff/nomad $fs/usr/sbin/
   11.21 +	cp -a stuff/nomadbox $fs/usr/sbin/
   11.22 +
   11.23 +	mkdir $fs/etc
   11.24 +	cp -a stuff/nomad.conf $fs/etc/
   11.25 +}
   11.26 +