forked from wernight/docker-mopidy
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun
executable file
·40 lines (32 loc) · 1.17 KB
/
run
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
#!/bin/bash
#
# ~ start a mopidy container using sane defaults.
#
set -eo pipefail
: ${name:='mopidy'}
: ${image:='trevorj/mopidy-extras:develop'} # remove :develop for stable (:latest)
: ${media_dir:="$(xdg-user-dir MUSIC)"}
: ${data_dir:="$(xdg-user-dir DATA)/mopidy"}
: ${config_dir:="$(xdg-user-dir CONFIG)/mopidy"}
: ${pulse_cookie_data:="$(DISPLAY="${DISPLAY:-:0.0}" pax11publish -d | grep -Po '(?<=^Cookie: ).*')"}
#: ${pulse_server:='tcp:0.0.0.0:4713'}
args=()
[[ -z "$pulse_cookie_data" ]] || args+=(-e PULSE_COOKIE_DATA="$pulse_cookie_data")
[[ -z "$pulse_server" ]] || args+=(-e PULSE_SERVER="$pulse_server")
[[ -z "$media_dir" ]] || args+=(-v "$media_dir:$app_home/Music")
[[ -z "$data_dir" ]] || args+=(-v "$data_dir:$app_home/.local/share/mopidy")
[[ -z "$config_dir" ]] || args+=(-v "$config_dir:$app_home/.config/mopidy")
# pull image first to minimize downtime.
$dry docker pull "$image"
# stop and remove any existing.
for i in stop rm; do $dry docker $i "$name" || :; done
# run container
$dry docker run -d \
--name="$name" \
--hostname="$HOST" \
--net=host \
-e DEBUG \
-e TRACE \
"${args[@]}" \
"$image" \
"$@"