Skip to content

Instantly share code, notes, and snippets.

@alemarengo
Forked from tylerhall/auto-mount.sh
Created June 17, 2021 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alemarengo/0fa26807845c43ca0ee3f7c17e2fc125 to your computer and use it in GitHub Desktop.
Save alemarengo/0fa26807845c43ca0ee3f7c17e2fc125 to your computer and use it in GitHub Desktop.
#!/bin/bash
[ ! -d "/Volumes/ShareName" ] && open -g -j smb://user:pass@somewhere.local/ShareName
@alemarengo
Copy link
Author

#!/bin/bash
sleep 5
VOL=$(mount | grep /Volumes/my_folder)
#VPN=$(ifconfig ppp0 | grep "inet " | cut -d\  -f2)
VPN=$(ifconfig ppp0 | grep "inet " | cut -d \  -f 2 | cut -d "." -f 1-3)
ETH=$(ifconfig -l | xargs -n1 ipconfig getifaddr)
WIFI=$(/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk -F' SSID: '  '/ SSID: / {print $2}')
if ! VOL;
then
	if [ "$WIFI" = "my_SSID" ] || [ "$VPN" = "192.168.xyz" ]  || [ "$ETH" = "192.168.xyz.abc" ];
		then
		[ ! -d "/Volumes/my_folder" ] && open -g -j smb://my_user:my_pwd@192.168.xyz.abc/my_folder
	fi
fi

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