summaryrefslogtreecommitdiff
path: root/systemd
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-03-10 10:35:17 -0500
committerScott Moser <smoser@ubuntu.com>2016-03-10 10:35:17 -0500
commit2f29e70d99906dd7bff0c64109a77f609577f063 (patch)
tree2f507e3531c00bd692533db4b3b339cd0d6c8a64 /systemd
parent2eb86ca13cb658b51440bb28cab47205b641d0ee (diff)
downloadvyos-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.
Diffstat (limited to 'systemd')
-rwxr-xr-xsystemd/cloud-init-generator17
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