| 1 | #!/bin/sh |
| 2 | # This file is part of cloud-init. See LICENSE file for license information. |
| 3 | |
| 4 | # This script is used on non-systemd systems. It is called by the |
| 5 | # cloud-init-hotplug init.d script. |
| 6 | # |
| 7 | # Creates a named pipe and then continually listens to this pipe. The pipe |
| 8 | # is written to by the hook-hotplug script (which is called by a udev rule |
| 9 | # upon a network device event). Anything received via the pipe is then |
| 10 | # passed on via the "cloud-init devel hotplug-hook handle" command. |
| 11 | |
| 12 | PIPE="/run/cloud-init/share/hook-hotplug-cmd" |
| 13 | |
| 14 | [ -p $PIPE ] || mkfifo -m700 $PIPE |
| 15 | |
| 16 | while true; do |
| 17 | # shellcheck disable=SC2162 |
| 18 | if read args < $PIPE; then |
| 19 | # shellcheck disable=SC2086 |
| 20 | /usr/bin/cloud-init devel hotplug-hook $args |
| 21 | fi |
| 22 | done |