summaryrefslogtreecommitdiff
path: root/nodename2hostname.sh
blob: 41dd2dd3ae79e4d51cea71a0f992ca24274c4eb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash

# This script converts Jenkins' NODE_NAME to the public hostname.
# This is needed because on some machines `hostname` does not return
# the name as known by the DNS (eg. "tegra-ubuntu").  This list needs
# to be kept up-to-date with Jenkins configuration, and don't forget
# that a single host can have several NODE_NAMES.

# FIXME: try to get rid of this script, it's going to be a maintenance
# nightmare :-)

# Save stdout/stderr file descriptors
exec 3>&1 4>&2

# Make sure all output goes to stderr
exec 1>&2

NODE=$1
if [ x"$NODE" = x ]; then
    echo "Usage: $0 node-name"
    exit 1
fi

ID=$(echo ${NODE} | sed 's/.*-\([0-9][0-9]\)$/\1/')
NAME=
case ${NODE} in
    tcwg-aarch64-build-0[1-2]) NAME=apm-${ID} ;;
    tcwg-aarch64-test-0[1-2]) NAME=test-armv8-${ID} ;;
    tcwg-bmk-tk1-0[6-8]) NAME=build-${ID} ;;
    tcwg-bmk-tx1-0[6-8]) NAME=build-${ID} ;;
    tcwg-tk1-0[1-5]) NAME=${NODE} ;;
    tcwg-tx1-0[1-5]) NAME=${NODE} ;;
    tcwg-x86_64-build-0[1-8]) NAME=build-${ID} ;;
    tcwg-x86_64-dev-0[1-2]) NAME=dev-${ID} ;;
    tcwg-x86_64-dev-0[1-2]-short)
	ID=$(echo ${NODE} | sed 's/.*-\([0-9][0-9]\)-short$/\1/')
	NAME=dev-${ID}
	;;
    *)
	echo "Error: unsupported NODE value: ${NODE}"
	exit 1
	;;
esac

# Restore stdout/stderr, so that expected output goes to stdout
exec 1>&3 2>&4

echo ${NAME}
exit 0