Skip to content

Instantly share code, notes, and snippets.

@masterdje
Created October 17, 2013 19:55
Show Gist options
  • Save masterdje/7031189 to your computer and use it in GitHub Desktop.
Save masterdje/7031189 to your computer and use it in GitHub Desktop.
HomePass2.sh : Transform your OpenWrt router into an NintendoZone, to get a big load of Streetpasses... Script from reddit User : http://www.reddit.com/user/alexatkinuk on the topic : http://www.reddit.com/r/3DS/comments/1k0g58/setting_up_a_streetpass_relay_at_home/cbl3onj ... He truly deserves all the glory, as we use also his custom Mac list (…
#/bin/sh
# HomePass
DATE=$(date)
# Put a filename and path in here if you wish to log each profile change
LOG="HomePass.log"
# The WiFi network number we need to toggle the MAC address of
# You must have already added a WiFi network with the ssid "attwifi" and clicked "save & apply"
WIFI=$(uci show wireless | grep "ssid=attwifi" | awk 'NR>1{print $1}' RS=[ FS=])
# MAC address list is missing or empty, reload it from the server
if [ ! -s HomePass.list ]; then
# If you only want to use the primaries and Nintendo World (not the SPOOF range)
# then delete the current HomePass.list and add ?new=1 to the end of the next line
wget -O HomePass.list http://csdprojects.co.uk/3DS/HomePass.php
fi
if [ ! -s HomePass.list ]; then
echo "MAC address list is missing or zero in length and we were unable to update it. Try again later."
exit
fi
LENGTH=$(wc -l < HomePass.list)
if [ -z "$WIFI" ]; then
echo Unable to identify the WiFi configuration for the attwifi network!
echo Please make sure you have created a Wifi network with the ssid attwifi before running this script.
exit
fi
# If no profile was manually specified then read it from uci
if [ -z "$1" ]; then
I=$(uci get wireless.@wifi-iface[$((WIFI))].profile)
# If there is no uci entry then we start from scratch
if [ -z "$I" ]; then
I=1
else
I=$((I+1))
fi
# If we went over the last profile we reset back to $MIN
if [ $I -gt $LENGTH ]; then
I=1
fi
else
I=$1
fi
# Read MAC address number $I from the list
MAC=$(sed -n $((I))p HomePass.list)
# Make sure we actually got a MAC address from the list
if [ -n "$MAC" ]; then
echo Setting profile $I, $MAC, $DATE
# Write profile changes to a log file
if [ -n "$LOG" ]; then
echo Setting profile $I, $MAC, $DATE >> $LOG
fi
# Save a custom config called profile so that we know where we are in the list next time
uci set wireless.@wifi-iface[$((WIFI))].profile=$I
# Save the new MAC address
uci set wireless.@wifi-iface[$((WIFI))].macaddr=$MAC
# Restart the WiFi
wifi 2>1 >/dev/null
else
echo "We had a problem reading the MAC address from the list, aborting."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment