Hello,

I suppose there is some argument that we should support hostname.MAC
files
Maybe a function in netstart right before vifscreate could be enough to 
achieve this? I creates this diff, against stable for now though, as a test.
Create a /etc/hostname.MAC file like you would create a /etc/hostname.if 
file. (MAC = lladdr as shown with ifconfig. Like 
/etc/hostname.08:00:27:14:26:0d)
/etc/netstart than creates a symbolic link to the corresponding 
hostname.if. If there is a hostname.if file it is not overwritten. The 
rest works the same.

--- netstart    Tue Sep 27 19:39:43 2022
+++ netstart    Tue Nov 22 03:39:49 2022
@@ -104,6 +104,21 @@ ifcreate() {
        fi
 }

+# Symlink hostname.MAC to hostname.if.
+# Existing hostname.if-file (no symlink) wins.
+link_MAC_to_if() {
+       local _hn _mac _if
+
+       for _hn in /etc/hostname.??:??:??:??:??:??; do
+               _mac=`echo $_hn | cut -c 15-31`
+               _if=`ifconfig | grep -B 1 $_mac | head -n 1 | awk -F ": " 
'{print $1}'`
+               # Only create a symlink if /etc/hostname.$_if is not a normal 
file.
+               if [[ -h /etc/hostname.$_if ]] || [[ ! -e /etc/hostname.$_if 
]]; then
+                       ln -fs /etc/hostname.$_mac /etc/hostname.$_if
+               fi
+       done
+}
+
# Create interfaces for network pseudo-devices referred to by hostname.if files.
 # Optionally, limit creation to given interfaces only.
 # Usage: vifscreate [if ...]
@@ -356,6 +371,9 @@ if ifconfig lo0 inet6 >/dev/null 2>&1; then
 else
        ip6kernel=NO
 fi
+
+# Symlink hostname.MAC to hostname.if.
+link_MAC_to_if

 # Create all the pseudo interfaces up front.
 vifscreate

Reply via email to