diff --git a/stack/base/before-notebook.d/10_prepare-home-config.sh b/stack/base/before-notebook.d/10_prepare-home-config.sh index 5c7eea9e..2a74f38f 100644 --- a/stack/base/before-notebook.d/10_prepare-home-config.sh +++ b/stack/base/before-notebook.d/10_prepare-home-config.sh @@ -6,20 +6,6 @@ if [[ ! -f /home/${NB_USER}/.bashrc ]]; then cp /etc/skel/.bashrc /home/${NB_USER}/.bashrc fi -# Set sshagent by source load-singlesshagent.sh script -# append the command text of source to .bashrc if the script /opt/bin/load-singlesshagen.sh is present -# and the command text is not already present in .bashrc -header="# Load singlesshagent on shell startup." -if [[ -f /opt/bin/load-singlesshagent.sh ]] && ! grep -q "${header}" /home/${NB_USER}/.bashrc; then - cat >> "/home/${NB_USER}/.bashrc" <<- EOF - -${header} -if [ -f /opt/bin/load-singlesshagent.sh ]; then - source /opt/bin/load-singlesshagent.sh -fi -EOF -fi - if [[ ! -f /home/${NB_USER}/.profile ]]; then cp /etc/skel/.profile /home/${NB_USER}/.profile fi @@ -40,12 +26,22 @@ fi mkdir -p --mode=0700 /home/${NB_USER}/.ssh && \ touch /home/${NB_USER}/.ssh/known_hosts - if [[ ! -f /home/${NB_USER}/.ssh/id_rsa ]]; then # Generate ssh key that works with `paramiko` # See: https://aiida.readthedocs.io/projects/aiida-core/en/latest/get_started/computers.html#remote-computer-requirements ssh-keygen -f /home/${NB_USER}/.ssh/id_rsa -t rsa -b 4096 -m PEM -N '' fi -# Start the ssh-agent. -eval `ssh-agent` +# Set sshagent by source load-singlesshagent.sh script +# append the command text of source to .bashrc if the script /opt/bin/load-singlesshagen.sh is present +# and the command text is not already present in .bashrc +header="# Load singlesshagent on shell startup." +if [[ -f /opt/bin/load-singlesshagent.sh ]] && ! grep -q "${header}" /home/${NB_USER}/.bashrc; then + cat >> "/home/${NB_USER}/.bashrc" <<- EOF + +${header} +if [ -f /opt/bin/load-singlesshagent.sh ]; then + source /opt/bin/load-singlesshagent.sh +fi +EOF +fi