diff options
Diffstat (limited to 'debian/agent-launch')
-rwxr-xr-x | debian/agent-launch | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/debian/agent-launch b/debian/agent-launch new file mode 100755 index 000000000..3b2abdbf7 --- /dev/null +++ b/debian/agent-launch | |||
@@ -0,0 +1,24 @@ | |||
1 | #!/bin/sh | ||
2 | # helper script for launching ssh-agent, used by systemd unit | ||
3 | set -e | ||
4 | |||
5 | if [ ! -d "$XDG_RUNTIME_DIR" ]; then | ||
6 | # shellcheck disable=SC2016 | ||
7 | echo 'This needs $XDG_RUNTIME_DIR to be set' >&2 | ||
8 | exit 1 | ||
9 | fi | ||
10 | |||
11 | if [ "$1" = start ]; then | ||
12 | if [ -z "$SSH_AUTH_SOCK" ] && grep -s -q '^use-ssh-agent$' /etc/X11/Xsession.options; then | ||
13 | S="$XDG_RUNTIME_DIR/openssh_agent" | ||
14 | dbus-update-activation-environment --verbose --systemd SSH_AUTH_SOCK="$S" SSH_AGENT_LAUNCHER=openssh | ||
15 | exec ssh-agent -D -a "$S" | ||
16 | fi | ||
17 | elif [ "$1" = stop ]; then | ||
18 | if [ "$SSH_AGENT_LAUNCHER" = openssh ]; then | ||
19 | dbus-update-activation-environment --systemd SSH_AUTH_SOCK= | ||
20 | fi | ||
21 | else | ||
22 | echo "Unknown command $1" >&2 | ||
23 | exit 1 | ||
24 | fi | ||