X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=opt%2Fbin%2Fsshcolourterm;h=0cf4b9fe0e92474d00ba9ab70c1bb6dfe95f1ec9;hb=99ae026171714bb2d9044305479054029e5c4665;hp=c144a3b4c9770212e377d44cf0327908b5836023;hpb=819bb88d5a014a23150b8fd609d194e883958674;p=profile.git diff --git a/opt/bin/sshcolourterm b/opt/bin/sshcolourterm index c144a3b..0cf4b9f 100755 --- a/opt/bin/sshcolourterm +++ b/opt/bin/sshcolourterm @@ -6,12 +6,24 @@ fqdn=${1##*@} colour= # Get colour by regex. -for path in $(ls "$SSHCOLOURS" | lensort -r); do - re=${path##*/} - echo "$fqdn" | grep -qs "$re" || continue - colour=$(readlink "$SSHCOLOURS/$path") - break -done +if [ -z "$colour" ]; then + for path in $(ls "$SSHCOLOURS" | lensort -r); do + re=${path##*/} + echo "$fqdn" | grep -qs "$re" || continue + colour=$(readlink "$SSHCOLOURS/$path") + break + done +fi + +# Get colour by netgroup. +if [ -z "$colour" ]; then + for netgroup in $(ls "$SSHCOLOURS" | grep ^\@); do + if netgroups $netgroup ${fqdn%%.*} 2>/dev/null; then + colour=$(readlink "$SSHCOLOURS/$netgroup") + break + fi + done +fi if [ ! -z "$colour" ]; then colour=${colour##*/}