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

Xlink Kai Ubuntu Client SSID Script

By: a guest on Jun 13th, 2010  |  syntax: Bash  |  size: 1.86 KB  |  hits: 195  |  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 Client 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. # current playstation ssid
  57. CURSSID="NOTHING"
  58.  
  59. # initial ssid loop start
  60. while [ "$CURSSID" = "NOTHING" ]; do
  61.  
  62. # get playstation ssid
  63. NEWSSID=`iwlist wlan0 scan 2> /dev/null | grep PSP_ | cut -d : -f 2 | cut -d \" -f 2 | cut -d \" -f 1`
  64.  
  65. # new playstation ssid start
  66. if [ "$CURSSID" != "$NEWSSID" -a -n "$NEWSSID" ]; then
  67.  
  68. # connect to network
  69. iwconfig wlan0 essid $NEWSSID
  70.  
  71. # set link local
  72. ifconfig wlan0 169.254.34.2
  73.  
  74. # save playstation ssid
  75. CURSSID=$NEWSSID
  76.  
  77. # display change
  78. echo Switched to $NEWSSID.
  79.  
  80. # new playstation ssid end
  81. fi
  82.  
  83. # delay polling
  84. sleep 3
  85.  
  86. # initial ssid loop end
  87. done
  88.  
  89. # ssid change loop
  90. while true; do
  91.  
  92. # output message
  93. echo Paste the Host-Key \(PSP_AULES12345_L_hOsTkEy\) to switch SSID.
  94.  
  95. # read host key
  96. read HOSTKEY
  97.  
  98. # connect to network
  99. iwconfig wlan0 essid $CURSSID$HOSTKEY
  100.  
  101. # set link local
  102. ifconfig wlan0 169.254.34.2
  103.  
  104. # display change
  105. echo Switched to $CURSSID$HOSTKEY.
  106.  
  107. # ssid change loop end
  108. done