SHOW:
|
|
- or go back to the newest paste.
1 | #!/bin/sh | |
2 | echo "== Start WSL2 Docker with domains wsl2 and winhost in host file ==" | |
3 | echo "Try to set ip for windows and WSL hosts" | |
4 | export WIN_HOST_IP=$(cat /etc/resolv.conf | grep 'nameserver' | cut -f 2 -d ' ') | |
5 | export WSL_HOST_IP=$(ip addr show eth0 | grep 'inet ' | cut -f 6 -d ' ' | cut -f 1 -d '/') | |
6 | echo "Found windows host ip: $WIN_HOST_IP" | |
7 | echo "Found WSL2 host ip: $WSL_HOST_IP" | |
8 | rm /tmp/hosts | |
9 | if grep "wsl2" /mnt/c/Windows/System32/drivers/etc/hosts | |
10 | then | |
11 | cp /mnt/c/Windows/System32/drivers/etc/hosts /tmp/hosts | |
12 | sed -i "s/.*wsl2/$WSL_HOST_IP wsl2/" /tmp/hosts | |
13 | cat /tmp/hosts > /mnt/c/Windows/System32/drivers/etc/hosts | |
14 | else | |
15 | echo "$WSL_HOST_IP wsl2\n" >> /mnt/c/Windows/System32/drivers/etc/hosts | |
16 | fi | |
17 | rm /tmp/hosts | |
18 | if grep "winhost" /mnt/c/Windows/System32/drivers/etc/hosts | |
19 | then | |
20 | cp /mnt/c/Windows/System32/drivers/etc/hosts /tmp/hosts | |
21 | sed -i "s/.*winhost/$WIN_HOST_IP winhost/" /tmp/hosts | |
22 | cat /tmp/hosts > /mnt/c/Windows/System32/drivers/etc/hosts | |
23 | else | |
24 | echo "$WIN_HOST_IP winhost\n" >> /mnt/c/Windows/System32/drivers/etc/hosts | |
25 | fi | |
26 | #cat /mnt/c/Windows/System32/drivers/etc/hosts | |
27 | echo "done.\n" | |
28 | ||
29 | echo "Start Docker." | |
30 | sudo nohup dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --dns 8.8.8.8 >/dev/null 2>&1 & | |
31 | echo "done.\n" |