hook-dhclient 805 Bytes
Newer Older
1
#!/bin/sh
2 3
# This file is part of cloud-init. See LICENSE file for license information.

4 5
# This script writes DHCP lease information into the cloud-init run directory
# It is sourced, not executed.  For more information see dhclient-script(8).
6

7 8 9 10 11 12 13
is_azure() {
    local dmi_path="/sys/class/dmi/id/board_vendor" vendor=""
    if [ -e "$dmi_path" ] && read vendor < "$dmi_path"; then
        [ "$vendor" = "Microsoft Corporation" ] && return 0
    fi
    return 1
}
14

15 16 17 18 19 20 21 22 23 24 25 26 27
is_enabled() {
    # only execute hooks if cloud-init is enabled and on azure
    [ -e /run/cloud-init/enabled ] || return 1
    is_azure
}

if is_enabled; then
   case "$reason" in
      BOUND) cloud-init dhclient-hook up "$interface";;
      DOWN|RELEASE|REBOOT|STOP|EXPIRE)
         cloud-init dhclient-hook down "$interface";;
   esac
fi