<commit_before>#!/bin/bash
. /opt/farm/scripts/functions.custom

if [ "$1" = "" ]; then
	echo "usage: $0 <hostname>"
	exit 1
fi

path="/etc/local/.config"
query=$1
shift

server=`grep -h "^$query$" $path/physical.hosts $path/virtual.hosts $path/ec2.hosts $path/workstation.hosts $path/problematic.hosts |head -1`
if [ "$server" = "" ]; then

	if [ "`getent hosts \"$query\"`" != "" ]; then
		query="^$query[.:]"
	fi

	# TODO: sort by the longest match, instead of the longest entry
	server=`grep -h "$query" $path/physical.hosts $path/virtual.hosts $path/ec2.hosts $path/workstation.hosts $path/problematic.hosts |awk '{ print length($0) " " $0; }' |sort -rn |cut -d ' ' -f 2- |head -1`
fi

if [ "$server" = "" ]; then
	echo "error: no such server"
	exit 1
fi

if [ -z "${server##*:*}" ]; then
	host="${server%:*}"
	port="${server##*:}"
else
	host=$server
	port=22
fi

sshkey="`ssh_management_key_storage_filename $host`"
ssh -t -i $sshkey -p $port -o StrictHostKeyChecking=no root@$host $@<commit_msg>use literal specified hostname if server not found in farm registry<commit_after>#!/bin/bash
. /opt/farm/scripts/functions.custom

if [ "$1" = "" ]; then
	echo "usage: $0 <hostname>"
	exit 1
fi

path="/etc/local/.config"
orig=$1
query=$1
shift

server=`grep -h "^$query$" $path/physical.hosts $path/virtual.hosts $path/ec2.hosts $path/workstation.hosts $path/problematic.hosts |head -1`
if [ "$server" = "" ]; then

	if [ "`getent hosts \"$query\"`" != "" ]; then
		query="^$query[.:]"
	fi

	# TODO: sort by the longest match, instead of the longest entry
	server=`grep -h "$query" $path/physical.hosts $path/virtual.hosts $path/ec2.hosts $path/workstation.hosts $path/problematic.hosts |awk '{ print length($0) " " $0; }' |sort -rn |cut -d ' ' -f 2- |head -1`
fi

if [ "$server" = "" ]; then
	server=$orig
fi

if [ -z "${server##*:*}" ]; then
	host="${server%:*}"
	port="${server##*:}"
else
	host=$server
	port=22
fi

sshkey="`ssh_management_key_storage_filename $host`"
ssh -t -i $sshkey -p $port -o StrictHostKeyChecking=no root@$host $@
{'fraction_non_alphanumeric': 0.2051909892262488, 'fraction_numerical': 0.013712047012732615, 'mean_word_length': 4.172151898734177, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3332103', 'n_tokens_mistral': 826, 'n_tokens_neox': 760, 'n_words': 203}