| #!/bin/bash |
|
|
| echo-err() { echo "$@" >&2; } |
|
|
| check_insights() { |
| if [[ -f /etc/insights-client/machine-id ]]; then |
| return |
| fi |
| if [[ -f /etc/ilab/insights-opt-out ]]; then |
| return |
| fi |
| local ID |
| eval "$(grep ^ID= /etc/os-release)" |
| if [[ "$ID" != "rhel" ]]; then |
| return |
| fi |
| cat << EOF |
| This host is not connected to Red Hat Insights. |
| |
| To connect this host to Red Hat Insights run the following command: |
| sudo rhc connect --organization <org_id> --activation-key <your_activation_key> |
| |
| To generate an Activation Key: |
| https://console.redhat.com/insights/connector/activation-keys (this page will also display your Organization ID). |
| |
| For more information on Red Hat Insights, please visit: |
| https://docs.redhat.com/en/documentation/subscription_central/1-latest/html/getting_started_with_activation_keys_on_the_hybrid_cloud_console/assembly-creating-managing-activation-keys |
| EOF |
| exit 1 |
| } |
|
|
| check_insights |
|
|
| |
| CONTAINER_DEVICE="__REPLACE_CONTAINER_DEVICE__" |
| IMAGE_NAME="__REPLACE_IMAGE_NAME__" |
|
|
| ENTRYPOINT="ilab" |
| PARAMS=("$@") |
|
|
| if [[ -n "$ILAB_HOME" ]]; then |
| HOME="$ILAB_HOME" |
| fi |
|
|
| for dir in "$HOME/.cache" "$HOME/.config" "$HOME/.local"; do |
| mkdir -p "$dir" |
| done |
|
|
| if [[ "$1" = "shell" ]]; then |
| ENTRYPOINT=bash |
| PARAMS=() |
| fi |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| ADDITIONAL_MOUNTS=() |
| if [ -n "${ILAB_ADDITIONAL_MOUNTS}" ]; then |
| |
| eval "ADDITIONAL_MOUNTS=(${ILAB_ADDITIONAL_MOUNTS})" |
| fi |
| ADDITIONAL_MOUNT_OPTIONS=() |
| for PODMAN_MOUNT in "${ADDITIONAL_MOUNTS[@]}"; do |
| ADDITIONAL_MOUNT_OPTIONS+=("-v" "$PODMAN_MOUNT") |
| done |
|
|
| |
| |
| for authfile in \ |
| "${XDG_RUNTIME_DIR}/containers/auth.json" \ |
| /run/user/${UID}/containers/auth.json \ |
| /run/containers/${UID}/auth.json |
| do |
| if [[ -f "$authfile" ]]; then |
| ADDITIONAL_MOUNT_OPTIONS+=("-v" "$authfile:/run/containers/0/auth.json") |
| break |
| fi |
| done |
|
|
| PODMAN_COMMAND=("podman" "run" "--rm" "-it" |
| "--device" "${CONTAINER_DEVICE}" |
| "--security-opt" "label=disable" "--net" "host" |
| "--shm-size" "10G" |
| "--pids-limit" "-1" |
| "-v" "$HOME:$HOME" |
| "${ADDITIONAL_MOUNT_OPTIONS[@]}" |
| "--env" "VLLM_LOGGING_LEVEL" |
| "--env" "HOME" |
| "--env" "NCCL_DEBUG" |
| "--entrypoint" "$ENTRYPOINT" |
| "--env" "HF_TOKEN" |
| "--env" "SSL_CERT_FILE" |
| "--env" "SSL_CERT_DIR" |
| "${IMAGE_NAME}") |
|
|
| exec "${PODMAN_COMMAND[@]}" "${PARAMS[@]}" |
|
|