chiark / gitweb /
setup, bin/: Some scripts which are useful in Cygwin.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 29 Mar 2015 16:34:28 +0000 (17:34 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 29 Mar 2015 16:34:28 +0000 (17:34 +0100)
  * bin/run-with-shell-env runs a program having established the proper
    shell environment.  This is handy for invoking things from Windows
    shortcuts, for example.

  * bin/start-ssh-pageant starts the Cygwin proxy for PuTTY's Pageant
    SSH agent.  It's not properly engineered yet, but it seems to work
    well enough for running at login time.

bin/run-with-shell-env [new file with mode: 0644]
bin/start-ssh-pageant [new file with mode: 0644]
setup

diff --git a/bin/run-with-shell-env b/bin/run-with-shell-env
new file mode 100644 (file)
index 0000000..ba0afcf
--- /dev/null
@@ -0,0 +1,13 @@
+#! /bin/bash -x
+exec >/tmp/mdw/hacky.log 2>&1
+case ${__mdw_profile+t} in
+  t) ;;
+  *)
+    __mdw_force_secure_session=yes
+    export SHELL=/bin/bash USER=$(/bin/id -un)
+    set +x
+    . $HOME/.bash_profile
+    set -x
+    ;;
+esac
+exec "$@"
diff --git a/bin/start-ssh-pageant b/bin/start-ssh-pageant
new file mode 100644 (file)
index 0000000..cb704dd
--- /dev/null
@@ -0,0 +1,13 @@
+#! /bin/sh -ex
+PATH=/bin:$HOME/bin:$PATH
+eval $(tmpdir -b)
+sockdir=${TMPDIR?}/.ssh-agent.$(hostname).${USER-$(id -un)}
+if [ -S $sockdir/sock ]; then
+  set +e; ssh-add -l >/dev/null 2>&1; rc=$?; set -e
+  case $rc in 0) exit 0 ;; esac
+  kill $(cat $sockdir/pid) || :
+  rm -f $sockdir/pid $sockdir/sock
+fi
+mkdir -p -m700 $sockdir
+(cd /; exec run ssh-pageant -d -a$sockdir/sock >/dev/null 2>&1)&
+echo $! >$sockdir/pid
diff --git a/setup b/setup
index 7b54cd9dbbeed526e91fb60494252f59537d90aa..6347acdeb9e47027e711abf8ed47a78dc4573850 100755 (executable)
--- a/setup
+++ b/setup
@@ -245,7 +245,9 @@ scripts="
   aspell-hack
   emerge-hack
   lesspipe.sh
+  run-with-shell-env
   start-ssh-agent
+  start-ssh-pageant
   svnwrap
   guest-console
   hyperspec"