Debian Codegraph @

tools/hook-hotplug

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 # This file is part of cloud-init. See LICENSE file for license information.
3
4 # This script checks if cloud-init has hotplug hooked and if
5 # cloud-init is ready; if so invoke cloud-init hotplug-hook
6
7 fifo=/run/cloud-init/share/hook-hotplug-cmdscip-shell filesystem . . `/run/cloud-init/share/hook-hotplug-cmd`.
8 log_file=/run/cloud-init/hook-hotplug.logscip-shell filesystem . . `/run/cloud-init/hook-hotplug.log`.
9
10 should_runscip-shell shell shell-project 0.0.0 should_run().() {
11 if [scip-shell system . . `[`. -d /run/systemdscip-shell filesystem . . `/run/systemd`. ]; then
12 # check that the socket is ready
13 [scip-shell system . . `[`. -p $fifo ]
14 else
15 # on non-systemd, check cloud-init fully finished.
16 [scip-shell system . . `[`. -e /run/cloud-init/result.jsonscip-shell filesystem . . `/run/cloud-init/result.json`. ]
17 fi
18 }
19
20 if ! should_runscip-shell shell shell-project 0.0.0 should_run().; then
21 # This happens when a device is hotplugged before cloud-init-hotplugd.socket is
22 # listening on the socket.
23 echoscip-shell system . . echo. "Not running hotplug, not ready yet" >> ${log_file}
24 exit 0
25 fi
26
27 # open cloud-init's hotplug-hook fifo rw
28 exec 3<> $fifo
29 env_params=" --subsystem=${SUBSYSTEM} handle --devpath=${DEVPATH} --udevaction=${ACTION}"
30 # write params to cloud-init's hotplug-hook fifo
31 echoscip-shell system . . echo. "${env_params}" >&3
32 echoscip-shell system . . echo. "Running hotplug hook: $env_params" >> ${log_file}