macOS users - AutoMount your Shares


Recommended Posts

  • 2 weeks later...
  • Replies 232
  • Created
  • Last Reply

Top Posters In This Topic

My setup is a Mac Mini running a Windows Home Server (WHS) virtual machine. Plex on the Mini plays media content stored on the WHS. If Plex 9 had the ability to mount SMB shares, my life would be simple. However, it doesn't, and the developers suggest adding the mounts to the Mac user login items. This is a non-starter in my case because the WHS virtual machine isn't even running when the user logs in so none of the shares are up. This script is exactly what I needed to watch for the WHS to come up, and then mount the shares.

 

I have one small suggestion. The standard location for scripts like this in UNIX-like systems is /usr/local/bin. See:

http://en.wikipedia.org/wiki/Unix_directory_structure

Link to comment

My setup is a Mac Mini running a Windows Home Server (WHS) virtual machine. Plex on the Mini plays media content stored on the WHS. If Plex 9 had the ability to mount SMB shares, my life would be simple. However, it doesn't, and the developers suggest adding the mounts to the Mac user login items. This is a non-starter in my case because the WHS virtual machine isn't even running when the user logs in so none of the shares are up. This script is exactly what I needed to watch for the WHS to come up, and then mount the shares.

 

I have one small suggestion. The standard location for scripts like this in UNIX-like systems is /usr/local/bin. See:

http://en.wikipedia.org/wiki/Unix_directory_structure

 

Cheers for the feedback!  Issue is that OS X hides all unix folders, so for the newbies sake it is located /Scripts.  You can change the directory to your preferred folder in the settings.

 

Still having issues with how OS X sometimes doesn't unmount shares if the server is turned off. There's no easy way yet to force them to unmount without checking folder contents. If I integrated that into the script then the drives would never spin down. UnRAID doesn't turn off any ports as far as I can see, so I stopped at that point. Unless there's a wget / curl command, E.g http://tower/main?=stopped responds true or false?

 

Otherwise, it works well with AFP, which actually tells the computer that unRAID has stopped so it can unmount. SMB isn't as smart  :)

Link to comment

Speeding_ant & Stokkes thank you very much for this. I love that script !!

 

I'm using it with the latest AFP support of unRAID 5b4. The one question I have is the following:

 

Is it possible to define a second protocol? Namely NFS would be great as I symlinked the ~/Library/Application Support/XBMC/userdata directory to the unRAID server which is needed to synchronize all the XBMC consoles at my home.

 

I don´t know if another option would be to establish a symlink via AFP ??

Link to comment

I could potentially integrate a secondary protocol, but you're probably better off using a symlink through an AFP share. That's how I sort out my iTunes folder. NFS can be a pain to deal with, better off using a protocol that Apple can support really well.

 

You could also look into managed preferences to create a folder redirection on login. However, that does require the server to be available at all times.

 

Cheers

Link to comment
  • 1 month later...

So I set this up and added the shares like

 

# Shares, check notes

SHARES="Our%20Movies Our%20Music Our%20Files cache"

 

I mounts tower, but I do not she the shares listed in the side bar.  I can see all the shares, not just the ones I set in the script in the tower folder.  Does this script mount the individual shares under the shared section on the side bar?  Or am I missing something?  Even just mounting tower works great.  Thanks. 

Link to comment

Are the volumes showing up on the desktop? Make sure you have this setting turned on in the finder preferences first.

 

Double check the instructions, and make sure that the launchd preference file is being run from your user folder. If you're running the script from terminal, make sure you're not running it as root.

 

It should show up on the sidebar, but sometimes it can take finder a while to discover the server and show it. The volumes should still mount, and will eventually show as mounted in the sidebar. If you're using UnRAID 5.0 beta 5b then switch to AFP.

 

Cheers

Link to comment

I got this error

 

com.mount.media[188] mount_smbfs: mount error: /Volumes/tvixhd1: No such file or directory

 

So it's looks like the script is not looking to my mac drive, so perhaps this must be entered in the script , so it's look to my mac partition

 

tvixhd1 is my share

Link to comment

Ok when I check show connected servers in the finder preferences it does show the shares I selected.  I guess I has hoping they would show up in the side bar.  I don't really like things on my desktop.  Tower does show up in the side bar right away which is great too.  So even if I don't have the shares listed there, it's still a nice feature.  Otherwise like you say you might have to wait a while until tower shows up.  I don't have the 5.0 Beta yet, I don't want to test it on my primary server.  Thanks again for the help at least I know the script is working as designed. 

Link to comment

I have the itunes check set to false since I don't have itunes on my unraid box.  But when I have it set to false Itunes will quit after a minute.  When I set the check to true everything worked again.  I was wondering if it is possible to modify the script so there could be an itune integration True false variable and if the user sets false have it skip the entire section for checking itunes and if true it goes about checking if the drives are mounted then opening or closing itunes.  Maybe it is already this way, but I seem to be having a problem with it when itunes is set to false. 

Link to comment

I got this error

 

com.mount.media[188] mount_smbfs: mount error: /Volumes/tvixhd1: No such file or directory

 

So it's looks like the script is not looking to my mac drive, so perhaps this must be entered in the script , so it's look to my mac partition

 

tvixhd1 is my share

 

That error means it's trying to mount the smb share into that particular folder in the Volumes directory, but it's not there.

 

The script attempts to create a folder in the /Volumes directory. You'll need to double check and make sure that there's no permissions issue stopping the script from creating that directory.

Link to comment

I have the itunes check set to false since I don't have itunes on my unraid box.  But when I have it set to false Itunes will quit after a minute.  When I set the check to true everything worked again.  I was wondering if it is possible to modify the script so there could be an itune integration True false variable and if the user sets false have it skip the entire section for checking itunes and if true it goes about checking if the drives are mounted then opening or closing itunes.  Maybe it is already this way, but I seem to be having a problem with it when itunes is set to false. 

 

Modified script, there is an additional option where you can set iTunes to not quit if server isn't available. It is under the iTUNES open option.

 

Cheers

Link to comment

Restart the computer and try again. Don't have server on to check, but haven't changed anything to do with mounting at all?

 

If it's saying that it's mounted already, the folders might still be there in /Volumes. Might be worth checking if they're still there on restart, and if they are then move them to the trash.

Link to comment

Added functionality to wake the server via WOL.

You must have wolcmd (included) in the same folder as the script. This is a definable directory. If the server is unavailable via ping, WAKE is set to TRUE, and the time is within the hours specified, then the script will attempt wake on lan. You must have your server MAC address and subnet in the options. This is all shown in the script.

 

Download again to gain this functionality. wolcmd included.

Link to comment
  • 1 month later...

This was working ok, until a few days ago.

 

Here's my Console output:

 

May 19 22:12:14 defected07 com.mount.media[50266]: ping: sendto: Host is down
May 19 22:12:25 defected07 com.mount.media[50266]: PING 192.168.1.73 (192.168.1.73): 56 data bytes
May 19 22:12:25 defected07 com.mount.media[50266]: --- 192.168.1.73 ping statistics ---
May 19 22:12:25 defected07 com.mount.media[50266]: 1 packets transmitted, 0 packets received, 100.0% packet loss
May 19 22:12:25 defected07 com.mount.media[50266]: Waking Server
May 19 22:12:25 defected07 com.mount.media[50266]: Failed to send: Host is down
May 19 22:12:25 defected07 com.mount.media[50266]: Wake on Lan signal sent to MAC Address 001b21a48247
May 19 22:12:25 defected07 com.mount.media[50266]: via Broadcast Address 192.168.1.255 on port 7
May 19 22:12:25 defected07 com.mount.media[50266]: We should send 102 bytes we sent -1 bytes

 

When I manually run it through Terminal, I get this:

 


./mount.sh 
PING 192.168.1.73 (192.168.1.73): 56 data bytes

--- 192.168.1.73 ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.258/0.258/0.258/0.000 ms
Mounting Backup
Usage: file [-bcikLhnNrsvz0] [-e test] [-f namefile] [-F separator] [-m magicfiles] file...
       file -C -m magicfiles
Try `file --help' for more information.
Mounting Media
Usage: file [-bcikLhnNrsvz0] [-e test] [-f namefile] [-F separator] [-m magicfiles] file...
       file -C -m magicfiles
Try `file --help' for more information.

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.