fix sethostname.sh: check for end0 before eth0

+ correct boot order
This commit is contained in:
2025-07-10 13:14:07 +02:00
parent d78b2e255e
commit 9b5e190277
2 changed files with 6 additions and 5 deletions

View File

@ -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

View File

@ -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