Skip to content

Instantly share code, notes, and snippets.

@SamRothCA
Last active July 3, 2020 02:59
Show Gist options
  • Save SamRothCA/8ae670abfd60d6bab6e6 to your computer and use it in GitHub Desktop.
Save SamRothCA/8ae670abfd60d6bab6e6 to your computer and use it in GitHub Desktop.
set serverNames to {"Server 1", "Server 2"}
choose from list serverNames with title "Mount Drive via SSH" with prompt "Which system would you like to mount a drive to?"
set serverName to the result
if serverName is false then
-- Abort if the user cancelled
error number -128
else if serverName is {"Server 1"} then
set serverIP to "192.168.1.146"
-- Repeat for each server
else if serverName is {"Server 2"} then
set serverIP to "192.168.1.147"
end if
-- Get a list of items in /Volumes and present it to the user
set drives to paragraphs of (do shell script "/bin/ls /Volumes")
choose from list drives with title "Mount Drive via SSH" with prompt "Which drive would you like to mount on " & serverName & "?"
set driveName to the result
-- Abort if the user cancelled
if driveName is false then error -128
-- Format the drive name for the shell
set driveArg to the quoted form of (driveName as text)
do shell script "sudo nfsd update"
-- Generate the script to send over SSH
set SSHScript to "mkdir -p /mnt/HD_Archives/" & driveArg & "; mount ${SSH_CONNECTION%% *}:/Volumes/" & driveArg & " /mnt/HD_Archives/" & driveArg
log SSHScript
do shell script "ssh root@" & serverIP & " <<<" & (SSHScript's quoted form)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment