Re: Initialization script for SSHFS


Daniel Mikusa
 

There's a branch of that repo that uses a .profile.d script.


https://github.com/dmikusa-pivotal/cf-ex-wordpress/blob/pcf-sshfs-example/.profile.d/setup.sh

It's a little different than the Python one as it pulls the connection info
from a bound service, but you don't have to do that.


https://github.com/dmikusa-pivotal/cf-ex-wordpress/blob/pcf-sshfs-example/.profile.d/setup.sh#L33-L36

Some additional comments inline...


#!/bin/bash
mv $HOME/app/.ssh $HOME/
chmod 644 $HOME/.ssh/*
chmod 600 $HOME/.ssh/sshfs_rsa
mv $HOME/app/main.rb /tmp/
mkdir -p $HOME/app/SSHFS/
sshfs root(a)192.168.1.15:

Can you access 192.168.1.15 from the container? You might try adding a
`ping -c 5 192.168.1.15` earlier in the script to test that. If it doesn't
work check your security groups and make sure that you can route to that
network.



/root/ssh_target/ $HOME/app/SSHFS -o IdentityFile=$HOME/.ssh/sshfs_rsa -o
StrictHostKeyChecking=yes -o UserKnownHostsFile=$HOME/.ssh/known_hosts -o
idmap=user -o cache=yes -o kernel_cache -o compression=no -o large_read
Try running this command from your PC and make sure it works and that it
connects without prompting for a password. That last bit is critical or
you need to change the command so that the password is piped in like this.

https://github.com/dmikusa-pivotal/cf-ex-wordpress/blob/pcf-sshfs-example/.profile.d/setup.sh#L48-L56



mv /tmp/main.rb $HOME/app/SSHFS/
fusermount -uz $HOME/app/SSHFS
The Python script is run by the build pack, so it runs during staging.
This is why it unmounts the volume. A .profile.d script runs in the
runtime container prior to the application starting. You probably don't
want to unmount the drive or it won't be accessible. You also want to make
sure that it runs in the background or your script will just hang.

Dan

Join {cf-dev@lists.cloudfoundry.org to automatically receive all group messages.