I'd paint that bike shed like this:
Code:
#!/bin/sh
<init vars here>
mount_it() {
echo "Attempting to mount to ${1}..."
# If connect scan to tcp 22 works, then mount
( nc -z -w 2 ${1} 22 >/dev/null ) && <sshfs mount ${1} here>
# If that all worked, we get out
if [ ${?} -eq 0 ] ; then
echo 'Mounted.'
exit 0
fi
}
mount_it ${local_ip}
mount_it ${external_ip}
exit 0
netcat (nc) should be included with your Mac OSX base system.