File: //snap/docker/3618/meta/hooks/post-refresh
#!/bin/bash
set -eu
. "${SNAP}/usr/share/nvidia-container-toolkit/lib"
# ensure the layouts dir for /etc/{stuff} exists
mkdir -p "$SNAP_DATA/etc/docker"
mkdir -p "$SNAP_DATA/config"
ensure_nvidia_data_dirs
# copy the config file from $SNAP into $SNAP_DATA if it doesn't exist
if [ ! -f "$SNAP_DATA/config/daemon.json" ]; then
cp "$SNAP/config/daemon.json" "$SNAP_DATA/config/daemon.json"
fi
## Only required in post-refresh ##
# nvidia-conatiner-tooolkit requires either core or classic support #
# If either are present, enable the service, else disable the service #
if nvidia_support_classic || nvidia_support_core; then
snapctl start --enable "${SNAP_NAME}.nvidia-container-toolkit"
else
snapctl stop --disable "${SNAP_NAME}.nvidia-container-toolkit"
fi