This script currently requires that your Wireless password is stored in plaintext in a dotfile due to limitations of networksetup
command failing to connect when the password is not provided directly. It is recommended that you only run this on a system that is 100% your own with an encrypted drive should it be lost. Solutions are welcome.
This script checks if your home network is nearby and within a certain threshold (default is greater than -60 RSSI). If it is found and meets the RSSI, it will connect you. If the criteria are not met, you may optionally launch a TunnelBlick VPN connection to secure your connection.
This shell script and apple script are designed to
be executed by ControlPlane when the SSID is equal to "xfinitywifi". If your home
network is found you are connected to it via networksetup
.
The applescript file is executed by the shellscript if a VPN connection is desired upon failure to connect to the home network.
- ControlPlane
- OS X
- A nearby xfinitywifi network.
- (Optional - if you want to launch a VPN when connected to XfinityWifi) TunnelBlick
- Download the two scripts from this Repository and place them somewhere on your hard drive (in my case, they will be in the
$HOME/Code/Scripts/
folder. - Edit
xfinityNeighbors.sh
- Change any options in the Config Options section
home_SSID
: the SSID of your home network.home_SSID_passwordfile
: Dotfile that your network password is stored in (run this script once from the terminal to generate the file from your input).home_signal_strength_threshold
: maximum RSSI allowed to connect to Home Network. Set this higher if you are not getting autoconnected.connect_VPN
: Do you want to connect to a TunnelBlick VPN if your home network is not found / cannot be connected to?tunnelblick_applescript_connect_script
: Path to script if you place it separate from the shell script (otherwise leave this as default).
- Change any options in the Config Options section
- (Optional - TunnelBlick VPN Desired only) Edit
xfinityNeighbors.scpt
- Replace all instances of
yourVPNConnectionName
with your VPN name from the TunnelBlick dropdown / Menu.
- Replace all instances of
-
Under
Context
, create one called XfinityWifi. -
Under
Evidence Sources
, make sure Nearby WiFi Network is checked. -
Connect to any XfinityWifi Access Point.
-
Under
Rules
, Click the Plus sign at the bottom left and selectAdd Nearby WiFi Network Rule > WiFi SSID
.- select
xfinitywifi
for SSID - select
XfinityWifi
for Context. - leave the Confidence slider at the default (90%)
- select
-
Under
Actions
, Click the Plus sign at the bottom left and selectSystem Actions > Run Shell Script
- Navigate the Finder window to where you extracted the scripts and select
xfinityNeighbors.sh
. - In the Context dropdown, select
XfinityWifi
andOn Arrival
- Navigate the Finder window to where you extracted the scripts and select
- Connect to your home network and wait around 5 seconds.
- Connect to XfinityWifi, within a few seconds you should get a notification from ControlPlane (unless you turned off notifications). Your script should now run and you will see it try to connect to your home network if it is close enough. If not, your VPN should launch if you configured one.