Drop test station name detection via DNS

This commit is contained in:
2Shirt 2022-10-08 20:03:40 -07:00
parent 7dd35e3572
commit 49ed3c2919
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
3 changed files with 18 additions and 46 deletions

View file

@ -0,0 +1,16 @@
#!/bin/env bash
#
## Set up teststation settings if detected
# Hostname
if [[ -s "/run/archiso/bootmnt/teststation.name" ]]; then
NEW_HOSTNAME="$(head -1 "/run/archiso/bootmnt/teststation.name" \
| sed -r 's/\s//g')"
sudo hostnamectl set-hostname "${NEW_HOSTNAME}"
fi
# Wallpaper
if [[ -s "/run/archiso/bootmnt/teststation.wall" ]]; then
rm "${HOME}/.wallpaper" >/dev/null 2>&1
ln -s "/run/archiso/bootmnt/teststation.wall" "${HOME}/.wallpaper"
fi

View file

@ -1,44 +0,0 @@
#!/bin/env bash
#
## Setup network and update hostname
IP=
NEW_HOSTNAME=
# Load test station details if present
if [[ -s "/run/archiso/bootmnt/teststation.name" ]]; then
NEW_HOSTNAME="$(head -1 "/run/archiso/bootmnt/teststation.name" \
| sed -r 's/\s//g')"
fi
if [[ -s "/run/archiso/bootmnt/teststation.wall" ]]; then
rm "${HOME}/.wallpaper" >/dev/null 2>&1
ln -s "/run/archiso/bootmnt/teststation.wall" "${HOME}/.wallpaper"
fi
# Wait for network connection and get IP
echo -n "Waiting for network... "
for x in {1..3}; do
sleep 1s
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
break
fi
done
echo "Done"
# Set hostname
if [[ -z "${NEW_HOSTNAME:+x}" && "${IP:+x}" ]]; then
NEW_HOSTNAME="$(dig +noall +answer +short -x "$IP" \
| grep -v ';' \
| head -1 \
| sed 's/\.$//')"
fi
if [[ "${NEW_HOSTNAME:+x}" ]]; then
echo -n "Updating hostname... "
sudo hostnamectl set-hostname "${NEW_HOSTNAME}"
fi
echo "Done"

View file

@ -1,7 +1,7 @@
setterm -blank 0 -powerdown 0 2>/dev/null
if [ "$(fgconsole 2>/dev/null)" -eq "1" ]; then
# Connect to network and update hostname
$HOME/.update_network
# Set up teststation details
$HOME/.setup_teststation
# Start HW-diags
hw-diags --cli