-
Notifications
You must be signed in to change notification settings - Fork 0
/
.dockerfunc
207 lines (192 loc) · 4.87 KB
/
.dockerfunc
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/bin/bash
# Bash wrappers for docker run commands
export DOCKER_REPO_PREFIX=julianvmodesto
#
# Helper Functions
#
del_stopped(){
local name=$1
local state
state=$(docker inspect --format "{{.State.Running}}" "$name" 2>/dev/null)
if [[ "$state" == "false" ]]; then
docker rm "$name"
fi
}
relies_on(){
for container in "$@"; do
local state
state=$(docker inspect --format "{{.State.Running}}" "$container" 2>/dev/null)
if [[ "$state" == "false" ]] || [[ "$state" == "" ]]; then
echo "$container is not running, starting it for you."
$container
fi
done
}
#
# Container Aliases
#
chrome(){
# add flags for proxy if passed
local proxy=
local map
local args=$*
if [[ "$1" == "tor" ]]; then
relies_on torproxy
map="MAP * ~NOTFOUND , EXCLUDE torproxy"
proxy="socks5://torproxy:9050"
args="https://check.torproject.org/api/ip ${*:2}"
fi
del_stopped chrome
# one day remove /etc/hosts bind mount when effing
# overlay support inotify, such bullshit
docker run -d \
--memory 3gb \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e "DISPLAY=unix${DISPLAY}" \
-v "${HOME}/Downloads:/home/chrome/Downloads" \
-v "${HOME}/Pictures:/home/chrome/Pictures" \
-v "${HOME}/Torrents:/home/chrome/Torrents" \
-v "${HOME}/.chrome:/data" \
-e GDK_SCALE \
-e GDK_DPI_SCALE \
--shm-size 2gb \
-v /etc/hosts:/etc/hosts \
--security-opt seccomp:/etc/docker/seccomp/chrome.json \
--device /dev/snd \
--device /dev/dri \
--device /dev/bus/usb \
--group-add audio \
--group-add video \
--name chrome \
${DOCKER_REPO_PREFIX}/chrome --user-data-dir=/data \
--proxy-server="$proxy" \
--host-resolver-rules="$map" "$args"
}
firefox(){
del_stopped firefox
relies_on pulseaudio
docker run -d \
--shm-size 2gb \
--net host \
--ipc="host" \
--cpuset-cpus 0 \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v "${HOME}/.firefox/cache:/root/.cache/mozilla" \
-v "${HOME}/.firefox/mozilla:/root/.mozilla" \
-v "${HOME}/Downloads:/root/Downloads" \
-v "${HOME}/Pictures:/root/Pictures" \
-v "${HOME}/Torrents:/root/Torrents" \
-e "DISPLAY=unix${DISPLAY}" \
-e "PULSE_SERVER=localhost" \
-e GDK_SCALE \
-e GDK_DPI_SCALE \
--device /dev/snd \
--device /dev/dri \
--device /dev/bus/usb \
--group-add audio \
--group-add video \
--name firefox \
${DOCKER_REPO_PREFIX}/firefox "$@"
}
htop(){
docker run --rm -it \
--pid host \
--net none \
--name htop \
${DOCKER_REPO_PREFIX}/htop
}
landscape(){
docker run -i --rm \
--name landscape \
${DOCKER_REPO_PREFIX}/landscape "$@"
}
mycli(){
docker run --rm -it \
${DOCKER_REPO_PREFIX}/mycli "$@"
}
notify_osd(){
del_stopped notify_osd
docker run -d \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
--net none \
-v /etc \
-v /home/user/.dbus \
-v /home/user/.cache/dconf \
-e "DISPLAY=unix${DISPLAY}" \
--name notify_osd \
${DOCKER_REPO_PREFIX}/notify-osd
}
notify-send(){
relies_on notify_osd
local args=${*:2}
docker exec -i notify_osd notify-send "$1" "${args}"
}
export -f notify-send
pgcli(){
docker run --rm -it \
${DOCKER_REPO_PREFIX}/pgcli "$@"
}
pulseaudio(){
del_stopped pulseaudio
docker run -d \
-v /etc/localtime:/etc/localtime:ro \
-v "${DBUS_SESSION_BUS_ADDRESS}:/var/run/dbus/system_bus_socket" \
--device /dev/snd \
-p 4713:4713 \
--restart always \
--group-add audio \
--name pulseaudio \
${DOCKER_REPO_PREFIX}/pulseaudio
}
slack(){
del_stopped slack
docker run -d \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e "DISPLAY=unix${DISPLAY}" \
-e GDK_SCALE \
-e GDK_DPI_SCALE \
-v "${HOME}/Downloads:/root/Downloads" \
--memory 2gb \
--device /dev/snd \
--device /dev/dri \
--group-add audio \
--group-add video \
-v "${HOME}/.slack:/root/.config/Slack" \
--ipc="host" \
--name slack \
${DOCKER_REPO_PREFIX}/slack "$@"
}
synergys(){
del_stopped synergys
docker run -d \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v "${HOME}/.synergy.conf:/config/synergy.conf" \
-v "${HOME}/.synergy:/root/.synergy" \
-e "DISPLAY=unix${DISPLAY}" \
-p 24800:24800 \
--restart always \
--name synergys \
${DOCKER_REPO_PREFIX}/synergy \
build/bin/synergys \
-f --address 0.0.0.0:24800 --debug INFO --no-tray --name synergys --enable-crypto -c /config/synergy.conf
}
traceroute(){
docker run --rm -it \
--net host \
${DOCKER_REPO_PREFIX}/traceroute "$@"
}
zeal() {
del_stopped zeal
docker run -d \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e "DISPLAY=unix${DISPLAY}" \
--device /dev/dri \
--name=zeal \
${DOCKER_REPO_PREFIX}/zeal
# exit current shell
exit 0
}