forked from rocco/osx-wifi-location-changer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocationchanger
executable file
·68 lines (51 loc) · 1.56 KB
/
locationchanger
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# automatically change configuration of Mac OS X based on location
# author: Rocco Georgi <[email protected]>
# version: 0.3.1
# original author: Onne Gorter <[email protected]>
# url: http://tech.inhelsinki.nl/locationchanger/
# version: 0.4
# redirect all IO to a logfile
exec &>/usr/local/var/log/locationchanger.log
# redirect all IO to /dev/null (comment this in if you don#t want to write to logfile)
#exec 1>/dev/null 2>/dev/null
# get a little breather before we get data for things to settle down
sleep 2
# get SSID
SSID=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | grep ' SSID:' | cut -d ':' -f 2 | tr -d ' '`
echo `date` "New SSID found: $SSID"
# empty location var
LOCATION=
# LOCATIONS
# (use to be used Location name here)
# =============================================
Location_Home="Home"
Location_CompanyIntra="Office"
# SSIDS
# =====
SSID_Home=bingo
SSID_CompanyIntra=SAP-Corporate
# SSID -> LOCATION mapping
case $SSID in
$SSID_Home ) LOCATION="$Location_Home";;
$SSID_CompanyIntra ) LOCATION="$Location_CompanyIntra";;
# ... add more here
esac
REASON="SSID changed to $SSID"
# still didn't get a location -> use Location_Automatic
if [ -z "$LOCATION" ]; then
LOCATION="$Location_Automatic"
REASON="Automatic Fallback"
fi
# change network location
scselect "$LOCATION"
case $LOCATION in
$Location_Automatic )
# do stuff here you would do in Location_Automatic
;;
$Location_CompanyIntra )
# nothing special here
;;
esac
echo "--> Location Changer: $LOCATION - $REASON"
exit 0