-
Notifications
You must be signed in to change notification settings - Fork 0
/
spotify
executable file
·51 lines (40 loc) · 1.3 KB
/
spotify
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
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
#
# Run go in a container
#
# This script will attempt to mirror the host paths by using volumes for the
# following paths:
# * $(pwd)
# * $(dirname $GOPATH) if it's set
#
# You can add additional volumes (or any docker run options) using
# the $DOCKER_RUN_OPTIONS environment variable.
#
set -e
VERSION=${VERSION:-"local"}
IMAGE="spotify:$VERSION"
ENTRYPOINT="spotify"
USER=$(id -u)
GROUP=$(getent group audio | cut -d : -f 3)
SWD=$(readlink -f "$0" | xargs dirname)
DOCKERFILE="$SWD/stowage/spotify.dockerfile"
if [ -z $(docker images -q $IMAGE) -o x$1 = 'xbuild' ]; then
shift 1 $@
docker pull $IMAGE ||
docker build -t $IMAGE -f $DOCKERFILE $SWD/stowage
fi
if [ -n "$DBUS_SESSION_BUS_ADDRESS" ]; then
VOLUMES="$VOLUMES -v /run/user/$ID:/run/user/$ID"
ENVS="$ENVS -e DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS"
fi
# Only allocate tty if we detect one
if [ -t 1 ]; then
DOCKER_RUN_OPTIONS="-t"
fi
if [ -t 0 ]; then
DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS -i"
fi
VOLUMES="$VOLUMES -v /etc/passwd:/etc/passwd -v /tmp/.X11-unix:/tmp/.X11-unix -v $HOME:$HOME"
ENVS="$ENVS -e DISPLAY=$DISPLAY"
DEVICES="--device /dev/snd:/dev/snd --device /dev/dri:/dev/dri"
exec docker run --rm -u $USER:$GROUP $DOCKER_RUN_OPTIONS $VOLUMES $ENVS $DEVICES --entrypoint $ENTRYPOINT $IMAGE "$@"