#! /bin/sh # Script for controlling the WLAN connection. # exit codes: # 0: OK # 1: you are not root # 2: connection failed # are we root? if [ `id -u` != 0 ]; then echo "Only root may run $0." exit 1 fi COMMAND=$1 USER=user # set network name for wlan as saved in Connections # only WEP, WPA preshared and NONE security MY_NETWORK="HOME_WLAN" MY_ESSID="HOME_WLAN" # MY_ESSID=`su - $USER -c "gconftool-2 -g /system/osso/connectivity/IAP/${MY_NETWORK}/wlan_ssid"` infoprint() { local msg=$1 su - $USER -c "dbus-send --session --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint \"string:$*\"" } bnep_start() { infoprint "Connecting to $MY_NETWORK ..." ifconfig wlan0 up MY_SECURITY=`su - $USER -c "gconftool-2 -g /system/osso/connectivity/IAP/${MY_NETWORK}/wlan_security"` case $MY_SECURITY in WEP) MY_KEY=`su - $USER -c "gconftool-2 -g /system/osso/connectivity/IAP/${MY_NETWORK}/wlan_wepkey1"` iwconfig wlan0 enc $MY_KEY mode managed essid $MY_ESSID ;; WPA_PSK) MY_KEY=`su - $USER -c "gconftool-2 -g /system/osso/connectivity/IAP/${MY_NETWORK}/EAP_wpa_preshared_passphrase"` iwconfig wlan0 enc s:$MY_KEY mode managed essid $MY_ESSID ;; NONE) iwconfig wlan0 mode managed essid $MY_ESSID ;; esac udhcpc -i wlan0 -n MY_IP=`ifconfig wlan0 | grep inet` infoprint "Connected with $MY_IP" } bnep_stop() { infoprint "Disconnecting from $MY_NETWORK ..." ifconfig wlan0 down udhcpc -i wlan0 -n ifconfig wlan0 up } case $COMMAND in connect) bnep_start ;; disconnect) bnep_stop ;; esac