I had trouble with mounting directories and getting an input/output error. I tracked it down (http://blogs.bu.edu/mhirsch... to needing a trailing slash. Once I did that, though, rmount would only use the hostname for the mount directory, not the remote directory name. I ended up changing:
mname=${folder##*/}
to
mname=`basename "$folder"`
And semi-related to the whole mount discussion, here's a nifty one-liner that displays what's mounted in a nice format.
# -------------------------------------------------------------------
# nice mount (http://catonmat.net/blog/an...
# displays mounted drive information in a nicely formatted manner
# -------------------------------------------------------------------
function nicemount() { (echo "DEVICE PATH TYPE FLAGS" && mount | awk '$2="";1') | column -t ; }
Took me a few tries, but that url in there should be http://www.catonmat.net/blo... if anyone wanted to know :). Thanks for the tip, that's a good one.
I'm using zsh and when I add the rmount and remount functions to my .zshrc it objects to the `if [[ $2 ]]; then` line in the rmount function. Since it appears like this is only testing for the presence of a second parameter, I changed it to be `if [[ -n $2 ]]; then` where the `-n` returns true is the string is of non-zero length.
The rumount function also needs modifying on zsh. I added a `-d` to these four lines:
[[ -d $(mount|grep "mounts/$dir") ]] && umount ~/mounts/$dir
[[ -d $(ls ~/mounts/$dir) ]] || rm -rf ~/mounts/$dir
[[ -d $(mount|grep "mounts/$1") ]] && umount ~/mounts/$1
[[ -d $(ls ~/mounts/$1) ]] || rm -rf ~/mounts/$1
`-d` returns true if the file exists and is a directory.
As you note the rumount function is experimental I shall proceed with caution.
Great article - I can see sshfs and these functions saving me lots of time and effort.
For web projects, the short version is that --- in my ideal scenario --- I use a bare git repository on the server as my 'origin' remote, and have a post-receive hook that runs something like:
GIT_WORK_TREE=/deploy/path/ git checkout -f
That takes the contents of the repo and exports a clean copy to the live site. I can use a few tricks to deploy branches of the repo to different locations to create staging sites from the same repo. Then I can just test locally, push to origin and have my site deployed (with version control).
I'm currently using rsync to deploy my Jekyll site from my work machine. That may change. Beyond that I primarily use rsync for backup and scp for quick transfers between servers of things like public SSH keys and config files.
There, that was kind of a post, right?
Sure, that counts. Just what I was looking for. Thanks for sharing.
Since I'm developing using the Grails framework right now, I'm stuck deploying WAR files to Tomcat (yikes). I'd love to be able to use something like rsync to just push up .class files that have changed when I compile but, I'm pretty sure I'm going to end up needing to use something like Jenkins/Bamboo in order to automate my deployments.
I'll keep this workflow in mind though for other sites in the future.
Oh, and thanks for nvALT. It rocks.
Really cool tip, Brett! I'm hoping this might help me with some of the development I do on remote boxes. Currenlty I'm using Cyberduck+TextMate to "live" edit.
I'm running into issues with the sshfs-mounted directories though. When I try to save files in TextMate (v.2.0.0-alpha.9377, btw), I keep getting this error:
The document "fubar.php" could not be saved.
Setting extended attributes: Attribute not found
Some searching around seems to indicate this is an issue with some incompatibility with TextMate and fuse. Have you had this issue, and if so, any tips on getting around it?
Thanks again for this!
I haven't seen this issue, no, but it's likely a permissions conflict. Is it TextMate specific?
Not sure. Seems to be the only place I'm experiencing the issue. Or maybe TextMate is the only app that's griping about it. Apparently TextMate uses the extended file attributes to store metadata about the file, like bookmarks and text folding. And our linux servers don't seem to like it.
Odd thing is, the file actually gets saved, even though TextMate doesn't think so.
Got through the entire set up with no problems, but when I try to run `rmount mm` (where `mm` is a server that I have set up properly in `~/.ssh/config`) I get this message:
execl: No such file or directory
Any suggestions?
Not sure…
That error would typically mean that a binary wasn't being found, I think. If you run:
mkdir -p ~/mounts/mm && sshfs mm ~/mounts/mm -oauto_cache,reconnect,defer_permissions,negative_vncache,volname=mm,noappledouble
Does it throw an error?