#!/bin/sh

set -e

NVIDIA_CONTAINER_RUNTIME_HOOK=/usr/bin/nvidia-container-runtime-hook

case "$1" in
    configure)
        /usr/bin/dcu-ctk --quiet config --config-file=/etc/dcu-container-runtime/config.toml --in-place
        if [ ! -e "${NVIDIA_CONTAINER_RUNTIME_HOOK}" ]; then
            ln -s /usr/bin/dcu-ctk $NVIDIA_CONTAINER_RUNTIME_HOOK
        fi

        /usr/bin/dcu-ctk runtime configure --runtime=docker --set-as-default
        echo -e "\e[032m ================================== \e[0m"
        echo -e "\e[033m Please restart Docker service:     \e[0m"
        echo -e "\e[033m    sudo systemctl restart docker   \e[0m"
        echo -e "\e[032m ================================== \e[0m"
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

#DEBHELPER#

exit 0
