From 4c60dc89a46aeeb8c65897e22942793e62d283e7 Mon Sep 17 00:00:00 2001 From: Eric Hameleers Date: Mon, 7 Feb 2022 17:44:06 +0100 Subject: pxeserver: also check NetworkManager internal dhcp client --- pxeserver.tpl | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/pxeserver.tpl b/pxeserver.tpl index 3a9c206..1bde266 100755 --- a/pxeserver.tpl +++ b/pxeserver.tpl @@ -168,7 +168,7 @@ int_to_ip() { echo $(($1>>24)).$(($1>>16&0xff)).$(($1>>8&0xff)).$(($1&0xff)) } -# Find the location of the dhcpcd PID file: +# Find out whether the interface is managed by DHCP: get_dhcpcd_pid() { # Find the location of the PID file of dhcpcd: MYDEV="$1" @@ -185,6 +185,17 @@ get_dhcpcd_pid() { fi } +# Find out whether the interface is managed by DHCP: +get_nm_internal_lease() { + # Find the lease of NetworkManager internal dhcp client: + MYDEV="$1" + if [ -s /var/lib/NetworkManager/intern*-${MYDEV}.lease ]; then + echo "$(ls --indicator-style=none /var/lib/NetworkManager/intern*-${MYDEV}.lease)" + else + echo UNKNOWNLOC + fi +} + # The network interface IP configuration routine. # Will be called if the interface was not configured by DHCP. # It ends with a configured network interface: @@ -392,10 +403,12 @@ Alternate keys may also be used: '+', '-', and TAB." 13 72 9 \ # We now know what network interface to use. # - # If dhcpcd is running, it likely has a lease from a LAN DHCP server, - # so we should not activate another DHCP server ourselves now: + # If our interface is configured by DHCP, it likely has a lease from a + # LAN DHCP server, so we should not activate another DHCP server ourself now: if [ -s $(get_dhcpcd_pid ${INTERFACE}) -a -n "$(ps -q $(cat $(get_dhcpcd_pid ${INTERFACE})) -o comm=)" ]; then OWNDHCP="no" + elif [ -s $(get_nm_internal_lease ${INTERFACE}) ]; then + OWNDHCP="no" else # Assume nothing... we will ask the user for confirmation later! OWNDHCP="yes" -- cgit v1.2.3