agent-launch 700 B

1234567891011121314151617181920212223
  1. #!/bin/sh
  2. # helper script for launching ssh-agent, used by systemd unit
  3. set -e
  4. if [ ! -d "$XDG_RUNTIME_DIR" ]; then
  5. echo 'This needs $XDG_RUNTIME_DIR to be set' >&2
  6. exit 1
  7. fi
  8. if [ "$1" = start ]; then
  9. if [ -z "$SSH_AUTH_SOCK" ] && grep -s -q '^use-ssh-agent$' /etc/X11/Xsession.options; then
  10. S="$XDG_RUNTIME_DIR/openssh_agent"
  11. dbus-update-activation-environment --verbose --systemd SSH_AUTH_SOCK=$S SSH_AGENT_LAUNCHER=openssh
  12. exec ssh-agent -D -a $S
  13. fi
  14. elif [ "$1" = stop ]; then
  15. if [ "$SSH_AGENT_LAUNCHER" = openssh ]; then
  16. dbus-update-activation-environment --systemd SSH_AUTH_SOCK=
  17. fi
  18. else
  19. echo "Unknown command $1" >&2
  20. exit 1
  21. fi