3
# This is a sample /etc/dhcpc/dhcpcd.exe script.
4
# /etc/dhcpc/dhcpcd.exe script is executed by dhcpcd daemon
5
# any time it configures or shuts down interface.
6
# The following parameters are passed to dhcpcd.exe script:
7
# $1 = HostInfoFilePath, e.g "/var/lib/dhcpc/dhcpcd-eth0.info"
8
# $2 = "up" if interface has been configured with the same
9
# IP address as before reboot;
10
# $2 = "down" if interface has been shut down;
11
# $2 = "new" if interface has been configured with new IP address;
12
# $3 (optional) = "-d" debug flag passed if dhcpcd daemon has been
13
# invoked with "-d" flag
15
# This script sources /var/lib/dhcpc/dhcpcd-<interface>.info which defines
17
# NOTE THAT THE DATA IN SOME OF THESE VARIABLES COME FROM
18
# UNTRUSTED SOURCES AND ARE UNCHECKED.
19
# The variables in question are HOSTNAME, DOMAIN, NISDOMAIN,
20
# ROOTPATH DNSSEARCH and DHCPSNAME. Enough quoting is done to ensure that
21
# execution of this script is safe, but beware if you pass the value of any of
22
# these variables to another shell or perl script - there is nothing to
23
# stop an attacker putting dangerous characters in these variables.
25
# This is important: if noglob not set a filename expansion metachar may be
26
# included in one of the variables set in the info file and executed
27
# if that variable is used.
28
# Try this to see the effect:
29
# TEST='*'; echo $TEST
35
logger -s -p local0.err -t dhcpcd.exe "wrong usage"
43
# Reading HostInfo file for configuration parameters
44
if ! [ -f ${hostinfo} ]; then
45
logger -s -p local0.err -t dhcpcd.exe "No hostinfo file"
55
[ "$dnsservs" != "" ] && [ "$DNSSEARCH" != "" ] && r="${r}search $DNSSEARCH
57
[ "$dnsservs" != "" ] && [ "$DNSSEARCH" == "" ] && [ "$DOMAIN" != "" ] && r="${r}search $DOMAIN
59
for serv in $dnsservs; do
60
r="${r}nameserver $serv
63
if [ -x /sbin/resolvconf ] ; then
64
echo -n "$r" | /sbin/resolvconf -a "$INTERFACE"
66
# set /etc/dhcpc/resolv.conf for compatiblity with older packages
67
echo -n "$r" >| /etc/dhcpc/resolv.conf
68
chmod 644 /etc/dhcpc/resolv.conf
74
if [ -x /sbin/resolvconf ] ; then
75
/sbin/resolvconf -d "$INTERFACE"
82
*) logger -s -p local0.err -t dhcpcd.exe "wrong interface name \"${INTERFACE}\""
88
up) logger -s -p local0.info -t dhcpcd.exe "interface ${INTERFACE} has been configured with old IP=${IPADDR}"
91
# ==== Put your code for the case interface has been brought up with old IP address here
99
new) logger -s -p local0.info -t dhcpcd.exe "interface ${INTERFACE} has been configured with new IP=${IPADDR}"
102
# ==== Put your code for the case interface has been brought up with new IP address here
110
down) logger -s -p local0.info -t dhcpcd.exe "interface ${INTERFACE} has been brought down"
112
# ==== Put your code for the case interface has been shut down here