Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
lima-vm
GitHub Repository: lima-vm/lima
Path: blob/master/pkg/cidata/cidata.TEMPLATE.d/boot/07-etc-environment.sh
2661 views
1
#!/bin/sh
2
3
# SPDX-FileCopyrightText: Copyright The Lima Authors
4
# SPDX-License-Identifier: Apache-2.0
5
6
set -eux
7
8
# /etc/environment must be written after 04-persistent-data-volume.sh has run to
9
# make sure the changes on a restart are applied to the persisted version.
10
11
orig=$(test ! -f /etc/environment || cat /etc/environment)
12
if [ -e /etc/environment ]; then
13
sed -i '/#LIMA-START/,/#LIMA-END/d' /etc/environment
14
fi
15
cat "${LIMA_CIDATA_MNT}/etc_environment" >>/etc/environment
16
17
# It is possible that a requirements script has started an ssh session before
18
# /etc/environment was updated, so we need to kill it to make sure it will
19
# restart with the updated environment before "linger" is being enabled.
20
21
if command -v loginctl >/dev/null 2>&1 && [ "${orig}" != "$(cat /etc/environment)" ]; then
22
loginctl terminate-user "${LIMA_CIDATA_USER}" || true
23
fi
24
25
# Signal that provisioning is done. The instance-id in the meta-data file changes on every boot,
26
# so any copy from a previous boot cycle will have different content.
27
cp "${LIMA_CIDATA_MNT}"/meta-data /run/lima-ssh-ready
28
29