--- client/dhclient-script.8 +++ client/dhclient-script.8 2008/08/22 10:05:02 @@ -45,9 +45,10 @@ any, and also called once if no valid le This script is not meant to be customized by the end user. If local customizations are needed, they should be possible using the enter and exit hooks provided (see HOOKS for details). These hooks will allow the -user to override the default behaviour of the client in creating a +user to override the default behaviour of the client in applying of +additional settings like DNS (e.g. creating a .B /etc/resolv.conf -file. +file), NTP or YP to the system. .PP No standard client script exists for some operating systems, even though the actual client may work, so a pioneering user may well need to create @@ -59,14 +60,46 @@ customizing .B ETCDIR/dhclient.conf or using the enter and exit hooks, please submit a bug report. .SH HOOKS -When it starts, the client script first defines a shell function, -.B make_resolv_conf , -which is later used to create the -.B /etc/resolv.conf -file. To override the default behaviour, redefine this function in -the enter hook script. +When it starts, the client script first defines several shell functions: +.BR use_netconfig , +.BR netconfig_modify , +.BR netconfig_remove , +.BR make_resolv_conf , +.BR make_ntp_runtime_conf , +.BR restore_resolv_conf , +and +.BR remove_ntp_runtime_conf . +These functions are later used to apply DNS, NTP, YP, and other additional +settings to the system. + +The +.B use_netconfig +returns true (0), when the /sbin/netconfig script is supported / installed +and enables the use of +.B netconfig_modify +and +.B netconfig_remove +functions. See also the netconfig(8) manual page. +.br +Otherwise, the compatibility functions +.BR make_resolv_conf , +.BR restore_resolv_conf , +.BR make_ntp_runtime_conf , +and +.B remove_ntp_runtime_conf +functions are used. The default implementation of make_resolv_conf is to +modify the /etc/resolv.conf file in /sbin/modify_resolvconf script +compatible way. The make_ntp_runtime_conf makes use of the /etc/init.d/ntp +init script mechanism to apply the NTP server provided by dhcp at runtime. + +.IR Note : +The /sbin/modify_resolvconf script and mechanizm is obsoleted by netconfig +and not shipped or supported any more since openSUSE 11.1. + +To override the default behaviour, redefine these functions in the enter +hook script. .PP -On after defining the make_resolv_conf function, the client script checks +On after defining the netconfig functions, the client script checks for the presence of an executable .B ETCDIR/dhclient-enter-hooks script, and if present, it invokes the script inline, using the Bourne @@ -220,8 +253,8 @@ the other. Assuming the information pr valid, this shouldn't cause any real problems, but it could be confusing. .SH SEE ALSO -dhclient(8), dhcpd(8), dhcrelay(8), dhclient.conf(5) and -dhclient.leases(5). +dhclient(8), dhcpd(8), dhcrelay(8), dhclient.conf(5), +dhclient.leases(5) and netconfig(8). .SH AUTHOR .B dhclient-script(8) has been written for Internet Systems Consortium --- client/scripts/linux +++ client/scripts/linux 2008/08/22 09:52:12 @@ -57,6 +57,36 @@ if [ -n "${dhc_dbus}" ]; then fi; fi; +use_netconfig() { + test -x /sbin/netconfig +} + +netconfig_modify() { + { + echo "INTERFACE='$interface'" + for v in ${!new_*}; do + case $v in + (new_ip_address) k='IPADDR' ;; + (new_subnet_mask) k='NETMASK' ;; + (new_network_number) k='NETWORK' ;; + (new_broadcast_address) k='BROADCAST' ;; + (new_routers) k='GATEWAYS' ;; + (new_domain_name) k='DNSDOMAIN' ;; + (new_domain_name_servers) k='DNSSERVERS' ;; + (new_ntp_servers) k='NTPSERVERS' ;; + (new_nis_domain) k='NISDOMAIN' ;; + (new_nis_servers) k='NISSERVERS' ;; + (new_netbios_name_servers) k='NETBIOSNAMESERVER' ;; + (*) : skip $v ; continue ;; + esac + [ "k${k}" != k ] && echo "${k}='${!v}'" + done + } | /sbin/netconfig modify -s "dhclient3" -i "$interface" +} + +netconfig_remove() { + /sbin/netconfig remove -s "dhclient3" -i "$interface"