Skip to content

Commit

Permalink
Merge pull request #197 from rancher-sandbox/user-provision
Browse files Browse the repository at this point in the history
Make sure user provisioning scripts can be executed
  • Loading branch information
AkihiroSuda authored Sep 3, 2021
2 parents de25ccc + 6f8b20c commit 950be8a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/cidata/cidata.TEMPLATE.d/boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,19 @@ if [ -d "${LIMA_CIDATA_MNT}"/provision.system ]; then
done
fi

USER_SCRIPT="/home/${LIMA_CIDATA_USER}.linux/.lime-user-script"
if [ -d "${LIMA_CIDATA_MNT}"/provision.user ]; then
until [ -e "/run/user/${LIMA_CIDATA_UID}}/systemd/private" ]; do sleep 3; done
until [ -e "/run/user/${LIMA_CIDATA_UID}/systemd/private" ]; do sleep 3; done
for f in "${LIMA_CIDATA_MNT}"/provision.user/*; do
INFO "Executing $f (as user ${LIMA_CIDATA_USER})"
if ! sudo -iu "${LIMA_CIDATA_USER}" "XDG_RUNTIME_DIR=/run/user/${LIMA_CIDATA_UID}" "$f"; then
cp "$f" "${USER_SCRIPT}"
chown "${LIMA_CIDATA_USER}" "${USER_SCRIPT}"
chmod 755 "${USER_SCRIPT}"
if ! sudo -iu "${LIMA_CIDATA_USER}" "XDG_RUNTIME_DIR=/run/user/${LIMA_CIDATA_UID}" "${USER_SCRIPT}"; then
WARNING "Failed to execute $f (as user ${LIMA_CIDATA_USER})"
CODE=1
fi
rm "${USER_SCRIPT}"
done
fi

Expand Down

0 comments on commit 950be8a

Please sign in to comment.