diff --git a/training/ilab-wrapper/ilab b/training/ilab-wrapper/ilab index 6d9cf15d..923ca16d 100755 --- a/training/ilab-wrapper/ilab +++ b/training/ilab-wrapper/ilab @@ -12,21 +12,42 @@ if [[ -n "$ILAB_HOME" ]]; then fi for dir in "$HOME/.cache" "$HOME/.config" "$HOME/.local"; do - mkdir -p "$dir" + mkdir -p "$dir" done if [[ "$1" = "shell" ]]; then - export ENTRYPOINT=bash - export PARAMS=() + export ENTRYPOINT=bash + export PARAMS=() fi +# If you need to mount additional volumes into the container, you can specify them +# using the ILAB_ADDITIONAL_MOUNTS environment variable. +# +# Example ILAB_ADDITIONAL_MOUNTS usage: +# +# ILAB_ADDITIONAL_MOUNTS="/host/path:/container/path /host/path2:/container/path2" +# +# If your path contains spaces, you can use quotes: +# +# ILAB_ADDITIONAL_MOUNTS="/host/path:/container/path '/host/path with spaces':/container/path" +ADDITIONAL_MOUNTS=() +if [ -n "${ILAB_ADDITIONAL_MOUNTS}" ]; then + # (eval is used here to allow the user to specify mounts that might have spaces in them) + eval "ADDITIONAL_MOUNTS=(${ILAB_ADDITIONAL_MOUNTS})" +fi +ADDITIONAL_MOUNT_OPTIONS=() +for PODMAN_MOUNT in "${ADDITIONAL_MOUNTS[@]}"; do + ADDITIONAL_MOUNT_OPTIONS+=("-v" "$PODMAN_MOUNT") +done + PODMAN_COMMAND=("podman" "run" "--rm" "-it" - "--device" "${CONTAINER_DEVICE}" - "--security-opt" "label=disable" "--net" "host" - "-v" "$HOME:$HOME" - "--env" "HOME" - "--entrypoint" "$ENTRYPOINT" - "--env" "HF_TOKEN" - "${IMAGE_NAME}") + "--device" "${CONTAINER_DEVICE}" + "--security-opt" "label=disable" "--net" "host" + "-v" "$HOME:$HOME" + "${ADDITIONAL_MOUNT_OPTIONS[@]}" + "--env" "HOME" + "--entrypoint" "$ENTRYPOINT" + "--env" "HF_TOKEN" + "${IMAGE_NAME}") exec "${PODMAN_COMMAND[@]}" "${PARAMS[@]}" diff --git a/training/nvidia-bootc/duplicated/ilab-wrapper/ilab b/training/nvidia-bootc/duplicated/ilab-wrapper/ilab index 6d9cf15d..923ca16d 100755 --- a/training/nvidia-bootc/duplicated/ilab-wrapper/ilab +++ b/training/nvidia-bootc/duplicated/ilab-wrapper/ilab @@ -12,21 +12,42 @@ if [[ -n "$ILAB_HOME" ]]; then fi for dir in "$HOME/.cache" "$HOME/.config" "$HOME/.local"; do - mkdir -p "$dir" + mkdir -p "$dir" done if [[ "$1" = "shell" ]]; then - export ENTRYPOINT=bash - export PARAMS=() + export ENTRYPOINT=bash + export PARAMS=() fi +# If you need to mount additional volumes into the container, you can specify them +# using the ILAB_ADDITIONAL_MOUNTS environment variable. +# +# Example ILAB_ADDITIONAL_MOUNTS usage: +# +# ILAB_ADDITIONAL_MOUNTS="/host/path:/container/path /host/path2:/container/path2" +# +# If your path contains spaces, you can use quotes: +# +# ILAB_ADDITIONAL_MOUNTS="/host/path:/container/path '/host/path with spaces':/container/path" +ADDITIONAL_MOUNTS=() +if [ -n "${ILAB_ADDITIONAL_MOUNTS}" ]; then + # (eval is used here to allow the user to specify mounts that might have spaces in them) + eval "ADDITIONAL_MOUNTS=(${ILAB_ADDITIONAL_MOUNTS})" +fi +ADDITIONAL_MOUNT_OPTIONS=() +for PODMAN_MOUNT in "${ADDITIONAL_MOUNTS[@]}"; do + ADDITIONAL_MOUNT_OPTIONS+=("-v" "$PODMAN_MOUNT") +done + PODMAN_COMMAND=("podman" "run" "--rm" "-it" - "--device" "${CONTAINER_DEVICE}" - "--security-opt" "label=disable" "--net" "host" - "-v" "$HOME:$HOME" - "--env" "HOME" - "--entrypoint" "$ENTRYPOINT" - "--env" "HF_TOKEN" - "${IMAGE_NAME}") + "--device" "${CONTAINER_DEVICE}" + "--security-opt" "label=disable" "--net" "host" + "-v" "$HOME:$HOME" + "${ADDITIONAL_MOUNT_OPTIONS[@]}" + "--env" "HOME" + "--entrypoint" "$ENTRYPOINT" + "--env" "HF_TOKEN" + "${IMAGE_NAME}") exec "${PODMAN_COMMAND[@]}" "${PARAMS[@]}"