From 2eb86ca13cb658b51440bb28cab47205b641d0ee Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Thu, 10 Mar 2016 10:32:08 -0500 Subject: initial systemd service suggestions provided by pitti This should mean that cloud-init-local is running earlier now (DefaultDependencies=no). And also blocking networking coming up (Before=network-pre.target) cloud-init.service should now actually block network-online.target from being made (meaning it will run before anything that expects that) but after networking.service, which is what actually does the bringup on ifupdown / ubuntu. --- systemd/cloud-init-local.service | 4 ++++ systemd/cloud-init.service | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'systemd') diff --git a/systemd/cloud-init-local.service b/systemd/cloud-init-local.service index 73aa46f6..475a2e11 100644 --- a/systemd/cloud-init-local.service +++ b/systemd/cloud-init-local.service @@ -1,7 +1,11 @@ [Unit] Description=Initial cloud-init job (pre-networking) +DefaultDependencies=no Wants=local-fs.target After=local-fs.target +Conflicts=shutdown.target +Before=network-pre.target +Before=shutdown.target [Service] Type=oneshot diff --git a/systemd/cloud-init.service b/systemd/cloud-init.service index 1f656f7f..6fb655e6 100644 --- a/systemd/cloud-init.service +++ b/systemd/cloud-init.service @@ -1,8 +1,8 @@ [Unit] Description=Initial cloud-init job (metadata service crawler) -After=local-fs.target network-online.target cloud-init-local.service -Before=sshd.service sshd-keygen.service systemd-user-sessions.service -Requires=network-online.target +After=cloud-init-local.service networking.service +Before=network-online.target sshd.service sshd-keygen.service systemd-user-sessions.service +Requires=networking.service Wants=local-fs.target cloud-init-local.service sshd.service sshd-keygen.service [Service] -- cgit v1.2.3 From 2f29e70d99906dd7bff0c64109a77f609577f063 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Thu, 10 Mar 2016 10:35:17 -0500 Subject: 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. --- systemd/cloud-init-generator | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'systemd') 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 -- cgit v1.2.3 From b1d9c92f5bc6f711e104ceb981ded658249c3255 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Thu, 10 Mar 2016 10:41:48 -0500 Subject: generator: use /run/cloud-init instead of /run --- systemd/cloud-init-generator | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'systemd') diff --git a/systemd/cloud-init-generator b/systemd/cloud-init-generator index b7a2f17a..8156db58 100755 --- a/systemd/cloud-init-generator +++ b/systemd/cloud-init-generator @@ -3,7 +3,7 @@ set -f LOG="" DEBUG_LEVEL=1 -LOG_D="/run" +LOG_D="/run/cloud-init" ENABLE="enabled" DISABLE="disabled" CLOUD_SYSTEM_TARGET="/lib/systemd/system/cloud-init.target" @@ -17,7 +17,8 @@ debug() { [ "$lvl" -gt "$DEBUG_LEVEL" ] && return if [ -z "$LOG" ]; then local log="$LOG_D/${0##*/}.log" - { : > "$log"; } >/dev/null 2>&1 && LOG="$log" || + { [ -d "$LOG_D" ] || mkdir -p "$LOG_D"; } && + { : > "$log"; } >/dev/null 2>&1 && LOG="$log" || LOG="/dev/kmsg" fi echo "$@" >> "$LOG" -- cgit v1.2.3