352 lines
9.1 KiB
Bash
Executable File
352 lines
9.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Bash wrappers for docker run commands
|
|
# inspired by https://github.com/jfrazelle/dotfiles/ <3
|
|
|
|
#
|
|
# Helper Functions
|
|
#
|
|
dcleanup() {
|
|
|
|
# TODO: add list of non-disposable containers (eclipse, intelliJ, ...?)
|
|
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
|
|
}
|
|
|
|
del_stopped() {
|
|
local name=$1
|
|
local state=$(docker inspect --format "{{.State.Running}}" $name 2>/dev/null)
|
|
|
|
if [[ "$state" == "false" ]]; then
|
|
docker rm $name
|
|
fi
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
# Applications...
|
|
|
|
android-studio() {
|
|
|
|
ANDROID_DIR="/home/fschl/projects/android"
|
|
# for dir in .studio-home .gradle .idea .android/avd; do
|
|
# mkdir -p $ANDROID_DIR/.docker-dev/$dir
|
|
# done
|
|
|
|
# TODO: mount /home/developer/android-sdk-linux
|
|
# docker start android-studio
|
|
|
|
## You don't want to remove the container between uses, because many things installed
|
|
## via the _Android Studio GUI_ are only stored in the container.
|
|
# del_stopped android-studio
|
|
docker run -it \
|
|
--net=host \
|
|
--name android-studio \
|
|
--privileged \
|
|
-e DISPLAY \
|
|
-e SHELL=/bin/bash \
|
|
-e GRADLE_USER_HOME='/workspace/.docker-dev/.gradle/home' \
|
|
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
|
-v /dev/bus/usb:/dev/bus/usb \
|
|
-v $ANDROID_DIR/projects:/home/developer/AndroidStudioProjects \
|
|
-v $ANDROID_DIR:/workspace \
|
|
-v $ANDROID_DIR/.docker-dev/.studio-home:/home/developer/.AndroidStudio1.2 \
|
|
-v $ANDROID_DIR/.docker-dev/.android/avd:/home/developer/.android/avd \
|
|
fschl/android-studio:latest \
|
|
/bin/studio
|
|
|
|
#exit 0;
|
|
}
|
|
|
|
bro() {
|
|
docker run -it --rm \
|
|
fschl/bropages \
|
|
bro "$@"
|
|
}
|
|
|
|
chrome() {
|
|
# add flags for proxy if passed
|
|
local proxy=
|
|
local map=
|
|
local args=$@
|
|
|
|
del_stopped chrome
|
|
|
|
# one day remove /etc/hosts bind mount when effing
|
|
# overlay support inotify, such bullshit
|
|
# --memory 2gb \
|
|
docker run -d \
|
|
--net host \
|
|
-v /etc/localtime:/etc/localtime:ro \
|
|
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
|
-e DISPLAY=unix$DISPLAY \
|
|
-v $HOME/Downloads:/root/Downloads \
|
|
-v $HOME/Pictures:/root/Pictures \
|
|
-v $HOME/Torrents:/root/Torrents \
|
|
-v $HOME/.chrome:/data \
|
|
-v /dev/shm:/dev/shm \
|
|
-v /etc/hosts:/etc/hosts \
|
|
--device /dev/snd \
|
|
--device /dev/dri \
|
|
--device /dev/video0 \
|
|
--group-add audio \
|
|
--group-add video \
|
|
--name="chrome" \
|
|
fschl/chrome:latest --user-data-dir=/data
|
|
#--force-device-scale-factor=1 \
|
|
#--proxy-server="$proxy" --host-resolver-rules="$map" "$args"
|
|
}
|
|
|
|
eclipse() {
|
|
del_stopped eclipse
|
|
|
|
docker run -d \
|
|
--net host \
|
|
--name="eclipse" \
|
|
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
|
-e DISPLAY=unix$DISPLAY \
|
|
-v $HOME/projects/java/workspace:/home/eclipse/workspace \
|
|
-v $HOME/.eclipse/plugins:/opt/eclipse/plugins \
|
|
-v $HOME/.eclipse/configuration:/opt/eclipse/configuration \
|
|
-v $HOME/.sonar:/home/eclipse/.sonar \
|
|
fschl/eclipse:latest
|
|
|
|
exit 0;
|
|
}
|
|
|
|
gimp() {
|
|
del_stopped gimp
|
|
|
|
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 \
|
|
-v $HOME/Documents:/root/Documents \
|
|
--name gimp \
|
|
fschl/gimp
|
|
|
|
exit 0;
|
|
}
|
|
|
|
go() {
|
|
docker run -i --rm \
|
|
-v "$PWD":/usr/src/myapp \
|
|
-w /usr/src/myapp \
|
|
fschl/golang-dev:latest go "$@"
|
|
}
|
|
|
|
|
|
icedove() {
|
|
del_stopped icedove
|
|
|
|
docker run -d \
|
|
--name="icedove" \
|
|
-v /etc/localtime:/etc/localtime:ro \
|
|
-v $HOME/Downloads/:/root/Downloads \
|
|
-v $HOME/.thunderbird/:/root/.icedove \
|
|
-v $HOME/.gnupg/:/root/.gnupg \
|
|
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
|
-e DISPLAY=unix$DISPLAY \
|
|
fschl/icedove:latest
|
|
|
|
exit 0;
|
|
}
|
|
|
|
inkscape() {
|
|
del_stopped inkscape
|
|
|
|
# -v $HOME/.Xauthority:/home/inkscaper/.Xauthority \
|
|
|
|
docker run --rm \
|
|
--name="inkscape" \
|
|
-v $HOME/Pictures:/home/inkscaper/Pictures \
|
|
-v $HOME/Documents:/home/inkscaper/Documents \
|
|
-u inkscaper \
|
|
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
|
-e DISPLAY=unix$DISPLAY \
|
|
--net=host \
|
|
fschl/inkscape:latest
|
|
|
|
exit 0;
|
|
}
|
|
|
|
latex() {
|
|
del_stopped latex
|
|
|
|
docker run -it --rm \
|
|
--net host \
|
|
-v $(pwd):/usr/src/latex \
|
|
--workdir="/usr/src/latex" \
|
|
fschl/latex "$@"
|
|
}
|
|
|
|
libreoffice() {
|
|
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/Documents:/root/Documents \
|
|
-v $HOME/Pictures:/root/Pictures \
|
|
-e GDK_SCALE \
|
|
-e GDK_DPI_SCALE \
|
|
--name libreoffice \
|
|
fschl/libreoffice
|
|
}
|
|
|
|
# start from a directory which contains a openvpn config file named 'config.ovpn'
|
|
# cert and key files should be in the same directory or relatively referencable
|
|
# from the config file
|
|
openvpn() {
|
|
del_stopped openvpn
|
|
|
|
docker run -it --rm \
|
|
--name="openvpn" \
|
|
--net host \
|
|
--device /dev/net/tun:/dev/net/tun \
|
|
--cap-add NET_ADMIN \
|
|
-v "$PWD":/etc/openvpn \
|
|
fschl/openvpn:latest config.ovpn
|
|
}
|
|
|
|
|
|
pulseaudio() {
|
|
del_stopped pulseaudio
|
|
|
|
docker run -d \
|
|
-v /etc/localtime:/etc/localtime:ro \
|
|
--device /dev/snd \
|
|
-p 4713:4713 \
|
|
--restart always \
|
|
--name pulseaudio \
|
|
fschl/pulseaudio
|
|
}
|
|
|
|
# pulseaudio() {
|
|
# del_stopped pulseaudio
|
|
|
|
# docker run -d \
|
|
# -v /etc/localtime:/etc/localtime:ro \
|
|
# --device /dev/snd \
|
|
# -p 4713:4713 \
|
|
# --restart always \
|
|
# -v /var/run/dbus:/var/run/dbus \
|
|
# -v /etc/machine-id:/etc/machine-id \
|
|
# --name pulseaudio \
|
|
# fschl/pulseaudio
|
|
# }
|
|
|
|
rstudio(){
|
|
del_stopped rstudio
|
|
|
|
# -e QT_DEVICE_PIXEL_RATIO \
|
|
|
|
docker run -d \
|
|
-v /etc/localtime:/etc/localtime:ro \
|
|
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
|
-v $HOME/fastly-logs:/root/fastly-logs \
|
|
-v /dev/shm:/dev/shm \
|
|
-p 8787 \
|
|
-e DISPLAY=unix$DISPLAY \
|
|
--device /dev/dri \
|
|
--name rstudio \
|
|
rocker/rstudio
|
|
}
|
|
|
|
scenebuilder() {
|
|
del_stopped scenebuilder
|
|
|
|
docker run -it \
|
|
--net host \
|
|
--name="scenebuilder" \
|
|
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
|
-e DISPLAY=unix$DISPLAY \
|
|
-v $HOME/projects/java/workspace:/home/eclipse/workspace \
|
|
fschl/scenebuilder:latest "$@"
|
|
|
|
exit 0;
|
|
}
|
|
|
|
skype() {
|
|
del_stopped skype
|
|
|
|
docker run -d \
|
|
-v $HOME/Downloads:/root/skype/Downloads \
|
|
-v /run/user/1000/pulse:/run/user/1000/pulse \
|
|
-v /var/lib/dbus:/var/lib/dbus \
|
|
-v ~/.pulse:/root/.pulse \
|
|
-v /etc/localtime:/etc/localtime:ro \
|
|
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
|
-e DISPLAY=unix$DISPLAY \
|
|
--device /dev/video0 \
|
|
--device /dev/snd \
|
|
--name skype \
|
|
--net host \
|
|
fschl/skype
|
|
}
|
|
|
|
torbrowser() {
|
|
del_stopped torbrowser
|
|
|
|
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 \
|
|
--device /dev/snd \
|
|
--name torbrowser \
|
|
fschl/tor-browser
|
|
|
|
# exit current shell
|
|
exit 0
|
|
}
|
|
|
|
|
|
transmission() {
|
|
del_stopped transmission
|
|
|
|
docker run -d \
|
|
-v /etc/localtime:/etc/localtime:ro \
|
|
-v $HOME/Downloads:/transmission/download \
|
|
-v $HOME/.transmission:/transmission/config \
|
|
-p 9091:9091 \
|
|
-p 51413:51413 \
|
|
-p 51413:51413/udp \
|
|
--name transmission \
|
|
fschl/transmission
|
|
}
|
|
|
|
vlc() {
|
|
del_stopped vlc
|
|
|
|
local args=$@
|
|
|
|
docker run -it \
|
|
-v "$args":/home/vlc \
|
|
-v /etc/localtime:/etc/localtime:ro \
|
|
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
|
-v /run/user/1000/pulse:/run/user/vlc/pulse \
|
|
-v /var/lib/dbus:/var/lib/dbus \
|
|
-v ~/.pulse:/root/.pulse \
|
|
-e DISPLAY=unix$DISPLAY \
|
|
-e GDK_SCALE \
|
|
-e GDK_DPI_SCALE \
|
|
--device /dev/snd \
|
|
--name vlc \
|
|
fschl/vlc
|
|
}
|