
Xlink Kai Ubuntu Host SSID Script
By: a guest on
Jun 13th, 2010 | syntax:
Bash | size: 1.62 KB | hits: 181 | expires: Never
#!/bin/bash
# shutdown handler
shutdown()
{
# start network-manager
start network-manager > /dev/null
# shutdown follower
exit 0
}
# add shutdown handler
trap shutdown SIGINT
# clear screen
clear
# display credits
echo "KAI SSID Host Tool for Ubuntu Linux 10.04 by Coldbird"
# stop network-manager
stop network-manager > /dev/null
# bring down cable interface
ifconfig eth0 down
# bring down wlan interface
ifconfig wlan0 down
# bring up cable network (internet)
ifconfig eth0 up
# connect cable network (internet)
dhclient eth0 2> /dev/null
# switch wlan device into adhoc mode
iwconfig wlan0 mode ad-hoc
# repeat till it works
while [ $? != 0 ]; do
iwconfig wlan0 mode ad-hoc
done
# switch to channel 1
iwconfig wlan0 channel 1
# repeat till it works
while [ $? != 0 ]; do
iwconfig wlan0 channel 1
done
# start wlan device
ifconfig wlan0 up
# previous playstation ssid
PREVSSID="NOTHING"
# current playstation ssid
CURSSID="NOTHING"
# follower loop start
while true; do
# get playstation ssid
NEWSSID=`iwlist wlan0 scan 2> /dev/null | grep PSP_ | cut -d : -f 2 | cut -d \" -f 2 | cut -d \" -f 1 | grep -x -v $CURSSID`
# new playstation ssid start
if [ "$CURSSID" != "$NEWSSID" -a "$PREVSSID" != "$NEWSSID" -a -n "$NEWSSID" ]; then
# connect to network
iwconfig wlan0 essid $NEWSSID
# set link local
ifconfig wlan0 169.254.34.2
# save previous ssid
PREVSSID=$CURSSID
# save playstation ssid
CURSSID=$NEWSSID
# display change
echo Switched to $NEWSSID.
# new playstation ssid end
fi
# delay polling
sleep 3
# follower loop end
done