macOS Sierra Automount on Startup

I have a little Script as Startup-Object:

https://picload.org/image/rrrpioli/bildschirmfoto2016-07-06um17.3.png


In this Script 2 Shares from my NAS (nas.box) and a Raspberry Pi (Raspi3) should mounted on Startup. This worked with El Capitan without problems. Since macOS Sierra Beta 1 the Script loads and mounting starts after startup but asks for my Login-Data. Username an Passwords are filled, but i must click on "Connect". For the NAS-Share, the Option to store the Login-Data to Keychain is checked. On the Raspberry-Share it's not checked, but the User-Data are also filled.


https://picload.org/image/rrrpioli/bildschirmfoto2016-07-06um17.3.png


https://picload.org/image/rrrpiolw/bildschirmfoto2016-07-06um17.3.png


The Problem is, that this occours every time, when i reboot my Mac or Logout/Login to my User-Account. I've tried to delete the Objects from Keychain, but it doesent change anything.


Any suggestions?

But what would the command be to unmount that same volume? I need to mount it (works), do something and then unmount it again, all scripted.

Many thanks in advance!

Thank you so much for this solution. I have been trying to find a perfect solution to mounting a network drive at login and this is the best one yet. I have been so frustrated having to enter the same username and password over and over. For some reason it never remembered my credentials and now it does.


Thank you.

Yes I can confirm this works... you have to use the IP adres of the shares... not the existing links you have been using so far...

But to anyone experiencing this issue, I do not really mind the password question, however the first drive I try to mount via the script gets duplicated under "volumes".


My script:

tell application "Finder"
  try
  mount volume "afp://TS431(AFP)._afpovertcp._tcp.local/Documents"
  mount volume "afp://TS431(AFP)._afpovertcp._tcp.local/Music"
  mount volume "afp://TS431(AFP)._afpovertcp._tcp.local/Video"
  mount volume "afp://TS431(AFP)._afpovertcp._tcp.local/Photography"
  end try
end tell


Now when it runs, it immediately creates a "documents" folder in /Volumes/

Then it asks my password and then connects the drives. However, because "Documents" is already there, it creates the 'real' drive on "Documents-1". When I then disconnect the drives and connect them again via the script, they create a "documents-1" and "documents-2". This changes the path of the drive which gives me problems with applications that do not know the updated path.


The weird thing is that when I do connect manually via finder this does not happen although it still asks for the password.


Any ideas how to solve that?

you can try to unmount the documents-volume, before you try to mount it again.


but there is an original-(apple-)"documents" folder in your User-Folder, so, it could be useful, to rename your network-folder to "mydocuments"....

i tweaked my applescript to klick the dialog box button by spawning a second applescript via shell right before my first (main) script issues the mount command - like this:


do shell script "

osascript -e 'delay 2 -- initial wait period until the server login/password box appears

tell application \"NetAuthAgent\" to activate

tell application \"System Events\" to keystroke return

delay 1 -- secondary wait period until the volumee chooser box appears

tell application \"NetAuthAgent\" to activate

tell application \"System Events\" to keystroke return' > /dev/null 2>&1 &"


very important: the "> /dev/null 2>&1 &" allows the "main" applescript to continue before the shell applescript ends, thus allowing two scripts to run in parallel

How do you add the server icon to the dock menu (what are the steps to do this)…maybe I'm making this more complicated that it is?

I get the same error using the mount_afp command. Figure that one out yet?


I also get the following error when trying to use the mount smbfs command as well:

error "usage: mount [-dfruvw] [-o options] [-t external_type] special node
       mount [-adfruvw] [-t external_type]
       mount [-dfruvw] special | node" number 1


Any ideas?

Open a Finder window, click on a network share (icons on the left).

Right-click on the Finder window title (over the name of the network share) and click below it on 'Network' (this is the parent folder, containing all network servers).

Now you have the server icon, which you can drag to your dock.

At least for me, this trick does not avoid the system asking for credentials for the first time! But it speeds up greatly the server discovery & connection to shares. Thanks!

Sounds very reasonable – but doesn't change the situation under Sierra (clickable mount-dialog appears).

YES – helped instantly on two devices (10.12.1), same NAS (Synology, fully updated)🙂

Volume appeared at reboot like magic – now it's normality, again…

Wasted time (until reading here, developer account etc) more than eight hours.


Thank you, Apple

Problem finally solved by Apple with OSX 10.12.2

See also the following article to modify the authentication behavior;


https://support.apple.com/en-us/HT207112

You need to drag the folder for the network share into the dock, not the network server.


For example:

1) Connect to your network share (i.e. smb://192.168.1.50/Media)

- Open Finder

- In the menu bar, Go -> Connect to Server

- Type server address and hit Connect

- Provide credentials if prompted (check to remember credentials in keychain)

- Choose share from list to access

2) Open the network server from Finder (on left side under "Shared"). The list of shares for this network will appear on right.

3) Drag the folder for the share you want to the dock on the right side (i.e. next to the Trash)


You should be automatically mounted and connected to the share upon restart. This works like a charm for me. Simple solution!

3D Touch

on macOs 10.12.2 same issue with getting prompted for a username and password even though I added it to my keychain, but changing the mount point worked. I noticed the mounts still show up in /Volumes even though I instructed them to go to /Users/machome/Mounts? Not too sure how it knows they are mounted even though I have it check my new Mount folder?


tell application "Finder"
  if not (disk "/Users/machome/Mounts/views" exists) then
  mount volume "smb://network_machine/viewes
  end if
end tell

How was it solved?

I use a similar script and have encountered the same sort of screwy icons and folder behaviors. Did you find a resolution?

Thanks, R-M-B!


This fixed it for me. In fact, this is what should be marked as the answer now I think, as it's a workaround from Apple themselves finally.

Hi!


I have made a shell script which parses a .plist file and mounts the listed shares. All the needed passwords for these shares are NOT stored in the script but retrieved from the local keychain.

Have a look at https://github.com/gniemetz/automount/blob/master/automount.sh


Hope this helps!


best regards

Gerd

I'm monitoring thes thread closely. It's a real shame that Apple is not making this a priority. Apple is having a huge presence in the enterprise now, yet can't get basic, simple NAS functionality going. It's an embarassment actually.

I finally upgraded my work machine to Sierra a few weeks ago. I was a bit concerned because of threads like this one. But I can confirm that a true automount via autofs still works fine in Sierra. I'm not using a NAS through. I have an Active Directory environment with a Linux SMB server. Do any of these NAS devices support login authentication via Active Directory or Open Directory? Once I'm logged into the network, I can mount SMB shares with no trouble via entries in /etc/auto_master and similar. Clearly, this is the environment that Apple supports. I've never had a NAS so I don't know if they can be configured to provide a real directory service with authentication.

It seems odd. Aren't firewalls and sharing rules supposed to help with this issue?

I can confirm this is working with mount_smbfs as well... (except without -t)


😀

Are you able to help me? I want the exact same functionality you do so I decided to use your script, but every time I try to go and save it as an application using AppleScript, I get a Syntax error Expected "end" but found unknown token.


I'm not a programmer, so am not able to self debug. 😕



All I've been able to do so far is Launch Apple Script Editor and pasted the script following =========== below and tried to hit save. Can you help me understand what I'm doing wrong please?



===========


set NrMounted to 0

set MaxMount to 2 -- max number of networkshares to mount

set NrTries to 0

set MaxTries to 5 -- max tries before quit

repeat while NrMounted is not MaxMount and NrTries is not MaxTries

set theWifi to "VancityGuyWifi" -- the wifi SSID

set theList to paragraphs of (do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s| awk '{print $1}'") -- get the wifi list

set EthernetStatus to do shell script "ifconfig en0 | grep 'status' | cut -d ':' -f 2 | tr -d ' '" -- get ethernet status

if theList contains theWifi or EthernetStatus = "active" then


if MountedSuccessfull("Volume_1") then set NrMounted to NrMounted + 1

if MountedSuccessfull("Volume_2") then set NrMounted to NrMounted + 1



end if

set NrTries to NrTries + 1

delay 10 -- waiting time before next try

end repeat

on MountedSuccessfull(VolumeName)

set NASUserCredentials to "username:password"

set NASIP to "100.100.100.2"

set MountPointFolder to "/Users/Vancityguy/NAS/"


set Mounted to false

set serverAddress to NASUserCredentials & "@" & NASIP & "/" & VolumeName

set mountPoint to MountPointFolder & VolumeName

tell application "Finder"

try

if disk VolumeName exists then -- it's presumable already mounted

else

with timeout of 3 seconds -- try to mount

do shell script "[ ! -d " & mountPoint & " ] && mkdir -p " & mountPoint & " || echo directoryOK" -- create the folder to host the mount point if it doesn't already exist

do shell script "mount -t smbfs /

set Mounted to true

end timeout

end if

end try

end tell

return Mounted

end MountedSuccessfull

macOS Sierra Automount on Startup
 
 
Q