Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Think of a different way to source lib into the scriptfile #7

Open
laur89 opened this issue Dec 23, 2015 · 1 comment
Open

Think of a different way to source lib into the scriptfile #7

laur89 opened this issue Dec 23, 2015 · 1 comment

Comments

@laur89
Copy link

laur89 commented Dec 23, 2015

Currently there's one major drawdown with pearl-ssh: i need its magic to be available on the server i ssh'd onto.

For that reason i'm currently using a separate copy of it.
Note that the rc file names both on local machine and remote (ie where it will be written down) have been unified, so the $PEARL_HOME can simply be redefined on the remote.

For this we need to take the pearl itself with us, but if the lib is sourced from the script the way it is done at the moment, I can't see very clean solution.

@fsquillace
Copy link
Owner

Hey @laur89,

wow, that's actually a nice feature. I have seen your solution and I could not probably do better than that.

I would probably do few other adjustments:

  • The structure of folder can change:
    • /tmp/pearl-XYZ/etc/ <- will contain all the rc files
    • /tmp/pearl-XYZ/bin/ <- will contain the ssh-pearl script (and in the future new other scripts)
    • /tmp/pearl-XYZ/lib/ <- will contain the ssh_pearl lib
    • Update the PATH variable remotely in order to point to /tmp/pearl-XYZ/bin too

To summarize, these can be the following steps once ssh-pearl (or ssh_pearl) wil be executed:

  • the script will load and merge the rc files both contents from PEARL_HOME and PEARLSSH_HOME (if it exists)
  • the script will load the script itself to be placed in the bin directory
  • the script will update the PATH variable in the remote host

So, this way should be a generalization so that the script would work either if we have run it locally or in remote host.

I will hopefully work on this the next year ;)

Feel free to write a pull request if you have time.

Thank you,
Filippo

PS: A small note on the reason why both ssh-pearl and ssh_pearl exist. ssh_pearl can be used as a bash function in a bash session. This will allow to change the behavior of ssh for instance by wrapping it as an alias or another function. For instance, I use a function wrapper so that i can combine it with ssh_pearl

ssh() {
    # do other stuff
    /usr/bin/ssh ....
}

ssh-pearl is just a script that will be spawned as a new process instead.

laur89 added a commit to laur89/pearl-ssh that referenced this issue Dec 25, 2015
- restructure the pearl directory on the remote as discussed at fsquillace#7;
- declare local variables on the function header;
laur89 added a commit to laur89/pearl-ssh that referenced this issue Dec 25, 2015
- restructure the pearl directory on the remote as discussed at fsquillace#7;
- declare local variables on the function header;
- change travis script to account for the rc filename changes;
laur89 added a commit to laur89/pearl-ssh that referenced this issue Dec 25, 2015
- restructure the pearl directory on the remote as discussed at fsquillace#7;
- make sure ssh_pearl is included in the ssh session, regardless whether it's invoked
  via script or shell function;
- declare local variables on the function header;
- change travis script to account for the rc filename changes;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants