diff options
| author | Scott Moser <smoser@brickies.net> | 2016-09-09 21:46:49 -0400 |
|---|---|---|
| committer | Scott Moser <smoser@brickies.net> | 2016-09-09 21:46:49 -0400 |
| commit | ea732e69516983b1d9838b0d80540a832594748a (patch) | |
| tree | f23cbf03e360f913e98e15d232bcf871770806e8 /tools/hook-dhclient | |
| parent | eb5860ec6ed76a90fb837001ab2ed54e1dcf78de (diff) | |
| parent | 34a26f7f59f2963691e36ca0476bec9fc9ccef63 (diff) | |
| download | vyos-cloud-init-ea732e69516983b1d9838b0d80540a832594748a.tar.gz vyos-cloud-init-ea732e69516983b1d9838b0d80540a832594748a.zip | |
Merge branch 'master' into ubuntu/xenial
Diffstat (limited to 'tools/hook-dhclient')
| -rwxr-xr-x | tools/hook-dhclient | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/hook-dhclient b/tools/hook-dhclient new file mode 100755 index 00000000..6a4626c6 --- /dev/null +++ b/tools/hook-dhclient @@ -0,0 +1,24 @@ +#!/bin/sh +# This script writes DHCP lease information into the cloud-init run directory +# It is sourced, not executed. For more information see dhclient-script(8). +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 +} + +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 |
