WizardKit/setup/linux/include/airootfs/etc/skel/.update_network
2Shirt ac2e5a4fcf
New project orgnization
* Match upstream layout for the benefits listed there
2020-01-08 00:28:56 -07:00

26 lines
542 B
Bash
Executable file

#!/bin/env bash
#
## Setup network and update hostname
# Wait for WiFi
echo -n "Waiting for network... "
sleep 3s
echo "Done"
# Set hostname
echo -n "Updating hostname... "
IP="$(ip a show scope global \
| grep inet \
| head -1 \
| sed -r 's#.*inet ([0-9]+.[0-9]+.[0-9]+.[0-9]+.)/.*#\1#')"
if [[ "${IP:+x}" ]]; then
NEW_HOSTNAME="$(dig +noall +answer +short -x "$IP" \
| grep -v ';' \
| head -1 \
| sed 's/\.$//')"
fi
if [[ "${NEW_HOSTNAME:+x}" ]]; then
sudo hostnamectl set-hostname "${NEW_HOSTNAME}"
fi
echo "Done"