Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. #/bin/sh
  2. # HomePass
  3. DATE=$(date)
  4. # Put a filename and path in here if you wish to log each profile change
  5. LOG="HomePass.log"
  6. # The WiFi network number we need to toggle the MAC address of
  7. # You must have already added a WiFi network with the ssid "attwifi" and clicked "save & apply"
  8. WIFI=$(uci show wireless | grep "ssid=attwifi" | awk 'NR>1{print $1}' RS=[ FS=])
  9. # MAC address list is missing or empty, reload it from the server
  10. if [ ! -s HomePass.list ]; then
  11. # If you only want to use the primaries and Nintendo World (not the SPOOF range)
  12. # then delete the current HomePass.list and add ?new=1 to the end of the next line
  13. wget -O HomePass.list http://csdprojects.co.uk/3DS/HomePass.php
  14. fi
  15.  
  16. if [ ! -s HomePass.list ]; then
  17. echo "MAC address list is missing or zero in length and we were unable to update it. Try again later."
  18. exit
  19. fi
  20.  
  21. LENGTH=$(wc -l < HomePass.list)
  22.  
  23. if [ -z "$WIFI" ]; then
  24. echo Unable to identify the WiFi configuration for the attwifi network!
  25. echo Please make sure you have created a Wifi network with the ssid attwifi before running this script.
  26. exit
  27. fi
  28.  
  29. # If no profile was manually specified then read it from uci
  30. if [ -z "$1" ]; then
  31. I=$(uci get wireless.@wifi-iface[$((WIFI))].profile)
  32. # If there is no uci entry then we start from scratch
  33. if [ -z "$I" ]; then
  34. I=1
  35. else
  36. I=$((I+1))
  37. fi
  38. # If we went over the last profile we reset back to $MIN
  39. if [ $I -gt $LENGTH ]; then
  40. I=1
  41. fi
  42. else
  43. I=$1
  44. fi
  45.  
  46. # Read MAC address number $I from the list
  47. MAC=$(sed -n $((I))p HomePass.list)
  48. # Make sure we actually got a MAC address from the list
  49. if [ -n "$MAC" ]; then
  50. echo Setting profile $I, $MAC, $DATE
  51. # Write profile changes to a log file
  52. if [ -n "$LOG" ]; then
  53. echo Setting profile $I, $MAC, $DATE >> $LOG
  54. fi
  55. # Save a custom config called profile so that we know where we are in the list next time
  56. uci set wireless.@wifi-iface[$((WIFI))].profile=$I
  57. # Save the new MAC address
  58. uci set wireless.@wifi-iface[$((WIFI))].macaddr=$MAC
  59. # Restart the WiFi
  60. wifi 2>1 >/dev/null
  61. else
  62. echo "We had a problem reading the MAC address from the list, aborting."
  63. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement