summaryrefslogtreecommitdiff
path: root/tools/hook-network-manager
diff options
context:
space:
mode:
Diffstat (limited to 'tools/hook-network-manager')
-rwxr-xr-xtools/hook-network-manager23
1 files changed, 19 insertions, 4 deletions
diff --git a/tools/hook-network-manager b/tools/hook-network-manager
index 447b134e..98a36c8a 100755
--- a/tools/hook-network-manager
+++ b/tools/hook-network-manager
@@ -2,8 +2,23 @@
# This script hooks into NetworkManager(8) via its scripts
# arguments are 'interface-name' and 'action'
#
+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
+}
-case "$1:$2" in
- *:up) exec cloud-init dhclient-hook up "$1";;
- *:down) exec cloud-init dhclient-hook down "$1";;
-esac
+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 "$1:$2" in
+ *:up) exec cloud-init dhclient-hook up "$1";;
+ *:down) exec cloud-init dhclient-hook down "$1";;
+ esac
+fi