- Copy this script to the script editor
- Replace the field “X.X.X.X” with your NAS IP
- Replace the field “Myusername”
- Replace the field “YOUR-WIFI-NAME”
- Save and test the file as AutoMountShare.APP
delay 5
# Check WD NAS IP address is reachable
set IP_address to "X.X.X.X"
set IP_Valid to true
try
do shell script ("ping -c 2 " & IP_address)
on error
set IP_Valid to false
end try
# Check WIFI Name
set SSID to do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk '/ SSID: / {print $2}'"
-- IF NETWORK IS HOME
if SSID is "YOUR-WIFI-NAME" or IP_Valid then
-- MOUNT My Drives
tell application "Finder"
mount volume "smb://x.x.x.x/myshare" as user name "Myusername"
end tell
-- SET RESULT VAR TO "WIN"
set endresult to "win"
-- ELSE
else
-- DO NOTHING
-- SET RESULT VAR TO "FAIL"
set endresult to "fail"
-- END
end if