Avoid dig errors if not connected to a network
This commit is contained in:
parent
c4755124a0
commit
d113d710a7
1 changed files with 6 additions and 4 deletions
|
|
@ -11,10 +11,12 @@ IP="$(ip a show scope global \
|
|||
| grep inet \
|
||||
| head -1 \
|
||||
| sed -r 's#.*inet ([0-9]+.[0-9]+.[0-9]+.[0-9]+.)/.*#\1#')"
|
||||
HOSTNAME="$(dig +noall +answer +short -x "$IP" \
|
||||
| grep -v ';' \
|
||||
| head -1 \
|
||||
| sed 's/\.$//')"
|
||||
if [[ "${IP:+x}" ]]; then
|
||||
HOSTNAME="$(dig +noall +answer +short -x "$IP" \
|
||||
| grep -v ';' \
|
||||
| head -1 \
|
||||
| sed 's/\.$//')"
|
||||
fi
|
||||
|
||||
# Set hostname
|
||||
if [[ "${HOSTNAME:+x}" ]]; then
|
||||
|
|
|
|||
Loading…
Reference in a new issue