Sshfs script

Hi, I am new to this forum.

I want to setup my personal Dropbox between my home server and the work station in the office.

I followed this tutorial

danbishop.org/2011/09/10/...-in-os-x-lion/and it works great. :slight_smile:

The trouble now is I am not sure how I can make it to start on boot.

I have to enter this command every time after a reboot.
sshfs user@xxx.xxx.xxx.xxx:/Volumes/data/myDropbox /Volumes/data/Desktop/myDropbox
then enter the password.

After some research I made this script called myDropbox.sh

#!/usr/bin/expect
spawn sshfs user@xxx.xxx.xxx.xxx:/Volumes/data/htdocs/myDropbox /Volumes/data/Desktop/myDropbox
expect "Password"
send "myPwd\r"
interact

When I run it in Terminal, it seems like it was going to mount because after the password it returns to the $ prompt.
but it doesn't mount. :frowning:

Can someone tell me what I did wrong?

Thanks in advance.

P.S. I am on OSX 10.8.2

I usually start such with a frequent cron, and make the script discover if it is already running and exit if so. This can take many forms: bind to socket, writing a file, flag file, pid file. Not only do you get reboot restarts, you get restarts for any sort of crash.

However, automounts are the thing for mount points. Does sshfs allow automounts?

If it is ssh based, PPKeys is nicer than password.

Hi DGPickett, thanks for the reply. Please do excuse me, my knowledge in shell scripting is very limited.

"This can take many forms: bind to socket, writing a file, flag file, pid file"
I only need a simple script that can trigger the sshd
or something like that. , I am not concern regarding crashing, it's the boot that matters hence I don't believe corn or binding socket.... is necessary, or is it?

"However, automounts are the thing for mount points. Does sshfs allow automounts?"
May be I am wrong, this line does seem to mount nicely.
sshfs user@xxx.xxx.xxx.xxx:/Volumes/data/htdocs/myDropbox /Volumes/data/Desktop/myDropbox after I enter the password.

Basically I just need the line to execute and enter the password at boot.
I guess my question is why when I run this line user@xxx.xxx.xxx.xxx:/Volumes/data/htdocs/myDropbox /Volumes/data/Desktop/myDropbox in terminal works.
but not when I made it in the script.

Thanks again. :slight_smile:

One thing aboug ssh family commands is that they take the password from /dev/tty not stdin, so you need an expect layer or something similar to inject scripted passwords.

It is not so hard to set up trusted PPKey and not need a password.

A cron driven script might 'echo $$ >$HOME/.my_app_pid' after checking 'if [ 0 = $( ps -u $user -p $(<$HOME/.my_app_pid ) | grep -c $0 ) ]' to make sure old servers are not running. This is what I meant by pid file.