iankelling.org
/
git
/
automated-distro-installer
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
minor updates
[automated-distro-installer]
/
chost
1
#!/bin/bash
2
# Copyright (C) 2016 Ian Kelling
3
4
# chost: get canonical hostname
5
6
set -eE -o
pipefail
7
trap
'echo "
$0
:
$LINENO
:error:
\"
$BASH_COMMAND
\"
returned $?" >&2'
ERR
8
9
host
=
$1
10
addr
=
$
(
host
$host
|
sed
-rn
's/^\S+ has address //p;T;q'
)
11
h
=
$
(
host
$addr
)
12
h
=
${h##* }
13
echo
${h%%.*}