From 9b5e190277f30553a3cc24cd08234f15bae4d523 Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Thu, 10 Jul 2025 13:14:07 +0200 Subject: [PATCH] fix sethostname.sh: check for end0 before eth0 + correct boot order --- sethostname.sh | 8 +++++--- to_system/etc/systemd/system/sethostname.service | 3 +-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sethostname.sh b/sethostname.sh index 7bc974d..3e237d1 100644 --- a/sethostname.sh +++ b/sethostname.sh @@ -1,7 +1,9 @@ if [[ -f /sys/class/net/eth0/address ]]; then - ETHNAME=$(cat /sys/class/net/eth0/address) -else ETHNAME=$(cat /sys/class/net/end0/address) + BASED=end0 +else + ETHNAME=$(cat /sys/class/net/eth0/address) + BASED=eth0 fi FOUND=($(grep -l -r MAC=$ETHNAME /home/l_samenv/boxtools/cfg)) if [ -z "$FOUND" ]; then @@ -11,7 +13,7 @@ if [ -z "$FOUND" ]; then else FOUND=$(basename ${FOUND[0]}) # remove directory part HOSTNAME=${FOUND%%.cfg} # remove extension - echo "hostname $HOSTNAME" fi +echo "set hostname to $HOSTNAME based on $BASED $ETHNAME" echo $HOSTNAME > /etc/hostname echo "127.0.0.1 localhost $HOSTNAME" > /etc/hosts diff --git a/to_system/etc/systemd/system/sethostname.service b/to_system/etc/systemd/system/sethostname.service index d47c96c..f3b3b20 100644 --- a/to_system/etc/systemd/system/sethostname.service +++ b/to_system/etc/systemd/system/sethostname.service @@ -1,7 +1,6 @@ [Unit] Description = Create host name from ethernet address -Wants=network-pre.target -Before=network.pre-target +Before=ifup@end0.service [Service] Type=oneshot