#!/usr/bin/sh #---------------------------------------------------------------------------- # /usr/libexec/netconfig/nm-get-dhcpd - create dhcpd.conf and restart dhcpd.service # # Creation : 2025-11-19 hbfl # Last Update: $Id$ # # Copyright (c) 2001-@@YEAR@@ the eisfair team, team(at)eisfair(dot)org # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- #exec 2>/tmp/nm-get-dhcpd$$-trace.log #set -x # --------------------------------------------------------------------------- # run dhcpd # --------------------------------------------------------------------------- run_dhcpd() { /var/install/config.d/dhcpd.sh -4 --quiet --createconf sleep 3 /usr/sbin/service --quiet try-restart dhcpd.service exit 0 } # --------------------------------------------------------------------------- # start dhcpd # --------------------------------------------------------------------------- dhcpd_start() { nm_module=$(/usr/bin/find /etc/sysconfig/network/active -maxdepth 1 -type f -printf '%f\n') case "${nm_module}" in bonding) bond_device=$(/usr/sbin/ip addr | /usr/bin/gawk '/bond.:/ {print $2}' | /usr/bin/sed 's|:||' | /usr/bin/head -n 1) idx=20 while /usr/sbin/ip link show ${bond_device} | /usr/bin/grep -i -q 'state DOWN' do sleep 2 idx=$((${idx} - 2)) done run_dhcpd ;; bridge) bridge_device=$(/usr/sbin/ip addr | /usr/bin/gawk '/br.:/ {print $2}' | /usr/bin/sed 's|:||' | /usr/bin/head -n 1) idx=20 while /usr/sbin/ip link show ${bridge_device} | /usr/bin/grep -i -q 'state DOWN' do sleep 2 idx=$((${idx} - 2)) done run_dhcpd ;; *) exit 0 ;; esac } # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- main() { case "${1}" in start) dhcpd_start ;; stop) run_dhcpd ;; esac } # --------------------------------------------------------------------------- # exec main # --------------------------------------------------------------------------- main "${@}" # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------