bundlewrap/scripts/update-ssh-client-config

32 lines
875 B
Text
Raw Normal View History

2021-02-13 15:39:55 +00:00
#!/bin/bash
# Intended to be used as a git hook for post-commit, post-merge, post-checkout
2021-02-13 15:39:55 +00:00
#
# Remember to include the generated ssh config on top of ~/.ssh/config:
# Include ~/.ssh/bwnode
(
tmpfile=$(mktemp -p ~/.ssh/)
echo "# generated $(date)" >"$tmpfile"
BW_TABLE_STYLE=grep bw nodes -a hostname -- "lambda:not node.dummy" | \
while read node addr
do
2024-12-28 16:22:21 +00:00
if [[ -n "$BW_SSH_HOOK_EXTRA_LINE" ]]
then
echo "Host $addr" >>"$tmpfile"
echo "$BW_SSH_HOOK_EXTRA_LINE" >>"$tmpfile"
echo "" >>"$tmpfile"
fi
2021-02-13 15:39:55 +00:00
echo "Host $node" >>"$tmpfile"
echo "HostName $addr" >>"$tmpfile"
2024-12-28 16:22:21 +00:00
if [[ -n "$BW_SSH_HOOK_EXTRA_LINE" ]]
then
echo "$BW_SSH_HOOK_EXTRA_LINE" >>"$tmpfile"
fi
2021-02-13 15:39:55 +00:00
echo "" >>"$tmpfile"
done
mv "$tmpfile" ~/.ssh/config.d/bwnodes
2021-02-13 15:39:55 +00:00
) &