-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappdocker
executable file
·77 lines (66 loc) · 2.96 KB
/
appdocker
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
# Run apps inside docker
cachedir=$HOME/.cache/appdocker
olddays=7
declare -A images=(
["acestream"]="munkie/acestreamplayer"
["chrome"]="jess/chrome"
["decktape"]="astefanutti/decktape"
["skype"]="jess/skype"
["spotify"]="yammelvin/spotify-client"
["tor-browser"]="jess/tor-browser"
)
declare -A params=(
["acestream"]="--privileged --rm=true --net=host -v /dev/snd:/dev/snd -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY -e uid=$(id -u) -e gid=$(id -g) --name acestream"
["chrome"]="--privileged -it --rm --net host --cpuset-cpus 0 --memory 512mb -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY -v $HOME/Downloads/Chrome:/home/chrome/Downloads --volume /tmp:/tmp --volume /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket -v /run/user/$UID/pulse/native:/home/chrome/pulseaudio/socket --env PULSE_SERVER=unix:/home/chrome/pulseaudio/socket --device /dev/snd --name=chrome_client"
["decktape"]="--rm=true --net=host -v $PWD:/slides:Z"
["skype"]="--privileged --rm=true --net=host -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY --name skype --volume /tmp:/tmp --volume /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket -v /run/user/$UID/pulse/native:/tmp/pulse/native --env PULSE_SERVER=unix:/tmp/pulse/native -v $HOME/.Skype:/home/skype/.Skype --group-add irc"
["spotify"]="--privileged --name=spotify_client --rm=true --net=host -v /tmp/.X11-unix:/tmp/.X11-unix --env DISPLAY --shm-size=256M --volume $HOME/.spotify:/root --volume /tmp:/tmp --volume /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket -v /run/user/$UID/pulse/native:/root/pulseaudio/socket --env PULSE_SERVER=unix:/root/pulseaudio/socket"
["tor-browser"]="--privileged --rm -v /dev/shm:/dev/shm -v /etc/machine-id:/etc/machine-id:ro -v /tmp/.X11-unix:/tmp/.X11-unix -v $HOME/Downloads/TorBrowser:/usr/local/bin/Browser/Downloads:Z -e DISPLAY=unix$DISPLAY --device /dev/snd --name tor-browser"
)
function usage {
echo "Usage: $(basename $0) [-n] <app> [<parameter>]"
echo " where:"
echo " -n : do not update image"
echo " <app> : one of"
for a in ${!images[@]}; do
echo " $a"
done
echo " <parameter> : optional parameter to pass"
exit 0
}
function update_image {
local cachefile=$cachedir/$1.last
if [ ! -d $cachedir ]; then
mkdir -p $cachedir
fi
if [ ! -f $cachefile ] || [ $(find $cachefile -mtime +$olddays) ]; then
docker pull ${images[$1]}
touch $cachefile
fi
}
if [ $# == 1 ] ; then
app=$1
fi
if [ $# == 2 ] ; then
if [ "$1" == "-n" ] ; then
noupgrade=1
app=$2
else
app=$1
parameter=$2
fi
fi
if [ $# == 3 ] && [ "$1" == "-n" ] ; then
noupgrade=1
app=$2
parameter=$3
fi
if [ -z $app ] || [ -z ${images[$app]} ] ; then
usage
fi
if [ -z $noupgrade ] ; then
update_image $app
fi
xhost local:root
docker run ${params[$app]} ${images[$app]} ${parameter}