wok diff nomad/stuff/nomad @ rev 6213
Up: seamonkey to 2.0.7.
author | Christopher Rogers <slaxemulator@gmail.com> |
---|---|
date | Sat Sep 11 12:27:43 2010 +0000 (2010-09-11) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/nomad/stuff/nomad Sat Sep 11 12:27:43 2010 +0000 1.3 @@ -0,0 +1,131 @@ 1.4 +#! /bin/sh 1.5 +# nomad: configure wifi and change acces point easily. 1.6 + 1.7 +# Copyright (C) <2008> <Pierre-Jean Fichet> <sygnes@ombres.eu> 1.8 +# 1.9 +# This program is free software: you can redistribute it and/or modify 1.10 +# it under the terms of the GNU General Public License as published by 1.11 +# the Free Software Foundation, either version 3 of the License, or 1.12 +# (at your option) any later version. 1.13 +# 1.14 +# This program is distributed in the hope that it will be useful, 1.15 +# but WITHOUT ANY WARRANTY; without even the implied warranty of 1.16 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1.17 +# GNU General Public License for more details. 1.18 +# 1.19 +# You should have received a copy of the GNU General Public License 1.20 +# along with this program. If not, see <http://www.gnu.org/licenses/>. 1.21 + 1.22 + 1.23 +CONFIG="/etc/nomad.conf" 1.24 + 1.25 +. $CONFIG 1.26 +. /etc/init.d/rc.functions 1.27 + 1.28 + 1.29 +case "$1" in 1.30 + # we want to configure au new interface 1.31 + new) 1.32 + TYPE="wifi" 1.33 + WIFI_INTERFACE="$2" 1.34 + ESSID="$3" 1.35 + KEYTYPE="$4" 1.36 + KEY="$5" 1.37 + DRIVER="$6" 1.38 + if [ "$KEYTYPE" = "wpa" ]; then 1.39 + WPA=" 1.40 +ap_scan=1 1.41 +network={ 1.42 + ssid=\"$ESSID\" 1.43 + scan_ssid=1 1.44 + proto=WPA 1.45 + key_mgmt=WPA-PSK 1.46 + psk=\"$KEY\" 1.47 + priority=5 1.48 +}" 1.49 + fi 1.50 + ;; 1.51 + 1.52 + # we want to poweroff wifi 1.53 + stop) 1.54 + echo -n "pidof wpa_supplicant: " 1.55 + if pidof wpa_supplicant; then 1.56 + echo -n "stopping wpa_supplicant..." 1.57 + killall wpa_supplicant 1.58 + status 1.59 + else 1.60 + echo "None" 1.61 + fi 1.62 + echo -n "power off wifi..." 1.63 + iwconfig $WIFI_INTERFACE txpower off 1.64 + status 1.65 + ;; 1.66 + 1.67 + 1.68 + *) 1.69 + # we want to join a known access point 1.70 + if [ "$1" != "" ] && grep -q "$1() {" $CONFIG ; then 1.71 + $1 # here we launch the function to set variables 1.72 + # we don't know how to use nomad 1.73 + else 1.74 + echo -n -e "\033[01musage:\033[0m `basename $0` [" 1.75 + for line in `grep "() {" $CONFIG | sed "/#.*/d" | sed -e "s/() {//g"` 1.76 + do 1.77 + echo -n "$line|" 1.78 + done 1.79 + echo -n "stop]" 1.80 + echo "" 1.81 + echo -e "\033[1mOr :\033[0m `basename $0` new \ 1.82 +WIFI_INTERFACE ESSID KEYTYPE KEY DRIVER" 1.83 + echo " KEYTYPE is: wpa or wep" 1.84 + echo " DRIVER is wext or another-wpa_supplicant-driver" 1.85 + echo "" 1.86 + echo -e " But first, you have to edit \033[1m/etc/nomad.conf\033[0m " 1.87 + echo "" 1.88 + echo -e "You can also use \033[1mnomadbox\033[0m, if you want a graphical interface for nomad" 1.89 + echo "" 1.90 + exit 1 1.91 + fi 1.92 + ;; 1.93 +esac 1.94 + 1.95 + 1.96 +#Si ethernet 1.97 +if [ "$TYPE" = "ethernet" ]; then 1.98 + if [ "$DHCP" = "yes" ] ; then 1.99 + echo "Starting udhcpc client on: $INTERFACE... " 1.100 + /sbin/udhcpc -b -i $INTERFACE -p /var/run/udhcpc.$INTERFACE.pid 1.101 + status 1.102 + fi 1.103 + # For a static IP. 1.104 + if [ "$STATIC" = "yes" ] ; then 1.105 + echo -n "Configuring static IP on $INTERFACE: $IP... " 1.106 + /sbin/ifconfig $INTERFACE $IP netmask $NETMASK up 1.107 + /sbin/route add default gateway $GATEWAY 1.108 + status 1.109 + # Multi-DNS server in $DNS_SERVER. 1.110 + /bin/mv /etc/resolv.conf /tmp/resolv.conf.$$ 1.111 + for NS in $DNS_SERVER 1.112 + do 1.113 + echo "nameserver $NS" >> /etc/resolv.conf 1.114 + done 1.115 + fi 1.116 + 1.117 +#si wifi 1.118 +elif [ "$TYPE" = "wifi" ]; then 1.119 + iwconfig $WIFI_INTERFACE txpower on 1.120 + status 1.121 + iwconfig $WIFI_INTERFACE essid $ESSID 1.122 + if [ -n "$WPA" ]; then 1.123 + echo "$WPA" >/tmp/wpa.conf 1.124 + echo "starting wpa_supplicant for $INTERFACE..." 1.125 + wpa_supplicant -B -w -c/tmp/wpa.conf -D$DRIVER -i$WIFI_INTERFACE 1.126 + status 1.127 + rm /tmp/wpa.conf 1.128 + elif [ -n "$KEY" ]; then 1.129 + iwconfig $WIFI_INTERFACE key $KEY 1.130 + fi 1.131 + /sbin/udhcpc -b -i $WIFI_INTERFACE -p /var/run/udhcpc.$WIFI_INTERFACE.pid 1.132 +fi 1.133 + 1.134 +exit 0