Skip to content

Commit 6f8b20c

Browse files
committed
Make sure user provisioning scripts can be executed
There are 2 issues: * a typo (note the double "}}") made the waiting loop run forever: until [ -e "/run/user/${LIMA_CIDATA_UID}}/systemd/private" ]; do sleep 3; done * the user scripts are owned by root with mode 700 on /mnt/lima_cidata/... so not accessible by the regular user This commit copies them into the home directory (and deletes them after execution) Signed-off-by: Jan Dubois <[email protected]>
1 parent de25ccc commit 6f8b20c

File tree

1 file changed

+7
-2
lines changed
  • pkg/cidata/cidata.TEMPLATE.d

1 file changed

+7
-2
lines changed

pkg/cidata/cidata.TEMPLATE.d/boot.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,19 @@ if [ -d "${LIMA_CIDATA_MNT}"/provision.system ]; then
3232
done
3333
fi
3434

35+
USER_SCRIPT="/home/${LIMA_CIDATA_USER}.linux/.lime-user-script"
3536
if [ -d "${LIMA_CIDATA_MNT}"/provision.user ]; then
36-
until [ -e "/run/user/${LIMA_CIDATA_UID}}/systemd/private" ]; do sleep 3; done
37+
until [ -e "/run/user/${LIMA_CIDATA_UID}/systemd/private" ]; do sleep 3; done
3738
for f in "${LIMA_CIDATA_MNT}"/provision.user/*; do
3839
INFO "Executing $f (as user ${LIMA_CIDATA_USER})"
39-
if ! sudo -iu "${LIMA_CIDATA_USER}" "XDG_RUNTIME_DIR=/run/user/${LIMA_CIDATA_UID}" "$f"; then
40+
cp "$f" "${USER_SCRIPT}"
41+
chown "${LIMA_CIDATA_USER}" "${USER_SCRIPT}"
42+
chmod 755 "${USER_SCRIPT}"
43+
if ! sudo -iu "${LIMA_CIDATA_USER}" "XDG_RUNTIME_DIR=/run/user/${LIMA_CIDATA_UID}" "${USER_SCRIPT}"; then
4044
WARNING "Failed to execute $f (as user ${LIMA_CIDATA_USER})"
4145
CODE=1
4246
fi
47+
rm "${USER_SCRIPT}"
4348
done
4449
fi
4550

0 commit comments

Comments
 (0)