From 49ed3c2919634e5a0baf47cf0c4d612fb14d651f Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sat, 8 Oct 2022 20:03:40 -0700 Subject: [PATCH] Drop test station name detection via DNS --- .../airootfs/etc/skel/.setup_teststation | 16 +++++++ .../airootfs/etc/skel/.update_network | 44 ------------------- .../profile_base/airootfs/etc/skel/.zlogin | 4 +- 3 files changed, 18 insertions(+), 46 deletions(-) create mode 100755 setup/linux/profile_base/airootfs/etc/skel/.setup_teststation delete mode 100755 setup/linux/profile_base/airootfs/etc/skel/.update_network diff --git a/setup/linux/profile_base/airootfs/etc/skel/.setup_teststation b/setup/linux/profile_base/airootfs/etc/skel/.setup_teststation new file mode 100755 index 00000000..ac28a32d --- /dev/null +++ b/setup/linux/profile_base/airootfs/etc/skel/.setup_teststation @@ -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 diff --git a/setup/linux/profile_base/airootfs/etc/skel/.update_network b/setup/linux/profile_base/airootfs/etc/skel/.update_network deleted file mode 100755 index 66aee836..00000000 --- a/setup/linux/profile_base/airootfs/etc/skel/.update_network +++ /dev/null @@ -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" - diff --git a/setup/linux/profile_base/airootfs/etc/skel/.zlogin b/setup/linux/profile_base/airootfs/etc/skel/.zlogin index 68868d8e..b694cd12 100644 --- a/setup/linux/profile_base/airootfs/etc/skel/.zlogin +++ b/setup/linux/profile_base/airootfs/etc/skel/.zlogin @@ -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