fsquillace/kyrat

Think of a different way to source lib into the scriptfile

Opened this issue · 1 comments

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.

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.