Jump to content
SNS Users' Forums
  • Announcements

    • Eric Newbauer

      Follow SNS on Twitter!

      Get notifications via Twitter! Looking for instant updates? We're now also announcing new versions and beta programs via Twitter. Follow Studio Network Solutions on Twitter. Thanks!
chezpaul

Scripting the connect/mounting and unmounting/disconnect on Mac OS X Sierra

Recommended Posts

I would like to make the connecting and mounting a faster thing.

Is GlobalSAN scriptable? Anywhere I can find script examples in order to connect/Disconnect and mount/unmount my iSCSI drives?

On a mac. So it could be applescript or bash.

Thanks

Share this post


Link to post
Share on other sites

Hello,

Checking the Persistent box for the target in globalSAN will set it to always attempt a connection when the machine starts, so there's no need for scripting for the initiator, but are you also using SANmp to manage shared SAN storage?

Share this post


Link to post
Share on other sites

I know about persistent and I do not want to use that. I'm using a MacBook pro, so portable and I put it to sleep every time I go to work and vis versa when I get home.

It's getting to be really annoying to unmount, open pref pane, disconnect and vis versa when I get back home. So I would like to script it. Click the script. Bam.

My Target is on a QNAP Das so i'm not using SANmp.

Share this post


Link to post
Share on other sites

Ah, understood! In that case, the initiator does provide a CLI. You'll find the options in Section 3.3 of the guide in the /Applications/globalSAN folder.

Share this post


Link to post
Share on other sites

Yes, I did find the CLI but gsutil does not work in terminal on OSX. I gives me a "command not found".

What do I need to install and from where in order to make this work?

Thanks

Share this post


Link to post
Share on other sites

I was surprised to find this seems to be missing from our globalSAN documentation, but you'll find gsutil in /opt/local/bin.

Thank you for drawing our attention to it, and I'll make sure that gets added to the manual!

You may also wish to set the PATH variable rather than navigating to the appropriate directory each time you use it. By doing this, you can access the CLI immediately after opening Terminal, and it will persist after rebooting. To set the path permanently, create the file

.bash_login

in your home folder, containing the following command:

PATH=$PATH:/opt/local/bin

If this file already exists, simply add that line to the end of it. The next time you start the Terminal window, your new path will be active.

We apologize for the oversight. Let us know if we can help with anything else!

Share this post


Link to post
Share on other sites

Almost a year later I'm back.. Wow, time flies.

I never got to automate this. I went with the free github sourced OSX Initiator, have been using it for a year but I don't like that you have to disable the system lock in order to install and use. So I think I will be buying your globalsan version.

This is what I used for the github initiator through an automator script that ran this in the terminal.

on run {input, parameters}
	tell application "Terminal"
		activate
		do script with command "iscsictl login iqn.2004-04.com.qnap:ts-251:iscsi.nasphotos.02d665,192.168.1.44:3260"
	end tell
	tell application "Finder"
		set visible of process "Terminal" to false
	end tell
end run

What would be the equivalent using globalsan? Or where is this manual you are talking about above?

 

 

 

Share this post


Link to post
Share on other sites

So I'm trying to get my feet wet and it doesn't seem like gustily is responding.

Last login: Thu Dec 28 08:23:07 on console
[Naths-MacBook:~] nathalie% cd /opt/local/bin
[Naths-MacBook:/opt/local/bin] nathalie% gsutil --list
gsutil: Command not found.
[Naths-MacBook:/opt/local/bin] nathalie% ls
gsutil
[Naths-MacBook:/opt/local/bin] nathalie% gsutil
gsutil: Command not found.
[Naths-MacBook:/opt/local/bin] nathalie% gsutil --list
gsutil: Command not found.
[Naths-MacBook:/opt/local/bin] nathalie% sudo gsutil -l
Password:
sudo: gsutil: command not found
[Naths-MacBook:/opt/local/bin] nathalie% gsutil -l
gsutil: Command not found.
[Naths-MacBook:/opt/local/bin] nathalie% sudo gsutil -l
sudo: gsutil: command not found
[Naths-MacBook:/opt/local/bin] nathalie%

When asked for the password, I inserted the mac's password (as I was using sudo)

But you'll notice gsutil -l was only understood once for some reason.

Share this post


Link to post
Share on other sites

I got it working

Thought I'd share the script here.

This is my disconnect script. You need to run diskutil list in terminal while the target disk is mounted on your desktop in order to find what name the volume has. In my case it's disk2s2.

do script "" in window 1 allows the script to happen all in the same window, otherwise it launches a new window per command.

For the Connect script, just change disconnect to connect and take out the first 2 commands.

tell application "Terminal"
	reopen
	activate
	do script "diskutil unmount /dev/disk2s2" in window 1
	delay 4
	do script "cd /opt/local/bin" in window 1
	delay 2
	do script "./gsutil --disconnect 4C2XXXXX-DE1E-4C6A-BABE-XXXXX7F61763" in window 1
end tell
tell application "Finder"
	set visible of process "Terminal" to false
end tell

Then I just made the 2 scripts into services with the help of Automator. Works like a charm.

 

EDIT: I tried the bash thing but it wouldn't work, so I just use cd

Share this post


Link to post
Share on other sites

×