Dynamic host configuration protocol software
CentOS Sources
2018-05-15 9431ab0c280b60f5e935fb29bb5c10e3335e3340
commit | author | age
54343e 1 #!/bin/bash
CS 2 # run dhclient.d scripts in an emulated environment
3
4 PATH=/bin:/usr/bin:/sbin
5 SAVEDIR=/var/lib/dhclient
6 ETCDIR=/etc/dhcp
7 interface=$1
8
9 eval "$(
e52af9 10 declare | LC_ALL=C grep '^DHCP4_[A-Z_]*=' | while read -r opt; do
54343e 11     optname=${opt%%=*}
CS 12     optname=${optname,,}
13     optname=new_${optname#dhcp4_}
14     optvalue=${opt#*=}
15     echo "export $optname=$optvalue"
16 done
17 )"
18
19 [ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
20
21 [ -f /etc/sysconfig/network-scripts/ifcfg-$interface ] && \
22     . /etc/sysconfig/network-scripts/ifcfg-$interface
23
24 if [ -d $ETCDIR/dhclient.d ]; then
25     for f in $ETCDIR/dhclient.d/*.sh; do
26         if [ -x $f ]; then
27             subsystem="${f%.sh}"
28             subsystem="${subsystem##*/}"
29             . ${f}
30             if [ "$2" = "up" ]; then
31                 "${subsystem}_config"
32             elif [ "$2" = "dhcp4-change" ]; then
33                 if [ "$subsystem" = "chrony" -o "$subsystem" = "ntp" ]; then
34                     "${subsystem}_config"
35                 fi
36             elif [ "$2" = "down" ]; then
37                 "${subsystem}_restore"
38             fi
39         fi
40     done
41 fi