32 lines
722 B
Bash
32 lines
722 B
Bash
|
#!/usr/bin/env sh
|
||
|
set -euo errexit
|
||
|
|
||
|
# Print a debug message if debug mode is on ($DEBUG is not empty)
|
||
|
# @param message
|
||
|
debug_msg ()
|
||
|
{
|
||
|
if [ -n "${DEBUG:-}" -a "${DEBUG:-}" != "false" ]; then
|
||
|
echo "$@"
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
case "${1:-start}" in
|
||
|
|
||
|
start)
|
||
|
debug_msg "Starting..."
|
||
|
|
||
|
# Create proxy-socket for ssh-agent (to give everyone access to the ssh-agent socket)
|
||
|
debug_msg "Create proxy socket..."
|
||
|
rm -f ${SSH_AUTH_SOCK} ${SSH_AUTH_PROXY_SOCK} > /dev/null 2>&1
|
||
|
socat UNIX-LISTEN:${SSH_AUTH_PROXY_SOCK},perm=0666,fork UNIX-CONNECT:${SSH_AUTH_SOCK} &
|
||
|
|
||
|
debug_msg "Launch ssh-agent..."
|
||
|
exec /usr/bin/ssh-agent -a ${SSH_AUTH_SOCK} -D >/dev/null
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
debug_msg "Exec: $@"
|
||
|
exec "$@"
|
||
|
;;
|
||
|
esac
|