Skip to content

Commit 1ddb934

Browse files
authored
Merge pull request #2048 from mhio/boot-env
pkg/cidata: During boot, only terminate user connections when the environment changes
2 parents b136264 + 6836aa6 commit 1ddb934

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

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

Lines changed: 2 additions & 4 deletions
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,13 +14,10 @@ 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

20-
# Make sure the guestagent socket from a previous boot is removed before we open the "lima-ssh-ready" gate.
21-
rm -f /run/lima-guest-agent.sock
22-
2321
# Signal that provisioning is done. The instance-id in the meta-data file changes on every boot,
2422
# so any copy from a previous boot cycle will have different content.
2523
cp "${LIMA_CIDATA_MNT}"/meta-data /run/lima-ssh-ready

0 commit comments

Comments
 (0)