-
Notifications
You must be signed in to change notification settings - Fork 0
/
alias
executable file
·152 lines (138 loc) · 6.61 KB
/
alias
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
#!/usr/local/bin/zsh
rcpath="$HOME/go/src/github.com/vankichi/dotfiles"
zpath="/usr/bin/zsh"
container_name="dev"
image_name="vankichi/dev:latest"
function dockerrm {
docker container stop $(docker container ls -aq)
docker ps -aq | xargs docker rm -f
docker container prune -f
docker images -aq | xargs docker rmi -f
docker image prune -a
docker volume prune -f
docker network prune -f
docker system prune -a
}
alias dockerrm="dockerrm"
alias vmove="cd $rcpath"
alias vbuild="vmove&&docker build --pull=true --file=$rcpath/Dockerfile -t vankichi/dev:latest $rcpath"
function devrun {
port_range="7000-9300"
privileged=true
tz_path="/usr/share/zoneinfo/Japan"
font_dir="/System/Library/Fonts"
docker_daemon="$HOME/Library/Containers/com.docker.helper/Data/.docker/daemon.json"
docker_config="$HOME/Library/Containers/com.docker.helper/Data/.docker/config.json"
docker_sock="/var/run/docker.sock"
container_home="/home/vankichi"
container_root="/root"
container_goroot="$container_home/go"
goroot="/usr/local/go"
case "$(uname -s)" in
Darwin)
echo 'Docker on macOS start'
docker run \
--cap-add=ALL \
--name $container_name \
--restart always \
--privileged=$privileged \
-v /var/run/docker.sock:/var/run/docker.sock \
-p $port_range:$port_range \
-v $HOME/.docker/daemon.json:$container_root/.docker/daemon.json \
-v $HOME/.kube:$container_root/.kube \
-v $HOME/.netrc:$container_root/.netrc \
-v $HOME/.ssh:$container_root/.ssh \
-v $HOME/.gnupg:$container_root/.gnupg \
-v $HOME/Documents:$container_root/Documents \
-v $HOME/Downloads:$container_root/Downloads \
-v $HOME/go/src:/go/src:cached \
-v $docker_config:/etc/docker/config.json:ro,cached \
-v $docker_daemon:/etc/docker/daemon.json:ro,cached \
-v $font_dir:/usr/share/fonts:ro \
-v $rcpath/coc-settings.json:$container_root/.config/nvim/coc-settings.json \
-v $rcpath/editorconfig:$container_root/.editorconfig \
-v $rcpath/gitconfig:$container_root/.gitconfig \
-v $rcpath/gitignore:$container_root/.gitignore \
-v $rcpath/init.vim:$container_root/.config/nvim/init.vim \
-v $rcpath/monokai.vim:$container_root/.config/nvim/colors/monokai.vim \
-v $rcpath/tmux.conf:$container_root/.tmux.conf \
-v $rcpath/zshrc:$container_root/.zshrc \
-v $rcpath/go.env:$container_goroot/go.env:ro \
-v $rcpath/go.env:$goroot/go.env:ro \
-v $HOME/.zsh_history:$container_root/.zsh_history \
-v $tz_path:/etc/localtime:ro \
-v $docker_sock:$docker_sock \
-dit $image_name
;;
Linux)
echo 'Docker on Linux start'
font_dir="/usr/share/fonts"
tz_path="/etc/timezone"
docker_daemon="/etc/docker/daemon.json"
docker_config="/etc/docker/config.json"
docker run \
--cap-add=ALL \
--name $container_name \
--restart always \
--privileged=$privileged \
-p 1313:1313 \
-u "$(id -u $USER):$(id -g $USER)" \
-v $HOME/.docker:$container_home/.docker \
-v $HOME/.docker:$container_root/.docker \
-v $HOME/.gnupg:$container_home/.gnupg \
-v $HOME/.gnupg:$container_root/.gnupg \
-v $HOME/.kube:$container_home/.kube \
-v $HOME/.netrc:$container_home/.netrc:ro \
-v $HOME/.ssh:$container_home/.ssh \
-v $HOME/.zsh_history:$container_home/.zsh_history:cached \
-v $HOME/Documents:$container_home/Documents \
-v $HOME/Downloads:$container_home/Downloads \
-v $HOME/go/src:$container_goroot/src:cached \
-v $docker_config:$docker_config:ro,cached \
-v $docker_daemon:$docker_daemon:ro,cached \
-v $docker_sock:$docker_sock \
-v $font_dir:$font_dir \
-v $rcpath/coc-settings.json:$container_home/.config/nvim/coc-settings.json \
-v $rcpath/editorconfig:$container_home/.editorconfig \
-v $rcpath/efm-lsp-conf.yaml:$container_home/.config/nvim/efm-lsp-conf.yaml \
-v $rcpath/gitattributes:$container_home/.gitattributes \
-v $rcpath/gitconfig:$container_home/.gitconfig \
-v $rcpath/gitignore:$container_home/.gitignore \
-v $rcpath/init.vim:$container_home/.config/nvim/init.vim \
-v $rcpath/monokai.vim:$container_home/.config/nvim/colors/monokai.vim \
-v $rcpath/tmux-kube:$container_home/.tmux-kube \
-v $rcpath/tmux.conf:$container_home/.tmux.conf \
-v $rcpath/go.env:$container_goroot/go.env:ro \
-v $rcpath/go.env:$goroot/go.env:ro \
-v $rcpath/vintrc.yaml:$container_home/.vintrc.yaml \
-v $rcpath/zshrc:$container_home/.zshrc:ro,cached \
-v $tz_path:/etc/localtime:ro,cached \
-dit $image_name
;;
CYGWIN*|MINGW32*|MSYS*)
echo 'MS Windows is not ready for this environment'
;;
*)
echo 'other OS'
;;
esac
# docker exec -d $container_name $zpath nvup
}
alias devrun="devrun"
# alias devin="docker exec -it $container_name $zpath -c \"tmux source-file /home/vankichi/.tmux.conf && tmux -S /tmp/tmux.sock -q has-session && exec tmux -S /tmp/tmux.sock -2 attach-session -d || exec tmux -S /tmp/tmux.sock -2 new-session -n$USER -s$USER@$HOST\""
# alias devin="docker exec -it $container_name $zsh_path -c \"tmux -S /tmp/tmux.sock -q has-session && exec tmux -S /tmp/tmux.sock -2 attach-session -d || exec tmux -S /tmp/tmux.sock -2 new-session -n$USER -s$USER@$HOST\""
alias devin="docker exec -it $container_name $zpath"
function devkill {
docker update --restart=no $container_name \
&& docker container stop $(docker container ls -aq) \
&& docker container stop $(docker ps -a -q) \
&& docker ps -aq | xargs docker rm -f \
&& docker container prune -f
}
alias devkill="devkill"
alias devres="devkill && devrun"
function fup {
sudo systemctl reload dbus.service
sudo systemctl restart fwupd.service
sudo lsusb
}