-
Notifications
You must be signed in to change notification settings - Fork 5
/
dockerfunc
653 lines (602 loc) · 13.3 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
#!/bin/bash
# bash wrappers for docker run commands
# refs:
# https://github.com/jfrazelle/dotfiles
# https://blog.jessfraz.com/post/docker-containers-on-the-desktop/
#
# container aliases
#
# aircraft communication addressing/reporting system
acarsdec(){
del_stopped acarsdec
docker run -d \
--device=/dev/bus/usb \
--name acarsdec \
mitchtech/rpi-acarsdec -v -g 450 -r 0 130.025 131.550
}
# amazon alexa client
alexapi(){
del_stopped alexapi
docker run -d \
--net host \
-p 5000:5000 \
--device /dev/snd \
--device=/dev/bus/usb \
--name alexapi \
mitchtech/rpi-alexapi
}
# search for files within apt packages
apt_file(){
docker run --rm -it \
--name apt-file \
mitchtech/rpi-apt-file
}
alias apt-file="apt_file"
# adb, fastboot
android-tools(){
docker run --rm -it \
--device=/dev/bus/usb \
--name android-tools \
mitchtech/rpi-android-tools
}
# arduino
arduino(){
del_stopped arduino
xhost +
docker run -d \
--device=/dev/bus/usb \
-e DISPLAY=unix:0 \
-v $PWD:/sketchbook \
-v /tmp/.X11-unix:/tmp/.X11-unix \
--name arduino \
mitchtech/rpi-arduino
}
# beacon bluetooth low energy
# beacon(){}
# cli tool for bladerf sdr
bladerf-cli(){
docker run -it --rm \
--device=/dev/bus/usb \
--name bladerf-cli \
mitchtech/rpi-bladerf bladeRF-cli -i
}
# video and photo webcam capture
cheese(){
del_stopped cheese
docker run -d \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=unix$DISPLAY \
-v $HOME/Pictures:/root/Pictures \
--device /dev/video0 \
--device /dev/snd \
--device /dev/dri \
--name cheese \
mitchtech/rpi-cheese
}
# web browser
# chromium(){}
# movies via nzbs & torrents
couchpotato(){
del_stopped couchpotato
docker run -d \
-v /etc/localtime:/etc/localtime:ro \
-v $HOME/.sonarr:/config \
-v $HOME/Downloads:/downloads \
-v $HOME/movies:/movies \
-p 5050:5050 \
--restart=always \
--name couchpotato \
mitchtech/rpi-couchpotato
}
# ruby-based web dashboard
dashing(){
del_stopped dashing
docker run -d \
-p 3030:3030 \
--name dashing \
mitchtech/rpi-dashing
}
# web interface for docker
dockerui(){
del_stopped dockerui
docker run -d \
-p 9000:9000 \
-v /var/run/docker.sock:/var/run/docker.sock \
--name dockerui \
hypriot/rpi-dockerui
}
# adsb decoder for rtl-sdr
dump1090(){
del_stopped dump1090
docker run -d \
--net host \
-p 8080:8080 \
--device=/dev/bus/usb \
--name dump1090 \
mitchtech/rpi-dump1090 --interactive --net
}
# dns, dhcp, network infrastructure
dnsmasq(){
del_stopped dnsmasq
docker run -d \
-p=53:53/udp
-v .dnsmasq:/dnsmasq \
--name dnsmasq \
mitchtech/rpi-dnsmasq
}
# lightweight web brower
epiphany(){
del_stopped epiphany
xhost +
docker run -d \
--net host \
-e DISPLAY=unix:0 \
-v /tmp/.X11-unix:/tmp/.X11-unix \
--name epiphany \
mitchtech/rpi-epiphany "$@"
# --privileged \
# --restart=on-failure:5 \
}
# command line text-to-speech
festival(){
del_stopped festival
docker run --rm -d \
--name festival \
--device /dev/snd \
mitchtech/rpi-festival \
echo $@ | festival --tts
#"echo" "$@" "|" "festival" "--tts"
}
# lightweight command line text-to-speech
flite(){
del_stopped flite
docker run --rm -d \
--name festival \
--device /dev/snd \
mitchtech/rpi-flite \
flite -t "$@"
}
# real-time adsb aircraft tracking
# flightaware(){}
# frequency show visual spectrum analyzer
freqshow(){
docker run --rm -it \
--privileged \
--device=/dev/bus/usb \
-v /var/run/docker.sock:/var/run/docker.sock \
-e DISPLAY=172.17.42.1:0.0 \
--name freqshow \
mitchtech/rpi-freqshow
}
# google talk (xmpp) bot
# gtalkbot(){}
# node.js-based development environment
google-coder(){
del_stopped google-coder
docker run -d \
-p 8080:8080 \
--name google-coder \
hypriot/rpi-google-coder
}
# gnuradio suite (osmocom, gqrx)
# gnuradio(){}
# gpio pin mode/state acess
# gpio(){
# docker run --rm -it \
# --cap-add SYS_RAWIO \
# --device /dev/mem \
# --name gpio \
# mitchtech/rpi-wiringpi "$@"
# }
# physical gmail notification daemon
# gpio-gmail(){}
# video and photo webcam capture
# guvcview(){}
# wifi access point
# hostapd(){}
# minimal busybox http server
httpd(){
del_stopped httpd
docker run -d \
-p 80:80 \
--name httpd \
mitchtech/rpi-busybox-httpd
}
# debian firefox web brower
iceweasel(){
del_stopped iceweasel
xhost +
docker run -d \
--net host \
-e DISPLAY=unix:0 \
-v /tmp/.X11-unix:/tmp/.X11-unix \
--name iceweasel \
mitchtech/rpi-iceweasel "$@"
# --privileged \
# --restart=on-failure:5 \
}
# voice control platform
# jasper(){}
# gsm base station scanner
# kalibrate(){}
# kitematic docker gui
kitematic(){
del_stopped kitematic
docker run -d \
--privileged \
-v /var/run/docker.sock:/var/run/docker.sock \
-e DISPLAY=172.17.42.1:0.0 \
--name kitematic \
mitchtech/rpi-kitematic
}
# kivy graphic info screen
kivy-infoscreen(){
del_stopped kivy-infoscreen
docker run -d \
--privileged \
-e DISPLAY=172.17.42.1:0.0 \
--name kivy-infoscreen \
mitchtech/rpi-kivy-infoscreen
}
# documents, spreadsheets, and slides
libreoffice(){
xhost +
del_stopped libreoffice
docker run -d \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=unix$DISPLAY \
-v $HOME/slides:/root/slides \
--name libreoffice \
mitchtech/rpi-libreoffice
# -e GDK_SCALE \
# -e GDK_DPI_SCALE \
}
# text-based web browser
lynx(){
docker run --rm -it \
--name lynx \
mitchtech/rpi-lynx "$@"
}
# lightweight web brower
midori(){
del_stopped midori
xhost +
docker run -d \
--net host \
-e DISPLAY=unix:0 \
-v /tmp/.X11-unix:/tmp/.X11-unix \
--name midori \
mitchtech/rpi-midori "$@"
# --privileged \
# --restart=on-failure:5 \
}
# modulation/demodulation over rf
# minimodem(){}
# webcam and motion detection server
motion(){
del_stopped motion
docker run -d \
--device=/dev/video0 \
-v $PWD/motion.conf:/etc/motion/motion.conf \
-p 8080:8080 \
-p 8081:8081 \
--name motion \
mitchtech/rpi-motion
# --privileged \
# -v ./motion:/var/lib/motion \
}
# digital transmission decoder/demodulator
# multimon-ng(){}
# text-based audio player
mpg123(){
docker run --rm -it \
--privileged \
--device /dev/snd \
-v $PWD/audio.mp3:/audio.mp3 \
-v $PWD:/audio \
--name mpg123 \
mitchtech/rpi-mpg123
}
# adafruit neopixel leds
neopixel(){
del_stopped neopixel
docker run -d \
--cap-add SYS_RAWIO \
--device /dev/mem \
--name neopixel \
mitchtech/rpi-neopixel
}
# nintendo emulator
# nes(){}
# read and write tcp/ip connections
netcat(){
docker run --rm -it \
--net host \
mitchtech/rpi-netcat "$@"
}
# web and reverse proxy server
nginx(){
del_stopped nginx
docker run -d \
--restart always \
-v $HOME/.nginx:/etc/nginx \
--net host \
--name nginx \
mitchtech/rpi-nginx
}
# network map port scanner
nmap(){
docker run --rm -it \
--net host \
mitchtech/rpi-nmap "$@"
}
# pdf viewer and presentation tool
okular(){
del_stopped okular
xhost +
docker run -d \
-e DISPLAY=unix:0 \
-v /tmp/.X11-unix:/tmp/.X11-unix \
--name okular \
mitchtech/rpi-okular "$@"
# --privileged \
}
# smartphone test farm
# openstf(){}
# computer vision
# opencv(){}
# text-based pandora music
pianobar(){
docker run --rm -it \
--privileged \
--net host \
--device /dev/snd \
--name pianobar \
mitchtech/rpi-pianobar
}
# fm radio transmit pifm(sound_file, frequency)
pifm(){
del_stopped pifm
local sound_file=$1
local frequency=$2
docker run -d \
--cap-add SYS_RAWIO \
--device /dev/mem \
--name pifm \
mitchtech/rpi-pifm ${sound_file} ${frequency}
}
# fm radio playlist broadcast
pirate-radio(){
del_stopped pirate-radio
docker run -d \
--cap-add SYS_RAWIO \
--device /dev/mem \
-v $PWD/pirateradio.conf:/pirateradio/pirateradio.conf \
-v $PWD:/pirateradio \
--name pirate-radio \
mitchtech/rpi-pirate-radio
}
# private web proxy
# privoxy(){}
# audio server and proxy
# pulseaudio(){}
# real-time database engine
rethinkdb(){
del_stopped rethinkdb
docker run -d \
-p 8081:8081 \
-p 28015:28015 \
-p 29015:29015 \
-v $PWD:/data \
--name rethinkdb \
mitchtech/rpi-rethinkdb
}
# radio transmitter for am, fm, ssb, sstv, fsq, vfo
rpitx(){
del_stopped rpitx
local sound_file=$1
local frequency=$2
docker run -d \
--cap-add SYS_RAWIO \
--device /dev/mem \
--name rpitx \
mitchtech/rpi-rpitx ${sound_file} ${frequency}
}
# rtl-sdr ais boat/ship tracking
rtl-ais(){
del_stopped rtl-ais
docker run -d \
--device=/dev/bus/usb \
--name rtl-ais \
mitchtech/rpi-rtl-ais
}
# usenet binary downloader
sabnzbd(){
del_stopped sabnzbd
docker run -d \
-v /etc/localtime:/etc/localtime:ro \
-v $HOME/.sabnzbd:/config \
-v $HOME/Downloads:/data \
-p 8080:8080 \
--restart=always \
--name sabnzbd \
mitchtech/rpi-sabnzbd
}
# pvr for usenet and bittorrent
sickbeard(){
del_stopped sickbeard
docker run -d \
-v /etc/localtime:/etc/localtime:ro \
-v $HOME/.sickbeard:/config \
-v $HOME/Downloads:/data/downloads \
-v $HOME/.nzb:/data/nzb \
-v $HOME/.torrents:/data/torrents \
-p 8081:8081 \
--restart=always \
--name sickbeard \
mitchtech/rpi-sickbeard
}
# pvr for usenet and bittorrent
sonarr(){
del_stopped sonarr
docker run -d \
-v /etc/localtime:/etc/localtime:ro \
-v $HOME/.sonarr:/config \
-v $HOME/Downloads:/downloads \
-v $HOME/TV:/tv \
-p 8080:8080 \
--name sonarr \
mitchtech/rpi-sonarr
}
# mouse and keyboard sharing
# synergy
# python-based web dashboard
tipboard(){
del_stopped tipboard
docker run -d \
-p 7272:7272 \
--name=tipboard \
mitchtech/rpi-tipboard
# -v $PWD/settings-local.py:/root/.tipboard/settings-local.py \
# -v $PWD/layout_config.yaml:/root/.tipboard/layout_config.yaml \
}
# the onion router
# tor(){}
# web browser for tor
# torbrowser(){}
# instant messenger client for tor
# tormessenger(){}
# proxy on top of tor
# torproxy(){}
# bittorrent client
transmission(){
del_stopped transmission
docker run -d \
-v /etc/localtime:/etc/localtime:ro \
-v $HOME/.transmission:/config \
-v $HOME/Downloads:/downloads \
-p 9091:9091 \
-p 51413:51413 \
-p 51413:51413/udp \
--name transmission \
mitchtech/rpi-transmission
# -v $HOME/Torrents:/transmission/download \
# -v $HOME/.transmission:/transmission/config \
# transmission -v pass -u user
}
# android test automation
uiautomator(){
del_stopped uiautomator
docker run -d \
--privileged \
-p 2222:2222 \
-v /dev/bus/usb:/dev/bus/usb \
-v /etc/localtime:/etc/localtime:ro \
--name uiautomator \
mitchtech/uiautomator
}
# android test automation x windows
uiautomatorx(){
del_stopped uiautomator
docker run -d \
--privileged \
-p 2222:2222 \
-e DISPLAY=$DISPLAY \
-v /dev/bus/usb:/dev/bus/usb \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /etc/localtime:/etc/localtime:ro \
--name uiautomator \
mitchtech/uiautomator
}
# remote access and control
# vnc(){}
# web browser-based development environment
# webide(){}
# gpio, wiringpi, pyserial
wiringpi(){
docker run --rm -it \
--cap-add SYS_RAWIO \
--device /dev/mem \
--name wiringpi \
mitchtech/rpi-wiringpi
}
# x11-apps demo for basic docker x11 setup
xeyes(){
del_stopped xeyes
docker run -d \
--privileged \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
--name xeyes \
mitchtech/x11-apps
}
# sdr base transciever station
yatebts(){
docker run -it --rm \
--privileged \
--device=/dev/bus/usb \
--net host \
-v $PWD/ybts.conf:/usr/local/etc/yate/ybts.conf \
-v $PWD/subscribers.conf:/usr/local/etc/yate/subscribers.conf \
--name yatebts \
mitchtech/rpi-bladerf-yatebts
}
#
# support aliases
#
# kill all running containers
alias docker-killall='docker kill $(docker ps -q)'
# delete all stopped containers
alias docker-cleanc='printf "\n>>> Deleting stopped containers\n\n" && docker rm $(docker ps -a -q)'
# delete all untagged images
alias docker-cleani='printf "\n>>> Deleting untagged images\n\n" && docker rmi $(docker images -q -f dangling=true)'
# delete dangling volumes
alias docker-cleanv='printf "\n>>> Deleting dangling volumes\n\n" && docker volume rm $(docker volume ls -qf dangling=true)'
# delete stopped containers, untagged images
alias docker-cleanall='dockercleanc || true && dockercleani || true && dockercleanv'
# removes dangling and exited docker containers
dcleanup(){
docker rm -v $(docker ps --filter status=exited -q 2>/dev/null) 2>/dev/null
docker rmi $(docker images --filter dangling=true -q 2>/dev/null) 2>/dev/null
}
# delete stopped container
del_stopped(){
local name=$1
local state=$(docker inspect --format "{{.State.Running}}" $name 2>/dev/null)
if [[ "$state" == "false" ]]; then
docker rm $name
fi
}
# dependency on another running container
relies_on(){
local containers=$@
for container in $containers; do
local 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
}
# enter a running container
enter() {
local name=${1:?}
docker exec -it $name sh -c 'exec $(command -v bash || command -v sh)'
}
# helper to identify running containers
__enter() {
local cur=${COMP_WORDS[COMP_CWORD]}
for cid in $(docker ps -q)
do
local name=$(docker inspect -f '{{.Name}}' $cid)
name=${name#/}
if [[ $name = $cur* ]]
then
COMPREPLY+=("$name")
fi
done
}
# tab completion for entering running containers
complete -F __enter enter