diff --git a/install.sh b/install.sh index d75df5b58b62d4a79df4fcefbb52e343d34ed69a..efc82cbb49de4b547066c174fe1b12cdb28f9ea1 100755 --- a/install.sh +++ b/install.sh @@ -4,6 +4,30 @@ set -e BASE_DIR=$PWD +# If the user insists on using SSH for everything, make sure their key is +# unlocked before doing anything else. Otherwise they won't be able to clone. +if [ ! -z "$(git config url.ssh://git@gitlab.cern.ch:7999/.insteadOf)" ]; then + echo "+----------------------------------------------------------------------------------+" + echo "| NOTE ABOUT SSH KEYS |" + echo "| |" + echo "| Your git configuration redirects all clones to SSH. We will try to make it work, |" + echo "| but it may fail if you do not use the default SSH key. In any case running cmake |" + echo "| commands directly will require you ensure an SSH agent is running and your SSH |" + echo "| key is unlocked. |" + echo "+----------------------------------------------------------------------------------+" + echo + echo "===> Unlocking your SSH key..." + + # Start an ssh agent if needed + if [ -z "$SSH_AUTH_SOCK" ] || [ -z "$SSH_AGENT_PID" ]; then + eval $(ssh-agent) + fi + + # Unlock the key. This will only work if the default key is used for GitLab, + # but we have no easy way of getting this information. + ssh-add +fi + # Get a CMSSW if we don't have one if [ -z $CMSSW_BASE ]; then version=CMSSW_12_4_0