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 if [[ -f /sys/class/net/eth0/address ]]; then
ETHNAME=$(cat /sys/class/net/eth0/address)
else
ETHNAME=$(cat /sys/class/net/end0/address) ETHNAME=$(cat /sys/class/net/end0/address)
BASED=end0
else
ETHNAME=$(cat /sys/class/net/eth0/address)
BASED=eth0
fi fi
FOUND=($(grep -l -r MAC=$ETHNAME /home/l_samenv/boxtools/cfg)) FOUND=($(grep -l -r MAC=$ETHNAME /home/l_samenv/boxtools/cfg))
if [ -z "$FOUND" ]; then if [ -z "$FOUND" ]; then
@ -11,7 +13,7 @@ if [ -z "$FOUND" ]; then
else else
FOUND=$(basename ${FOUND[0]}) # remove directory part FOUND=$(basename ${FOUND[0]}) # remove directory part
HOSTNAME=${FOUND%%.cfg} # remove extension HOSTNAME=${FOUND%%.cfg} # remove extension
echo "hostname $HOSTNAME"
fi fi
echo "set hostname to $HOSTNAME based on $BASED $ETHNAME"
echo $HOSTNAME > /etc/hostname echo $HOSTNAME > /etc/hostname
echo "127.0.0.1 localhost $HOSTNAME" > /etc/hosts echo "127.0.0.1 localhost $HOSTNAME" > /etc/hosts

View File

@ -1,7 +1,6 @@
[Unit] [Unit]
Description = Create host name from ethernet address Description = Create host name from ethernet address
Wants=network-pre.target Before=ifup@end0.service
Before=network.pre-target
[Service] [Service]
Type=oneshot Type=oneshot