#!/usr/bin/sh #---------------------------------------------------------------------------- # /usr/libexec/netconfig/nm-get-dhcpc - script for dhcp client # # Creation: 2025-01-05 hbfl # Last Update: $Id$ # # Copyright (c) 2001-2005 the eisfair team, team(at)eisfair(dot)org # Copyright (c) 2011-@@YEAR@@ Holger Bruenjes, holgerbruenjes(at)gmx(dot)net # # 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. #---------------------------------------------------------------------------- . /etc/config.d/dhcpc . /etc/config.d/base # --------------------------------------------------------------------------- # start # --------------------------------------------------------------------------- dhcpc_start() { local ethx local dhcpc_iface eval ethx=${DHCPC_BIND_ETH} eval dhcpc_iface='${IP_ETH_'${ethx}'_NAME}' if [ -z "${dhcpc_iface}" ] then . /var/install/include/nm-get-device-name get_name eth0 dhcpc_iface=${name} fi /usr/sbin/ip addr flush dev ${dhcpc_iface} { # set interface parameter echo '[connection]' echo "id=${dhcpc_iface}" echo 'type=ethernet' echo "interface-name=${dhcpc_iface}" ipv4_method='auto' echo echo '[ipv4]' if [ -n "${DHCPC_SEND_HOSTNAME}" ] then echo "dhcp-send-hostname=true" echo "dhcp-hostname=${DHCPC_SEND_HOSTNAME}" fi if [ "${DHCPC_SET_DEFAULT_ROUTE:-no}" != "yes" ] then echo "ignore-auto-routes=true" # include to set gateway and route . /var/install/include/nm-get-route fi if [ "${DHCPC_USE_PEERDNS:-no}" != "yes" ] then echo 'ignore-auto-dns=true' # include to set dns responder . /var/install/include/nm-get-dns fi echo "method=${ipv4_method}" ipv6_method='link-local' echo echo '[ipv6]' echo 'addr-gen-mode=default' echo "method=${ipv6_method}" echo echo '[proxy]' echo } > /etc/NetworkManager/system-connections/${dhcpc_iface}.nmconnection /usr/bin/chmod 0600 /etc/NetworkManager/system-connections/${dhcpc_iface}.nmconnection >/run/netconfig/${dhcpc_iface}.nmconnection } # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- main() { while [ ${#} -gt 0 ] do case "${1}" in -q|--quiet) _quiet=true shift ;; *) _action=${1} shift ;; esac done case "${_action}" in start) dhcpc_start ;; *) exit 0 ;; esac exit 0 } # --------------------------------------------------------------------------- # exec main # --------------------------------------------------------------------------- main "${@}" # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------