Auto mount Network drive?

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Auto mount Network drive? Sat Dec 21, 2019 9:46 pm • by Corab
Is there a way to mount network drive automatically through Hazel? I have an SMB share that disappears all the time throughout the day (sleep/wake/restart Mac etc causes it to unmount). So Hazel rules don't work when it happens. I tried to add the share to my Login Items - doesn't help much.

Is there a way to set Hazel to try to auto-mount network drive if it's not available?
Thank you!
Corab
 
Posts: 10
Joined: Thu Dec 19, 2019 5:57 pm

Re: Auto mount Network drive? Sat Dec 21, 2019 10:57 pm • by luomat
There are ways to mount a network drive with AppleScript.

You can have Hazel monitor /Volumes/ and if the drive is not there, run the AppleScript.
luomat
 
Posts: 78
Joined: Wed Mar 10, 2010 3:57 pm

Re: Auto mount Network drive? Tue Dec 24, 2019 3:34 am • by Corab
luomat wrote:There are ways to mount a network drive with AppleScript.

You can have Hazel monitor /Volumes/ and if the drive is not there, run the AppleScript.


Thank you! But unfortunately it doesn't help. The network drive is in there, I see the share in the /Volumes list. But Hazel doesn't detect that its contents have been changed. It only detects the contents change on the network drive when I manually access it (by opening the /Volumes/[share name] folder in Finder or Terminal).
Corab
 
Posts: 10
Joined: Thu Dec 19, 2019 5:57 pm

Re: Auto mount Network drive? Tue Dec 24, 2019 12:00 pm • by Corab
It seems Hazel doesn't work well with network drives, I was very close to buying it. Hopefully in the future that can be fixed. Thank you!
Corab
 
Posts: 10
Joined: Thu Dec 19, 2019 5:57 pm

Re: Auto mount Network drive? Thu Dec 26, 2019 1:16 pm • by Mr_Noodle
How long are you waiting? Note that under macOS, file events (the things that trigger Hazel) are not available for network drives so Hazel has to check every few minutes.
Mr_Noodle
Site Admin
 
Posts: 11250
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Auto mount Network drive? Thu Dec 26, 2019 6:36 pm • by Corab
Thanks for the answer!
I was waiting for an hour, nothing happened. When I manually opened the drive in Finder then the Hazel immediately started to copy files.
How often does it check for the network drive?
Corab
 
Posts: 10
Joined: Thu Dec 19, 2019 5:57 pm

Re: Auto mount Network drive? Fri Dec 27, 2019 1:42 pm • by Mr_Noodle
Every few minutes. If it isn't firing, you should turn on debug mode (https://www.noodlesoft.com/kb/hazel-debug-mode/) and check the logs.
Mr_Noodle
Site Admin
 
Posts: 11250
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Auto mount Network drive? Fri Dec 27, 2019 2:05 pm • by Corab
Mr_Noodle wrote:Every few minutes. If it isn't firing, you should turn on debug mode (https://www.noodlesoft.com/kb/hazel-debug-mode/) and check the logs.


Thank you! This is what I see in the logs (Volumes/AutoImport is the folder I'm watching, it's an SMB network share). It seems the folder is nor accessible, but when access it manually (through Finder or Terminal) it reappears without any errors.

2019-12-27 10:02:07.494 HazelHelper[772] DEBUG: Thread 0x600002eb9100: Timer fired for folder: /Volumes/AutoImport
2019-12-27 10:02:07.494 HazelHelper[772] DEBUG: Thread 0x600002eb9100: Run worker for folder: /Volumes/AutoImport
2019-12-27 10:02:07.583 hazelworker[21141] Running worker (v4.4.3) for folder with identifier: 889192459-2.
2019-12-27 10:02:07.585 hazelworker[21141] ###main load address: 0x104642000
2019-12-27 10:02:07.585 hazelworker[21141] ###Noodle load address: 0x104763000
2019-12-27 10:02:07.585 hazelworker[21141] ###CK load address: 0x10472b000
...
2019-12-27 10:02:07.695 hazelworker[21141] Scan folder is not accessible. Exiting.
2019-12-27 10:02:07.699 HazelHelper[772] DEBUG: Thread 0x600002eb9100: Task removed: [21141]
2019-12-27 10:02:07.699 HazelHelper[772] Worker process for folder /Volumes/AutoImport did not check in.
Corab
 
Posts: 10
Joined: Thu Dec 19, 2019 5:57 pm

Re: Auto mount Network drive? Mon Dec 30, 2019 12:01 pm • by Mr_Noodle
Is AutoImport the actual mount point you want to automount? If so, Hazel may not work for this purpose. Thinking about it more, you might have to do some sort of rigamarole of watching the root folder, matching Volumes if it doesn't have that folder, then running a script.

An alternative is to create some file in /Volumes. Have a rule match with a condition like "Date last matched is not in the last X minutes" and then run the script. It will basically end up polling every X minutes.
Mr_Noodle
Site Admin
 
Posts: 11250
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Auto mount Network drive? Tue Dec 31, 2019 5:10 pm • by Corab
Yes, it's the actual point. Also the folder is always there, it doesn't disappear. The weird thing I can access it with any software including Finder, Terminal etc., but Hazel starts displaying that error after a while.

BTW this is what I see in Hazel logs after I access the folder with other software:

2019-12-31 13:14:12.712 HazelHelper[992] Monitored path changed from /Volumes/AutoImport to /Volumes/AutoImport. Rescheduling folders.

I'm not sure if "Date last matched is not in the last X minutes" will help in that case, but I will try.
Thank you and Happy holiday season!
Corab
 
Posts: 10
Joined: Thu Dec 19, 2019 5:57 pm

Re: Auto mount Network drive? Thu Jan 02, 2020 6:45 pm • by Corab
Mr_Noodle wrote:Is AutoImport the actual mount point you want to automount? If so, Hazel may not work for this purpose. Thinking about it more, you might have to do some sort of rigamarole of watching the root folder, matching Volumes if it doesn't have that folder, then running a script.

An alternative is to create some file in /Volumes. Have a rule match with a condition like "Date last matched is not in the last X minutes" and then run the script. It will basically end up polling every X minutes.


Thanks again for the hint. It doesn't work. Should I assign this script to the empty folder in Volumes? I did it but the Hazel rule never runs. I even created a file inside that empty folder. Didn't help. Here's the screenshot of what I did:

Image

It does say
2020-01-02 14:45:05.134 hazelworker[22125] Processing folder DONOTDELETE-EMPTYFORHAZEL
2020-01-02 14:45:07.139 hazelworker[22125] Done processing folder DONOTDELETE-EMPTYFORHAZEL

But in reality the AppleScript is never run.

Is there a way you can post a working example? Thank you!
Corab
 
Posts: 10
Joined: Thu Dec 19, 2019 5:57 pm

Re: Auto mount Network drive? Fri Jan 03, 2020 11:59 am • by Mr_Noodle
You should be using "not in the last minute". See if that works.
Mr_Noodle
Site Admin
 
Posts: 11250
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Auto mount Network drive? Sun Jan 05, 2020 5:13 pm • by Corab
Mr_Noodle wrote:You should be using "not in the last minute". See if that works.


Haha, my mistake, sorry.

Cool! Seems to be working now. Here's my rule (basically I'm emulating Finder browsing the folder):

Image

Thanks again for your support and an excellent software!
Corab
 
Posts: 10
Joined: Thu Dec 19, 2019 5:57 pm


Return to Support