Posted on 05-21-2016 05:39 PM
Hello Community,
since a few hours I try to create a little script to mount a smb share. Before the script mount the share he check it. If it is not mounted he mount it.
It works ok... Now I have a few permissions problem...
The Script create a folder called "Intranet", then he mount it. It works but I can't see the Intranet because the folder get the wrong permissions. The folder get the permissions root:wheel but I need "User":admin or "User":"Domain Group
Via Terminal I can see all files as root... My question, how I can change the permissions to the corretcly?
Here is the actuelly script:
#!/bin/bash
# Already mounted check
user=`ls -la /dev/console | cut -d " " -f 4`
isMounted=`mount | grep -c "/Volumes/Intranet"`
if [ $isMounted -ne 0 ] ; then
exit 0
fi
# Mount the network home
mkdir /Volumes/Intranet
sudo mount_smbfs //xxxx.xxxx/xxx/Intranet/Intranet/ /Volumes/Intranet
# end tell
# Script End
exit 0
I hope erveryone can help..
Many Thanks!
Christian
Solved! Go to Solution.
Posted on 05-21-2016 05:50 PM
Hello again!
I fixed the permission issue!
I forgot this "sudo -u $user" for the commands...
#!/bin/sh
sudo -u $user mkdir /Volumes/Intranet
sudo -u $user mount_smbfs //xxxx.xxxx/xxx/Intranet/Intranet/ /Volumes/Intranet
now it works!
Posted on 05-21-2016 05:50 PM
Hello again!
I fixed the permission issue!
I forgot this "sudo -u $user" for the commands...
#!/bin/sh
sudo -u $user mkdir /Volumes/Intranet
sudo -u $user mount_smbfs //xxxx.xxxx/xxx/Intranet/Intranet/ /Volumes/Intranet
now it works!
Posted on 07-25-2016 08:50 AM
I was just struggling with the same thing, and wanted to let you know that you helped me fix it. Thanks mate!
Posted on 07-25-2016 03:40 PM
If you make a call to the Finder to do it instead the system generally takes care of pretty much all of it for you as the currently logged in user, the protocol is just included in the path and then permissions, mount points, cleaning up on eject etc... all just get dealt with by the system.
osascript<<END
tell application "Finder"
mount volume "$Share_Path"
end tell
END
}
Share_Path would be something like smb://server.domain/share