From 6902100f6c1fe05ae352c0f7975cb0e0674a88e3 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Wed, 25 Dec 2024 17:42:38 +0900 Subject: [PATCH] [WIP] alpine: support `--plain` mode Fix issue 3052 - Populate the user account via cloud-init - Populate /bin/bash (specified as the login shell via user-data. Also depended by the host agent) - Install sudo (depended by the host agent, during the "boot scripts must have finished" check) WIP: needs minimization Signed-off-by: Akihiro Suda --- .../{boot => boot.essential}/00-alpine-user-group.sh | 0 .../{boot => boot.essential}/01-alpine-ash-as-bash.sh | 0 .../{boot => boot.essential}/10-alpine-prep.sh | 0 pkg/cidata/cidata.TEMPLATE.d/boot.sh | 11 ++++++++++- .../boot/DO_NOT_ADD_MORE_SCRIPTS.txt | 3 +++ website/content/en/docs/dev/internals.md | 1 + 6 files changed, 14 insertions(+), 1 deletion(-) rename pkg/cidata/cidata.TEMPLATE.d/{boot => boot.essential}/00-alpine-user-group.sh (100%) rename pkg/cidata/cidata.TEMPLATE.d/{boot => boot.essential}/01-alpine-ash-as-bash.sh (100%) rename pkg/cidata/cidata.TEMPLATE.d/{boot => boot.essential}/10-alpine-prep.sh (100%) create mode 100644 pkg/cidata/cidata.TEMPLATE.d/boot/DO_NOT_ADD_MORE_SCRIPTS.txt diff --git a/pkg/cidata/cidata.TEMPLATE.d/boot/00-alpine-user-group.sh b/pkg/cidata/cidata.TEMPLATE.d/boot.essential/00-alpine-user-group.sh similarity index 100% rename from pkg/cidata/cidata.TEMPLATE.d/boot/00-alpine-user-group.sh rename to pkg/cidata/cidata.TEMPLATE.d/boot.essential/00-alpine-user-group.sh diff --git a/pkg/cidata/cidata.TEMPLATE.d/boot/01-alpine-ash-as-bash.sh b/pkg/cidata/cidata.TEMPLATE.d/boot.essential/01-alpine-ash-as-bash.sh similarity index 100% rename from pkg/cidata/cidata.TEMPLATE.d/boot/01-alpine-ash-as-bash.sh rename to pkg/cidata/cidata.TEMPLATE.d/boot.essential/01-alpine-ash-as-bash.sh diff --git a/pkg/cidata/cidata.TEMPLATE.d/boot/10-alpine-prep.sh b/pkg/cidata/cidata.TEMPLATE.d/boot.essential/10-alpine-prep.sh similarity index 100% rename from pkg/cidata/cidata.TEMPLATE.d/boot/10-alpine-prep.sh rename to pkg/cidata/cidata.TEMPLATE.d/boot.essential/10-alpine-prep.sh diff --git a/pkg/cidata/cidata.TEMPLATE.d/boot.sh b/pkg/cidata/cidata.TEMPLATE.d/boot.sh index ab65c7192b7..404ad528efc 100644 --- a/pkg/cidata/cidata.TEMPLATE.d/boot.sh +++ b/pkg/cidata/cidata.TEMPLATE.d/boot.sh @@ -36,8 +36,17 @@ CODE=0 # has run because it might move the directories to /mnt/data on first boot. In that # case changes made on restart would be lost. +# The boot.essential scripts are executed in plain mode too. +for f in "${LIMA_CIDATA_MNT}"/boot.essential/*.sh; do + INFO "Executing $f" + if ! "$f"; then + WARNING "Failed to execute $f" + CODE=1 + fi +done + if [ "$LIMA_CIDATA_PLAIN" = "1" ]; then - INFO "Plain mode. Skipping to run boot scripts. Provisioning scripts will be still executed. Guest agent will not be running." + INFO "Plain mode. Skipping to run non-essential boot scripts. Provisioning scripts will be still executed. Guest agent will not be running." else for f in "${LIMA_CIDATA_MNT}"/boot/*; do INFO "Executing $f" diff --git a/pkg/cidata/cidata.TEMPLATE.d/boot/DO_NOT_ADD_MORE_SCRIPTS.txt b/pkg/cidata/cidata.TEMPLATE.d/boot/DO_NOT_ADD_MORE_SCRIPTS.txt new file mode 100644 index 00000000000..7ec1d4e2b8b --- /dev/null +++ b/pkg/cidata/cidata.TEMPLATE.d/boot/DO_NOT_ADD_MORE_SCRIPTS.txt @@ -0,0 +1,3 @@ +The "essential" scripts are limited to scripts that are essential even in the "plain" mode (`limactl create --plain`). + +Do not add more scripts to this `boot.essential` directory, unless they are really essential. diff --git a/website/content/en/docs/dev/internals.md b/website/content/en/docs/dev/internals.md index 53701be3a31..ad94d42de59 100644 --- a/website/content/en/docs/dev/internals.md +++ b/website/content/en/docs/dev/internals.md @@ -162,6 +162,7 @@ See [Building Ansible inventories](https://docs.ansible.com/ansible/latest/inven - `lima-guestagent`: Lima guest agent binary - `nerdctl-full.tgz`: [`nerdctl-full---.tar.gz`](https://github.com/containerd/nerdctl/releases) - `boot.sh`: Boot script +- `boot.essential/*`: Boot script modules (executed in "plain" mode too) - `boot/*`: Boot script modules - `util/*`: Utility command scripts, executed in the boot script modules - `provision.system/*`: Custom provision scripts (system)