nci/mosrs-setup

Use start-gpg-agent in .bashrc

Closed this issue · 1 comments

Building on issue #44 , use start-gpg-agent in the user's $HOME/.bashrc startup file. This depends on the correct mosrs-setup module having itself been loaded beforehand. A suggested way of doing this:

  1. Before editing ~/.bashrc, conceptually:
$ MOSRS_SETUP_MODULE=$(module info-loaded mosrs-setup)
$ MOSRS_SETUP_PATH=$(module path $MOSRS_SETUP_MODULE)
$ MOSRS_SETUP_USE=${MOSRS_SETUP_PATH/\/$MOSRS_SETUP_MODULE/}
  1. Put the following into ~/.bashrc in the appropriate place:
# mosrs-setup gpg_agent_script: DO NOT EDIT BETWEEN HERE AND END
function load_mosrs {
  module use $MOSRS_SETUP_USE
  module load $MOSRS_SETUP_MODULE
}
function start_mosrs_gpg {
  mkdir -p $HOME/.gnupg
  load_mosrs
  start-gpg-agent
}
if in_interactive_shell; then
    if in_login_shell; then
        # start the GPG agent
        start_mosrs_gpg
    fi
fi
# mosrs-setup gpg_agent_script: END

where the MOSRS_SETUP_* shell variables are replaced by Python strings.

Issues with doing things this way:

  1. Step 1. depends on mosrs-setup being run from a module, and will fail if mosrs-setup is run directly.
$ module unload mosrs-setup
$ MOSRS_SETUP_MODULE=$(module info-loaded mosrs-setup)
$ echo $MOSRS_SETUP_MODULE

  1. The version of mosrs-setup used in ~/.bashrc is fixed at the version used to edit the ~/.bashrc file itself.

Close. This change is not needed: mosrs-setup no longer updates the .bashrc file.