Script to automount 1 local networkshare an 1 external networkshare

Hi,

I have one Synology NAS at home and one Synology NAS on an external place. On my MacBook I want to create a script that first mount the local NAS, wait 30 seconds (to let OpenVPN startup and connecting to my DDNS) and mount the external NAS.

When mounting both NASses, I will let the script checking if both shares still mounted and if not, try to remount.

I've created the code below but it looks like the script only runs te first lines and only mount the local NAS.

global startup
set startup to true

on idle
   if startup then
      mount_share("smb", "Lisa", "NAS_name", "Data/Mijn Afbeeldingen")
      set startup to false
      return 30
   else
      mount_share("smb", "Lisa", "NAS_name", "Data/Mijn Afbeeldingen")
      mount_share("smb", "Lisa", "IP-external NAS", "Backup Lisa")
      return 120
   end if
end idle


on mount_share(protocol, account, server, share)
   set x to 0
   -- try a few time in case the server has to wake up first.
   -- don't do anything if the share is already mounted
   repeat until x > 4 or (list disks) contains share
      tell application "Finder"
         try
            mount volume protocol & "://" & account & "@" & server & "/" & share
         on error
            set x to x + 1
            delay 30
         end try
      end tell
   end repeat
end mount_share

Hopefully someone can help me

Script to automount 1 local networkshare an 1 external networkshare
 
 
Q