As I'm sure you are aware, the Force UNC Path function of the AD bind makes it so client computers try to mount home folders upon logging in. Well, the problem is that when the user is not on the network, it will hang until this process ultimately fails. I wanted a way around this, so I wrote a script that first checks to see if the server can be reached, and then mounts the user's home folder. There is a problem with it, though...
The script works fine, locally and in my research here, I have found that Casper will run everything as root and found how to run as the user. Even though I am specifically telling it to run as the current user, it is still running as root. Could anyone look at the script below and please tell me what I'm doing wrong? Thank you.
#Wait for full login
delay 10
#Check to see if DFS is available
set IP_address to "10.10.78.12"
set IP_Valid to true
try
do shell script ("ping -c 2 " & IP_address)
on error
set IP_Valid to false
end try
#Get current user name
set userName to short user name of (system info)
#If DFS is available, mount home folder of current user
if IP_Valid then
do shell script ("sudo -u " & userName & " mkdir ~/Desktop/" & userName & "
&& mount -t smbfs //sjdfs01.ehi.ehealth.com/" & userName & "$ ~/Desktop/" & userName & "")
end if
Also, by virtue of how this script works, there is a folder left on the desktop of the machine. So I have another unmount script I was going to program for logout, but it wiped out my test share contents. That script is below. What am I doing wrong here?
#Get current user name
set userName to short user name of (system info)
#Unmount Share, Delete Folder, Empty Trash
do shell script ("umount -f ~/Desktop/" & userName & " && rm -r ~/Desktop/" & userName & " && rm -rf ~/.Trash/*")