Skip to content

Instantly share code, notes, and snippets.

@ehemmete
Last active September 23, 2016 19:58
Show Gist options
  • Save ehemmete/618c96dc364d8a40723e30692617d2a8 to your computer and use it in GitHub Desktop.
Save ehemmete/618c96dc364d8a40723e30692617d2a8 to your computer and use it in GitHub Desktop.
LogonFileShareMounter.py
#!/bin/sh
if [ ! -d /Users/Shared/netlogon ]; then
mkdir /Users/Shared/netlogon
fi
mount_smbfs -o nobrowse //dc.my.domain.com/NETLOGON /Users/Shared/netlogon
if [ ! -e /Users/Shared/netlogon/LoginFileShareMounter.py ]; then
logger -t "myCompany:LoginFileShareMounter" "Cannot find the remote script"
else
storedSerial=$(cat /Library/Scripts/LoginFileShareMounter.py | grep '#serial_number=' | cut -d"=" -f 2)
remoteSerial=$(cat /Users/Shared/netlogon/LoginFileShareMounter.py | grep '#serial_number=' | cut -d"=" -f 2)
if [ $storedSerial -lt $remoteSerial ]; then
cp /Users/Shared/netlogon/LoginFileShareMounter.py /Library/Scripts/LogonFileShareMounter.py
logger -t "myCompany:LoginFileShareMounter" "The remote copy is newer; updating local version."
else
logger -t "myCompany:LoginFileShareMounter" "The local copy is up to date; nothing to change."
fi
fi
umount /Users/Shared/netlogon
rm -r /Users/Shared/netlogon
python /Library/Scripts/LoginFileShareMounter.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment