浏览文件
07-etc-environment.sh
27 行 · 1.0 KB历史下载| 1 | |
| 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 changes on every boot, |
| 26 | # so any value from a previous boot cycle will be different. |
| 27 | echo "${LIMA_CIDATA_IID}" >/run/lima-ssh-ready |

