43 lines
1.1 KiB
Plaintext
43 lines
1.1 KiB
Plaintext
description "NVIDIA Docker plugin"
|
|
|
|
start on (local-filesystems and net-device-up)
|
|
stop on runlevel [!2345]
|
|
|
|
normal exit 0 KILL TERM
|
|
respawn
|
|
respawn limit 5 10
|
|
|
|
kill timeout 20
|
|
|
|
env NVIDIA_DOCKER_USER=#PACKAGE#
|
|
env NVIDIA_DOCKER_PLUGIN=/usr/bin/nvidia-docker-plugin
|
|
env NVIDIA_DOCKER_PLUGIN_SPEC=/etc/docker/plugins/nvidia-docker.spec
|
|
|
|
script
|
|
if [ -f /etc/default/$UPSTART_JOB ]; then
|
|
. /etc/default/$UPSTART_JOB
|
|
fi
|
|
OPTS="$NVIDIA_DOCKER_PLUGIN_OPTS"
|
|
|
|
exec start-stop-daemon -S -u "$NVIDIA_DOCKER_USER" -c "$NVIDIA_DOCKER_USER" \
|
|
-a "$NVIDIA_DOCKER_PLUGIN" -- $OPTS
|
|
end script
|
|
|
|
post-start script
|
|
if [ -f /etc/default/$UPSTART_JOB ]; then
|
|
. /etc/default/$UPSTART_JOB
|
|
fi
|
|
OPTS="$NVIDIA_DOCKER_PLUGIN_OPTS"
|
|
SOCK_DIR=$( echo $OPTS | grep -oP -- '-s\s+\K\S+' )
|
|
SOCK_FILE=unix://$SOCK_DIR/nvidia-docker.sock
|
|
|
|
if [ -n "$SOCK_DIR" ]; then
|
|
mkdir -p $( dirname "$NVIDIA_DOCKER_PLUGIN_SPEC" )
|
|
echo "$SOCK_FILE" > "$NVIDIA_DOCKER_PLUGIN_SPEC"
|
|
fi
|
|
end script
|
|
|
|
post-stop script
|
|
rm -f "$NVIDIA_DOCKER_PLUGIN_SPEC"
|
|
end script
|