Skip to content

Instantly share code, notes, and snippets.

@04n0
Created February 13, 2018 12:02
Show Gist options
  • Save 04n0/e6c065de0d0cf725b406e36bdb2a81c0 to your computer and use it in GitHub Desktop.
Save 04n0/e6c065de0d0cf725b406e36bdb2a81c0 to your computer and use it in GitHub Desktop.
#!/bin/sh
# This script adds a Mac OS Launch Daemon, which runs every time the
# machine is booted. The daemon will re-detect the attached network
# interfaces. If this is not done, network devices may not work.
PLIST=/Library/LaunchDaemons/com.github.04n0.osx-vm-templates.detectnewhardware.plist
cat <<EOF > "${PLIST}"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.github.04n0.osx-vm-templates.detectnewhardware</string>
<key>ProgramArguments</key>
<array>
<string>/usr/sbin/networksetup</string>
<string>-detectnewhardware</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOF
# These should be already set as follows, but since they're required
# in order to load properly, we set them explicitly.
/bin/chmod 644 "${PLIST}"
/usr/sbin/chown root:wheel "${PLIST}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment