Skip to content

Instantly share code, notes, and snippets.

@yongkangchen
Created June 27, 2023 18:49
Show Gist options
  • Save yongkangchen/bfc7aa4cb875f7c36492c5134a5715b0 to your computer and use it in GitHub Desktop.
Save yongkangchen/bfc7aa4cb875f7c36492c5134a5715b0 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" \
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>networkchange</string>
<key>LowPriorityIO</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/Users/Shared/bin/networkchange.sh</string>
</array>
<key>WatchPaths</key>
<array>
<string>/private/var/run/resolv.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
@yongkangchen
Copy link
Author

networkchange.sh

#!/bin/bash

# automatically change configuration of Mac OS X based on location
# author: Rocco Georgi <rocco@pavingways.com>
# version: 0.4.0

# original author: Onne Gorter <o.gorter@gmail.com>
# url: http://tech.inhelsinki.nl/locationchanger/
# version: 0.4

# redirect all IO to a logfile
#mkdir -p /usr/local/var/log
#exec &>/usr/local/var/log/locationchanger.log

# to avoid any output, any logfile, uncomment the following:
exec 1>/dev/null 2>/dev/null

# this service is called immediately after network activity.
# sleep a bit to make sure that info is finished writing to disk about those network changes
sleep 2

# get SSID
SSID=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | awk -F ' SSID: ' '/ SSID:/ {print $2}'`
#echo `date` "New SSID found: $SSID"

#if [ -z "$SSID" ]; then
#   exit 0
#fi

if [ "$SSID" = "eduroam" ]; then
   osascript -e "display notification \"Network Changed to $SSID\" with title \"Network Update: $SSID\""
   sh /Users/Shared/bin/checkSCU.sh
fi


exit 0

@yongkangchen
Copy link
Author

checkSCU.sh

#!/bin/bash

url="https://login.scu.edu"

response=$(curl -sL --head --connect-timeout 3 "$url")

if [[ $? -ne 0 ]]; then
    open "/Users/Shared/bin/ReinstallOnGuardv1.app"
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment