-
Notifications
You must be signed in to change notification settings - Fork 3
/
.dockerfunc
93 lines (82 loc) · 2.17 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
#!/bin/bash
# Bash wrappers for docker run commands (shamelessly copied from jess/dotfiles, some have been modified)
#
# Helper Functions
#
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
}
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
}
# torproxy
torproxy(){
del_stopped torproxy
docker run -d \
--restart always \
-v /etc/localtime:/etc/localtime:ro \
-p 9050:9050 \
--name torproxy \
jess/tor-proxy
#sudo hostess add torproxy $(docker inspect --format "{{.NetworkSettings.Networks.bridge.IPAddress}}" torproxy)
}
privoxy(){
del_stopped privoxy
relies_on torproxy
docker run -d \
--restart always \
--link torproxy:torproxy \
-v /etc/localtime:/etc/localtime:ro \
-p 8118:8118 \
--name privoxy \
jess/privoxy
#sudo hostess add privoxy $(docker inspect --format "{{.NetworkSettings.Networks.bridge.IPAddress}}" privoxy)
}
rygel(){
local musicpath="$HOME/Music"
local videopath="$HOME/Videos"
local picspath="$HOME/Pictures"
local OPTIND m v p o
while getopts ":m:v:p:" o; do
case $o in
m)
musicpath=$OPTARG
;;
v)
videopath=$OPTARG
;;
p)
picspath=$OPTARG
;;
esac
done
shift $((OPTIND-1))
# echo "videopath set is $videopath."
# echo "picspath set is $picspath."
# echo "musicpath set is $musicpath."
del_stopped rygel
docker run \
-it \
--rm \
--net=host \
-v $musicpath:/music \
-v $videopath:/videos \
-v $picspath:/pictures \
--name rygel \
sameersbn/rygel:latest
}