diff options
author | Scott Moser <smoser@ubuntu.com> | 2016-03-10 10:35:17 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2016-03-10 10:35:17 -0500 |
commit | 2f29e70d99906dd7bff0c64109a77f609577f063 (patch) | |
tree | 2f507e3531c00bd692533db4b3b339cd0d6c8a64 | |
parent | 2eb86ca13cb658b51440bb28cab47205b641d0ee (diff) | |
download | vyos-cloud-init-2f29e70d99906dd7bff0c64109a77f609577f063.tar.gz vyos-cloud-init-2f29e70d99906dd7bff0c64109a77f609577f063.zip |
generator: support reading cmdline of pid 1 in a container
This might need cleaning up in the future as I believe in some
containers /proc/cmdline is provided, and in that case it would
be preferred to pid 1's command line.
-rwxr-xr-x | systemd/cloud-init-generator | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/systemd/cloud-init-generator b/systemd/cloud-init-generator index 9d1e22f0..b7a2f17a 100755 --- a/systemd/cloud-init-generator +++ b/systemd/cloud-init-generator @@ -32,15 +32,16 @@ etc_file() { } read_proc_cmdline() { - if [ "$CONTAINER" = "lxc" ]; then - _RET_MSG="ignored: \$container=$CONTAINER" - _RET="" - return 0 - fi - - if systemd-detect-virt --container --quiet; then - _RET_MSG="ignored: detect-virt is container" + # return /proc/cmdline for non-container, and /proc/1/cmdline for container + local ctname="systemd" + if [ -n "$CONTAINER" ] && ctname=$CONTAINER || systemd-detect-virt --container --quiet; then + local + if _RET=$(tr '\0' ' ' < /proc/1/cmdline) >/dev/null 2>&1; then + _RET_MSG="container[$ctname]: pid 1 cmdline" + return + fi _RET="" + _RET_MSG="container[$ctname]: pid 1 cmdline not available" return 0 fi |