summaryrefslogtreecommitdiffstats
path: root/source/installer/sources/initrd/etc/dhcpc/dhcpcd.exe-sample
blob: f49cffdd043f151d6477156c9f3cf0b5730afac0 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
#
#  This is a sample /etc/dhcpc/dhcpcd.exe script.
#  /etc/dhcpc/dhcpcd.exe script is executed by dhcpcd daemon
#  any time it configures or shuts down interface.
#  The following parameters are passed to dhcpcd.exe script:
#  $1 = HostInfoFilePath, e.g  "/etc/dhcpc/dhcpcd-eth0.info"
#  $2 = "up" if interface has been configured with the same
#       IP address as before reboot;
#  $2 = "down" if interface has been shut down;
#  $2 = "new" if interface has been configured with new IP address;
#  $3 (optional) = "-d" debug flag passed if dhcpcd daemon has been
#       invoked with "-d" flag
#
#  Sanity checks

if [ $# -lt 2 ]; then
  logger -s -p local0.err -t dhcpcd.exe "wrong usage"
  exit 1
fi

hostinfo="$1"
state="$2"
debug="$3"

# Reading HostInfo file for configuration parameters
. "${hostinfo}"

case "${state}" in
    up)
    logger -s -p local0.info -t dhcpcd.exe \
    "interface ${INTERFACE} has been configured with old IP=${IPADDR}"
    # Put your code here for when the interface has been brought up with an
    # old IP address here
    ;;

    new)
    logger -s -p local0.info -t dhcpcd.exe \
    "interface ${INTERFACE} has been configured with new IP=${IPADDR}"
    # Put your code here for when the interface has been brought up with a
    # new IP address
    ;;

    down) logger -s -p local0.info -t dhcpcd.exe \
    "interface ${INTERFACE} has been brought down"
    # Put your code here for the when the interface has been shut down
    ;;
esac
exit 0