diff --git a/overlay/files/system/oem/11_persistency.yaml b/overlay/files/system/oem/11_persistency.yaml index b5d8a0580..9623fe991 100644 --- a/overlay/files/system/oem/11_persistency.yaml +++ b/overlay/files/system/oem/11_persistency.yaml @@ -36,21 +36,22 @@ stages: /usr/share/pki/trust/anchors /var/lib/ca-certificates PERSISTENT_STATE_BIND: "true" - - if: | - [ -r /run/cos/custom-layout.env ] - name: "append custom bind and ephemeral mounts to /run/cos/cos-layout.env" + - if: '[ -r /run/cos/custom-layout.env ] && [ ! -f "/run/cos/recovery_mode" ] && [ ! -f /run/cos/live_mode ]' + name: "add custom bind and ephemeral mounts to /run/cos/cos-layout.env" commands: - | - source /run/cos/cos-layout.env - source /run/cos/custom-layout.env - PERSISTENT_STATE_PATHS="${CUSTOM_EPHEMERAL_MOUNTS} ${PERSISTENT_STATE_PATHS}" - RW_PATHS="${CUSTOM_BIND_MOUNTS} ${RW_PATHS}" - echo CUSTOM_BIND_MOUNTS=\"${CUSTOM_BIND_MOUNTS}\" >> /run/cos/cos-layout.env - echo CUSTOM_EPHEMERAL_MOUNTS=\"${CUSTOM_EPHEMERAL_MOUNTS}\" >> /run/cos/cos-layout.env - echo "# rw paths with user bind mounts" >> /run/cos/cos-layout.env - echo RW_PATHS=\"${RW_PATHS}\" >> /run/cos/cos-layout.env - echo "# persistent state paths with user ephemeral mounts" >> /run/cos/cos-layout.env - echo PERSISTENT_STATE_PATHS=\"${PERSISTENT_STATE_PATHS}\" >> /run/cos/cos-layout.env + source /run/cos/cos-layout.env + source /run/cos/custom-layout.env + PERSISTENT_STATE_PATHS="${CUSTOM_BIND_MOUNTS} ${PERSISTENT_STATE_PATHS}" + RW_PATHS="${CUSTOM_EPHEMERAL_MOUNTS} ${RW_PATHS}" + # Remove the existing lines that we are gonna rewrite + sed -i "/RW_PATHS/d" /run/cos/cos-layout.env + sed -i "/PERSISTENT_STATE_PATHS/d" /run/cos/cos-layout.env + # Add the new lines + echo "# rw paths with user bind mounts" >> /run/cos/cos-layout.env + echo RW_PATHS=\"${RW_PATHS}\" >> /run/cos/cos-layout.env + echo "# persistent state paths with user ephemeral mounts" >> /run/cos/cos-layout.env + echo PERSISTENT_STATE_PATHS=\"${PERSISTENT_STATE_PATHS}\" >> /run/cos/cos-layout.env - if: | cat /proc/cmdline | grep -q "kairos.boot_live_mode" name: "Layout configuration" diff --git a/tests/install_test.go b/tests/install_test.go index 4fd620a38..e89c696ed 100644 --- a/tests/install_test.go +++ b/tests/install_test.go @@ -93,11 +93,11 @@ bundles: Eventually(func() string { out, _ := Sudo("cat /run/cos/cos-layout.env") return out - }, 5*time.Minute, 10*time.Second).Should(ContainSubstring("CUSTOM_BIND_MOUNTS=\"/mnt/bind1 /mnt/bind2\"")) + }, 5*time.Minute, 10*time.Second).Should(ContainSubstring("PERSISTENT_STATE_PATHS=\"/mnt/bind1 /mnt/bind2")) Eventually(func() string { out, _ := Sudo("cat /run/cos/cos-layout.env") return out - }, 5*time.Minute, 10*time.Second).Should(ContainSubstring("CUSTOM_EPHEMERAL_MOUNTS=\"/mnt/ephemeral /mnt/ephemeral2\"")) + }, 5*time.Minute, 10*time.Second).Should(ContainSubstring("RW_PATHS=\"/mnt/ephemeral /mnt/ephemeral2")) Eventually(func() string { out, _ := Sudo("/usr/local/bin/usr/bin/edgevpn --help | grep peer")