summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-03-14 09:52:39 -0400
committerScott Moser <smoser@ubuntu.com>2016-03-14 09:52:39 -0400
commit8a929e66f2fe2aaed968ec23aeaf6d3b3c68cb65 (patch)
tree029dfc2c891a151cca226cde76989feb2dd08f79
parent97f81cbecf39c340b6c000d62536fcb7f1ef87b0 (diff)
parentb1d9c92f5bc6f711e104ceb981ded658249c3255 (diff)
downloadvyos-cloud-init-8a929e66f2fe2aaed968ec23aeaf6d3b3c68cb65.tar.gz
vyos-cloud-init-8a929e66f2fe2aaed968ec23aeaf6d3b3c68cb65.zip
some systemd cleanups
generator: * write to directory /run/cloud-init/ rather than /run * read from /proc/1/cmdline for the command line if inside a container cloud-init-local.service: now run fully before any networking comes up. cloud-init.service: run before network-online.target and after networking.service. This ends up meaning other things that require network-online.target will run after cloud-init.service, but cloud-init.service will still have networking. The 'networking.service' is ifupdown specific. Further changes would be needed for other networking systems (networkd for example)
-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]