macOS users - AutoMount your Shares


Recommended Posts

  • Replies 232
  • Created
  • Last Reply

Top Posters In This Topic

Don't know whether this can be fixed. In case the array is taken off-line (stopped), the unmounted shares stay in /Volumes, not as mounts but in stead as folders. After the shares are brought back on-line, the script returns that the shares are already mounted. Maybe there is another way, but only after deleting the (empty) folders in /Volumes, the script will (re)mount the shares.

 

 

Link to comment

Strange, that doesn't happen with me. Are you sure you're using launchd from your user folder? Eg, /users/admin/library/LaunchAgents/com.media.mount.plist ?

 

Might want to repair permissions as well.

 

I could add in a check so when the array is offline it'll check if there are the folders still in /Volumes. If there are it will attempt to umount, then check if there's anything in the folders. If there isn't then it'll delete them.

Link to comment

Let me try and describe what happens (non native English...).  My starting point is that all shares are normally mounted (all OK), when I stop the unRAID array (with unRAID's browser Management Utility), the shares will nicely unmount and /Volumes is empty (all OK). When the script runs again (after, say 40 seconds) it creates the folders in /Volumes - obviously the script cannot mount the shares because the array is still off-line. When I then start the array, the shares are available but the folders are still there and for that reason the script cannot mount the shares.

 

Hope this is clear.

 

BTW: Yep, I'm using launchd from the user folder. Will try again after permissions are repaired. 

Link to comment

Replicated issue. Re-uploaded script with new function. As unRAID doesn't turn off CIFS you can still access that port, which means I have to do checks at the time it mounts. So it creates a folder for the mountpoint, then tries to mount. If it can't mount the share then it will give you an error message. It will then check if the mount point has files in it. If it doesn't then it will remove that directory. If it does, then it will spit an error and move onto the next share.

 

Before you run it, make sure those folders aren't in your /Volumes folder, and try again. From now you shouldn't get that issue again.

 

I didn't want to do the check at the beginning of the script, as it would keep the drives spinning at all times as it continually does checks on the shares. The way I've done it means that it only does the check if there's an error mounting the SMB share.

 

Cheers

Link to comment

This is great, really helped me out.  A few tips for other newbies like me who may still run into problems:

1.  I tried editing the file after it didn't initially work and found I could not edit it with the permissions set to 775.  I just changed them to 777 and that worked for me.

2.  When troubleshooting I found that /Scripts/mount.sh did not work for me, I got an error the the file could not be run.  I changed it to /Scripts/sh mount.sh and that worked.

3.  I did not have user permissions setup and could not make this work for me.  It wanted a password and I was running a pretty plain install of unRaid with no root password or user permissions setup.  I was not sure if I would break other things by adding a root password so I just setup user security with passwords and then this script worked wonderfully.

 

 

Link to comment

I USED a program called MarcoPolo to do pretty much what this script is doing... I think... if I understand what it is doing.

 

I have started messing with a Mac application called Airport Location which seems to work pretty well.  It is a little tricky to get set up but it can do SO MUCH that I think it is worth it.

Link to comment

The advantage for me over programs like Marco Polo or Hazel is that they seem to only remount when they detect a network change.  They all failed miserably for me when I restarted my unraid box.  This script checks every minute to see if the unraid server is online and if not it unmounts the shares, then mounts them again when the unraid server is available again.  I have no need for anything like this on my windows computers but Mac's seem pretty dumb about auto-reconnecting so this has been a huge help.  I even tried the nfs mounts route on my mac as that was supposed to support automatically reconnecting as needed but it just didn't work well, it seemed to get confused after reboot and did not fully enumerate the files on my shares after I rebooted my unraid server.  So far since running this script everything has just worked.

Link to comment

The advantage for me over programs like Marco Polo or Hazel is that they seem to only remount when they detect a network change.  They all failed miserably for me when I restarted my unraid box.  This script checks every minute to see if the unraid server is online and if not it unmounts the shares, then mounts them again when the unraid server is available again.  I have no need for anything like this on my windows computers but Mac's seem pretty dumb about auto-reconnecting so this has been a huge help.  I even tried the nfs mounts route on my mac as that was supposed to support automatically reconnecting as needed but it just didn't work well, it seemed to get confused after reboot and did not fully enumerate the files on my shares after I rebooted my unraid server.  So far since running this script everything has just worked.

 

Fair enough, I just disable Airport or unplug the Ethernet cable to get the drives to disconnect (or do it myself).  From there I re-enable Airport and MarcoPolo does its thing.

 

With Airport Location you can "reapply snapshot settings" which will remount/reconnect to all the shares.

 

Some may not need the extras that these programs can provide, but I like them as I can set up different settings for different locations.  Works a treat for me!!

Link to comment

 

Fair enough, I just disable Airport or unplug the Ethernet cable to get the drives to disconnect (or do it myself).  From there I re-enable Airport and MarcoPolo does its thing.

 

With Airport Location you can "reapply snapshot settings" which will remount/reconnect to all the shares.

 

Some may not need the extras that these programs can provide, but I like them as I can set up different settings for different locations.  Works a treat for me!!

 

You obviously don't run a mini connected to a home theatre!

 

Can you imagine having to go behind the mini and unplugging the ethernet or gasp, finding a keyboard to use and disconnecting manually? AHH!?!?!

 

Your situation is fine if you're using a laptop or iMac, but horrible if you have any kind of automated setup and rely on the drives being available.

 

Link to comment

You speak the truth.  The fix for me is always to restart my mini, doesn't require me getting up off the couch at least :D

 

Still, having to restart it every time I changed a setting in unraid that caused me to restart the array was getting old.  I realize in time my unRaid server will just sit there and hum away for years on end but while I am new to it and installing new apps, changing config, etc., I was restarting it on a daily basis and my Mac Mini did not like it.

Link to comment

You obviously don't run a mini connected to a home theatre!

 

Can you imagine having to go behind the mini and unplugging the ethernet or gasp, finding a keyboard to use and disconnecting manually? AHH!?!?!

 

Your situation is fine if you're using a laptop or iMac, but horrible if you have any kind of automated setup and rely on the drives being available.

 

You are correct, I user a laptop as my primary machine so the above script would not suit my needs perfectly.

Link to comment

It could be integrated to do all sorts of things. If you wanted it to mount or unmount depending on location change, check this page:

 

http://tech.inhelsinki.nl/locationchanger/

 

You can modify the launch agent for changes to the system config (changes when you move between networks), and get it to run the script then.

 

Right, and while it will work it has to be done "manually." MarcoPolo/Airport Location takes care of all that for me once I get it set up.

Link to comment

The difference between tools like you are referring to and the script written here is those tools monitor to see if the computer they are running on has changed, has it gone to sleep, woken up, had a port plugged in, turned wireless on or off, changed location, what they are all missing (and I would love to see added) is monitoring if things externally have changed.  In this specific case, has a server I am connected to gone offline.  If they supported that simple functionality they would do the job perfectly, and if you find one that does that please update the thread because I would jump right in and use it.

 

Until then, while this script may not be quite as easy to configure it at least does the intended task, monitor my unraid server and perform an action based on whether or not my unraid server is reachable.  It's not perfect, but it's a damn good start.  Unfortunately since it monitors if the unraid server is up by ping it means if won't work if I just stop and start my array, but that is easy enough to work around, now whenever I stop my array I make sure to actually reboot my unraid server instead of just starting it again, that forced the network offline for a minute which is long enough that this script unmounts and remounts my shares. 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.