Sample Header Ad - 728x90

Automatically remount smb share on disconnect

0 votes
0 answers
135 views
I'm trying to write an Applescript to automatically remount an smb share when it is disconnected for whatever reasons. I have a script to check if the share is present in /Volumes and if not then mount it. This part is working fine, complete with error handling and retry 10x with delay. If I run this script manually, it works as intended. What I really want is for the script to get triggered automatically when the smb mount is lost so it can be remounted. So I set it up as a folder action and attach it to /Volumes using "Folder Actions Setup.app" But turns out the script only gets triggered when something is added, not when it is removed. I confirmed this by adding a display dialog "i am triggered" to the top of the script. So this is not helpful for my purpose. I attached the folder action to ~/Downloads instead and it's still the same -- only triggered when something is added, not removed. The reference on folder actions has "on removing folder items..." clause so this should work, but it doesn't. I'm on Sonoma 14.2 Anyone has any idea what is wrong? Thanks in advance
Asked by JBart (41 rep)
Dec 12, 2023, 10:24 PM