summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsystemd/cloud-init-generator22
-rw-r--r--systemd/cloud-init-local.service4
-rw-r--r--systemd/cloud-init.service6
3 files changed, 19 insertions, 13 deletions
diff --git a/systemd/cloud-init-generator b/systemd/cloud-init-generator
index 9d1e22f0..2d319695 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"
@@ -32,15 +33,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
+ if { _RET=$(tr '\0' ' ' < /proc/1/cmdline); } 2>/dev/null; then
+ _RET_MSG="container[$ctname]: pid 1 cmdline"
+ return
+ fi
_RET=""
+ _RET_MSG="container[$ctname]: pid 1 cmdline not available"
return 0
fi
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]