Don't like ads? PRO users don't see any ads ;-)
Guest

Xlink Kai Ubuntu Host SSID Script

By: a guest on Jun 13th, 2010  |  syntax: Bash  |  size: 1.62 KB  |  hits: 181  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2.  
  3. # shutdown handler
  4. shutdown()
  5. {
  6.   # start network-manager
  7.   start network-manager > /dev/null
  8.  
  9.   # shutdown follower
  10.   exit 0
  11. }
  12.  
  13. # add shutdown handler
  14. trap shutdown SIGINT
  15.  
  16. # clear screen
  17. clear
  18.  
  19. # display credits
  20. echo "KAI SSID Host Tool for Ubuntu Linux 10.04 by Coldbird"
  21.  
  22. # stop network-manager
  23. stop network-manager > /dev/null
  24.  
  25. # bring down cable interface
  26. ifconfig eth0 down
  27.  
  28. # bring down wlan interface
  29. ifconfig wlan0 down
  30.  
  31. # bring up cable network (internet)
  32. ifconfig eth0 up
  33.  
  34. # connect cable network (internet)
  35. dhclient eth0 2> /dev/null
  36.  
  37. # switch wlan device into adhoc mode
  38. iwconfig wlan0 mode ad-hoc
  39.  
  40. # repeat till it works
  41. while [ $? != 0 ]; do
  42. iwconfig wlan0 mode ad-hoc
  43. done
  44.  
  45. # switch to channel 1
  46. iwconfig wlan0 channel 1
  47.  
  48. # repeat till it works
  49. while [ $? != 0 ]; do
  50. iwconfig wlan0 channel 1
  51. done
  52.  
  53. # start wlan device
  54. ifconfig wlan0 up
  55.  
  56. # previous playstation ssid
  57. PREVSSID="NOTHING"
  58.  
  59. # current playstation ssid
  60. CURSSID="NOTHING"
  61.  
  62. # follower loop start
  63. while true; do
  64.  
  65. # get playstation ssid
  66. 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`
  67.  
  68. # new playstation ssid start
  69. if [ "$CURSSID" != "$NEWSSID" -a "$PREVSSID" != "$NEWSSID" -a -n "$NEWSSID" ]; then
  70.  
  71. # connect to network
  72. iwconfig wlan0 essid $NEWSSID
  73.  
  74. # set link local
  75. ifconfig wlan0 169.254.34.2
  76.  
  77. # save previous ssid
  78. PREVSSID=$CURSSID
  79.  
  80. # save playstation ssid
  81. CURSSID=$NEWSSID
  82.  
  83. # display change
  84. echo Switched to $NEWSSID.
  85.  
  86. # new playstation ssid end
  87. fi
  88.  
  89. # delay polling
  90. sleep 3
  91.  
  92. # follower loop end
  93. done