WizardKit/.linux_items/include/airootfs/etc/skel/.update_network
2Shirt 1cb7de08f3
Add small delay to network startup
* Will hopefully allow test-stations to update the hostname more reliably
2018-10-10 15:47:48 -06:00

23 lines
444 B
Text
Executable file

## .update_network ##
#!/bin/env bash
#
## Connect to network and update hostname
# Connect
connect-to-network
sleep 2s
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/\.$//')"
# Set hostname
if [[ "${HOSTNAME:+x}" ]]; then
sudo hostnamectl set-hostname "${HOSTNAME}"
fi