Files
cshenv/ssh/gen-search.sh

20 lines
549 B
Bash
Executable File

#!/usr/bin/env bash
rm -f ~/.ssh/search
if [ -e ${CSHENV_DIR}/ssh/ssh-search-domains ]
then
domains=`grep "^search" /etc/resolv.conf | cut -c 8- - | cat - ${CSHENV_DIR}/ssh/ssh-search-domains | sort -u | xargs`
else
domains=`grep "^search" /etc/resolv.conf | cut -c 8- - | sort -u | xargs`
fi
if [ -z "${domains}" ] ; then exit 1; fi
if [ "${domains}" == "." ] ; then exit 0; fi
printf "Host *\n\tCanonicalDomains ${domains}\n\tCanonicalizeHostname yes\n# v" > ~/.ssh/search
printf "im:ft=sshconfig" >> ~/.ssh/search
exit 0
# vim: ft=bash