From bc6ca7ff88fbad1d24e36bf828915fce34216cd6 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Fri, 30 Jun 2023 12:58:15 +0200 Subject: [PATCH] Generate default config post-install The debian and rpm packages are updated to trigger the generation of of a default config if no config exists at the expected location. Signed-off-by: Evan Lezar --- CHANGELOG.md | 2 +- .../nvidia-container-toolkit-base.postinst | 21 +++++++++++++++++++ .../rpm/SPECS/nvidia-container-toolkit.spec | 3 +++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 packaging/debian/nvidia-container-toolkit-base.postinst diff --git a/CHANGELOG.md b/CHANGELOG.md index bd998fa0..4f1b223b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ * Add option to load kernel modules when creating device nodes * Add option to create device nodes when creating `/dev/char` symlinks * Create ouput folders if required when running `nvidia-ctk runtime configure` - +* Generate default config as post-install step. * [libnvidia-container] Support OpenSSL 3 with the Encrypt/Decrypt library diff --git a/packaging/debian/nvidia-container-toolkit-base.postinst b/packaging/debian/nvidia-container-toolkit-base.postinst new file mode 100644 index 00000000..311af07c --- /dev/null +++ b/packaging/debian/nvidia-container-toolkit-base.postinst @@ -0,0 +1,21 @@ +#!/bin/sh + +set -e + +case "$1" in + configure) + /usr/bin/nvidia-ctk --quiet config default --in-place --config=/etc/nvidia-container-runtime/config.toml + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 diff --git a/packaging/rpm/SPECS/nvidia-container-toolkit.spec b/packaging/rpm/SPECS/nvidia-container-toolkit.spec index 608d3403..e7f1536f 100644 --- a/packaging/rpm/SPECS/nvidia-container-toolkit.spec +++ b/packaging/rpm/SPECS/nvidia-container-toolkit.spec @@ -66,6 +66,9 @@ fi rm -rf %{_localstatedir}/lib/rpm-state/nvidia-container-toolkit ln -sf %{_bindir}/nvidia-container-runtime-hook %{_bindir}/nvidia-container-toolkit +# Generate the default config; If this file already exists no changes are made. +%{_bindir}/nvidia-ctk --quiet config default --in-place --config=%{_sysconfdir}/nvidia-container-runtime/config.toml + %postun if [ "$1" = 0 ]; then # package is uninstalled, not upgraded if [ -L %{_bindir}/nvidia-container-toolkit ]; then rm -f %{_bindir}/nvidia-container-toolkit; fi