Posted on 11-24-2014 12:50 PM
Is there a way for when a user goes home that the script i have to mount network drives does not run because it doesn't see our directory? I am sure there is a check that can be done but not being script savvy am not sure how to write it. Any information would be greatly appreciated.
Posted on 11-24-2014 01:03 PM
What language is the script written in?
Whichever it is, there are probably a dozen different ways you can address this. A common way would be to pick some internal only domain controller or server or something and do a ping or ncat or nslookup against it first in your script and then based on the results, move on to mounting the shares or just exit silently. IOW, if your script can see the internal servers or DCs, it can likely mount the shares. If not, no point in even continuing, so just exit.
Posted on 11-24-2014 01:12 PM
@KCH080208, as @mm2270 said.. There are many ways.
Really depends on your script, to help we'll need to see it.
FWIW, we map drives based on AD group membership... When off the domain, clients cannot see the domain & therefore cannot get membership. So nothing tries to map.
Posted on 11-24-2014 03:19 PM
If the script is being triggered by a policy you could just restrict it to a specific network segment (or segments).
Failing that I would use a ping check on a known internal server.
Posted on 11-25-2014 02:21 PM
Instead of using a script to mount network shares, try using autofs. That works well to disconnect and reconnect network shares as needed.
Posted on 05-03-2016 06:39 PM
@davidacland do you have an example of this?
Posted on 05-03-2016 11:37 PM
In your JSS, go to Settings > Network Organisation > Network Segments and add the IP range of your local network.
Then in the policy, go to Scope > Limitations > Add and add the network segment.
If you want to include a ping check into the script instead (or as an added safety measure), here's some code you can use:
PingServer="your.server.com" # The address of a server on your local network that responds to a ping
ping -c 3 $PingServer &> /dev/null
if [ $? == 0 ] ; then
exit 0
else
# do the rest of your drive mounting code here
fi
The only downside with the ping method is if someone removes the ping server, the script will stop mounting the network drive as it will think it's off the network.