-
Notifications
You must be signed in to change notification settings - Fork 2
/
Mount Remote Directory With SSHFS.applescript
37 lines (27 loc) · 1.18 KB
/
Mount Remote Directory With SSHFS.applescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
-- Mounts a volume with SSHFS
on mountWithSSHFS(volumeName)
set username to "username" -- Remote server user login
set server to "server.domain.com" -- Remote server address
set workingDirectoryPath to "/" -- Working directory on the remote server to be mounted
set volumesDirectoryPath to "/Volumes"
set SSHFSBinaryPath to "/usr/local/bin/sshfs" -- Simple "sshfs" does not work for me
-- Options: caching, automatic reconnect, set volume name to volumeName variable value
set options to "'auto_cache,reconnect,volname=" & volumeName & ",uid=501,gid=20'"
if not isVolumeMounted(volumeName) then
do shell script "mkdir " & volumesDirectoryPath & "/" & volumeName
do shell script SSHFSBinaryPath & " " & username & "@" & server & ":" & workingDirectoryPath & " " & volumesDirectoryPath & "/" & volumeName & " -o " & options
end if
end mountWithSSHFS
on isFileExist(fileName)
tell application "Finder"
return exists fileName as POSIX file
end tell
end isFileExist
on isVolumeMounted(volumeName)
return isFileExist("/Volumes/" & volumeName)
end isVolumeMounted
-- Alfred.app entry point
on alfred_script(q)
set volumeName to (q as text)
mountWithSSHFS(volumeName)
end alfred_script