Enable teststation customization using local files

/run/archiso/bootmnt is only available if booted without using copytoram
This commit is contained in:
2Shirt 2021-08-22 16:16:40 -06:00
parent 7ce67c7844
commit 8cdfb244e8
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -2,24 +2,42 @@
# #
## Setup network and update hostname ## Setup network and update hostname
# Wait for WiFi IP=
echo -n "Waiting for network... " NEW_HOSTNAME=
sleep 3s
echo "Done"
# Set hostname # Load test station details if present
echo -n "Updating hostname... " 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 \ IP="$(ip a show scope global \
| grep inet \ | grep inet \
| head -1 \ | head -1 \
| sed -r 's#.*inet ([0-9]+.[0-9]+.[0-9]+.[0-9]+.)/.*#\1#')" | sed -r 's#.*inet ([0-9]+.[0-9]+.[0-9]+.[0-9]+)/.*#\1#')"
if [[ "${IP:+x}" ]]; then 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" \ NEW_HOSTNAME="$(dig +noall +answer +short -x "$IP" \
| grep -v ';' \ | grep -v ';' \
| head -1 \ | head -1 \
| sed 's/\.$//')" | sed 's/\.$//')"
fi fi
if [[ "${NEW_HOSTNAME:+x}" ]]; then if [[ "${NEW_HOSTNAME:+x}" ]]; then
echo -n "Updating hostname... "
sudo hostnamectl set-hostname "${NEW_HOSTNAME}" sudo hostnamectl set-hostname "${NEW_HOSTNAME}"
fi fi
echo "Done" echo "Done"