codekingpro/portable-devtools
114k
1@REM Do not use "echo off" to not affect any child calls.2 3@REM The goal of this script is to simplify launching `ssh-pageant` at4@REM logon, typically by dropping a shortcut into the Startup folder, so5@REM that Pageant (the PuTTY authentication agent) will always be6@REM accessible. No attempt is made to load SSH keys, since this is7@REM normally handled directly by Pageant, and no interactive shell8@REM will be launched.9@REM 10@REM The `ssh-pageant` utility is launched with the `-r` (reuse socket)11@REM option, to ensure that only a single running incarnation (per user)12@REM will be required... instead of launching a separate process for13@REM every interactive Git Bash session. A side effect of this selection14@REM is that the SSH_AUTH_SOCK environment variable *must* be set prior15@REM to running this script, with the value specifying a unix-style socket16@REM path, and needs to be consistent for all git-related processes. The17@REM easiest way to do this is to set a persistent USER environment18@REM variable, which (under Windows 7) can be done via Control Panel19@REM under System / Advanced System Settings. A typical value would look20@REM similar to:21@REM22@REM SSH_AUTH_SOCK=/tmp/.ssh-pageant-USERNAME23@REM24 25@REM Enable extensions, the `verify` call is a trick from the setlocal help26@VERIFY other 2>nul27@SETLOCAL EnableDelayedExpansion28@IF ERRORLEVEL 1 (29 @ECHO Unable to enable extensions30 @GOTO failure31)32 33@REM Ensure that SSH_AUTH_SOCK is set34@if "x" == "x%SSH_AUTH_SOCK%" @(35 @ECHO The SSH_AUTH_SOCK environment variable must be set prior to running this script. >&236 @ECHO This is typically configured as a persistent USER variable, using a MSYS2 path for >&237 @ECHO the ssh-pageant authentication socket as the value. Something similar to: >&238 @ECHO. >&239 @ECHO SSH_AUTH_SOCK=/tmp/.ssh-pageant-%USERNAME% >&240 @GOTO failure41)42 43@REM Start ssh-pageant if needed by git44@FOR %%i IN ("git.exe") DO @SET GIT=%%~$PATH:i45@IF EXIST "%GIT%" @(46 @REM Get the ssh-pageant executable47 @FOR %%i IN ("ssh-pageant.exe") DO @SET SSH_PAGEANT=%%~$PATH:i48 @IF NOT EXIST "%SSH_PAGEANT%" @(49 @FOR %%s IN ("%GIT%") DO @SET GIT_DIR=%%~dps50 @FOR %%s IN ("!GIT_DIR!") DO @SET GIT_DIR=!GIT_DIR:~0,-1!51 @FOR %%s IN ("!GIT_DIR!") DO @SET GIT_ROOT=%%~dps52 @FOR %%s IN ("!GIT_ROOT!") DO @SET GIT_ROOT=!GIT_ROOT:~0,-1!53 @FOR /D %%s in ("!GIT_ROOT!\usr\bin\ssh-pageant.exe") DO @SET SSH_PAGEANT=%%~s54 @IF NOT EXIST "!SSH_PAGEANT!" @GOTO ssh-pageant-done55 )56)57 58@REM Time to make the donuts!59@ECHO Starting ssh-pageant...60@FOR /f "usebackq tokens=1 delims=;" %%o in (`"%SSH_PAGEANT%" -qra %SSH_AUTH_SOCK%`) DO @ECHO %%o61 62:ssh-pageant-done63:failure64 