Skip to content

Commit f0f43cc

Browse files
committed
pkg/cidata: Terminate user only when the environment changes
Signed-off-by: mhio <[email protected]>
1 parent bfd7471 commit f0f43cc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/cidata/cidata.TEMPLATE.d/boot/07-etc-environment.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -eux
44
# /etc/environment must be written after 04-persistent-data-volume.sh has run to
55
# make sure the changes on a restart are applied to the persisted version.
66

7+
orig=$(test -f /etc/environment && cat /etc/environment)
78
if [ -e /etc/environment ]; then
89
sed -i '/#LIMA-START/,/#LIMA-END/d' /etc/environment
910
fi
@@ -13,7 +14,7 @@ cat "${LIMA_CIDATA_MNT}/etc_environment" >>/etc/environment
1314
# /etc/environment was updated, so we need to kill it to make sure it will
1415
# restart with the updated environment before "linger" is being enabled.
1516

16-
if command -v loginctl >/dev/null 2>&1; then
17+
if command -v loginctl >/dev/null 2>&1 && [ "${orig}" != "$(cat /etc/environment)" ]; then
1718
loginctl terminate-user "${LIMA_CIDATA_USER}" || true
1819
fi
1920

0 commit comments

Comments
 (0)