forked from netbrain/zwift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzwift.sh
executable file
·39 lines (31 loc) · 946 Bytes
/
zwift.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# The home directory to store zwift data
ZWIFT_HOME=${ZWIFT_HOME:-$HOME/.zwift/$USER}
# Set the container image to use
IMAGE=${IMAGE:-docker.io/netbrain/zwift}
# The container version
VERSION=${VERSION:-latest}
# Create the zwift home directory if not already exists
mkdir -p $ZWIFT_HOME
# Check for updated container image
docker pull $IMAGE:$VERSION
# Check for proprietary nvidia driver and set correct device to use
if [[ -f "/proc/driver/nvidia/version" ]]
then
VGA_DEVICE_FLAG="--gpus all"
else
VGA_DEVICE_FLAG="--device /dev/dri:/dev/dri"
fi
# Start the zwift container
CONTAINER=$(docker run \
-d \
--rm \
--privileged \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /run/user/$UID/pulse:/run/user/1000/pulse \
-v $ZWIFT_HOME:/home/user/Zwift \
$VGA_DEVICE_FLAG \
$IMAGE:$VERSION)
# Allow container to connect to X
xhost +local:$(docker inspect --format='{{ .Config.Hostname }}' $CONTAINER)