Skip to content

Commit

Permalink
Avoid copying the user setup script with 'podman cp'
Browse files Browse the repository at this point in the history
We needed to copy the setup script (for user toolboxes), when they were
generated in /tmp on the host. But they're currently generated directly
in $HOME, and since we bind mount $HOME... well, it's just already
there (and one can even argue that it's a bug copying it!).

So, not copying is the right thing do to and, nicely enough, it also
workarounds what apparently is a podman 3 issue with 'podman cp',
basically fixing issue openSUSE#25 too.

While there, add cleanup logic for the same user setup script. In fact,
if everything goes fine, the script is removed by the toolbox itself
(after executing it). But if there's an error and we bail, it may stick
around, cluttering the home directory.

Signed-off-by: Dario Faggioli <[email protected]>
  • Loading branch information
dfaggioli committed Mar 5, 2021
1 parent daeb191 commit 6999177
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion toolbox
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ if ! command -v sudo &> /dev/null ; then
fi
mkdir -p /etc/sudoers.d/ && echo "${USER_NAME} ALL = (root) NOPASSWD:ALL" > /etc/sudoers.d/${USER_NAME}
EOF
${SUDO} podman cp "${tmp_user_setup}" "${TOOLBOX_NAME}":"${tmp_user_setup}"
${SUDO} podman exec --user root "${TOOLBOX_NAME}" bash "${tmp_user_setup}" &> "${tmp_user_setup_log}"
${SUDO} podman exec --user root "${TOOLBOX_NAME}" rm "${tmp_user_setup}"
fi
Expand All @@ -127,6 +126,7 @@ run() {

cleanup() {
${SUDO} podman stop "$TOOLBOX_NAME" &>/dev/null
${SUDO} rm -f $tmp_user_setup
}

container_exists() {
Expand Down

0 comments on commit 6999177

Please sign in to comment.