-
Notifications
You must be signed in to change notification settings - Fork 3
/
b2d-functions
49 lines (39 loc) · 1.33 KB
/
b2d-functions
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
: <<USAGE
###############################################
curl -Lso /tmp/b2d-functions https://raw.githubusercontent.com/lalyos/bash-functions/master/b2d-functions && . /tmp/b2d-functions
###############################################
USAGE
: ${DEBUG:=1}
debug() {
[ $DEBUG -gt 0 ] && echo [DEBUG] "$@" 1>&2
}
b2d() {
unalias docker
$(boot2docker shellinit)
}
b2d-reload() {
source ${BASH_SOURCE[0]}
}
alias r=b2d-reload
b2d-fix-dns() {
boot2docker ssh "sudo sh -c 'sed -i \"/UseDNS/ s/.*/UseDNS no/ \" /var/lib/boot2docker/ssh/sshd_config ' "
boot2docker ssh "sudo sh -c '/bin/cat > /etc/resolv.conf' " <<< "$(cat /etc/resolv.conf | grep nameserver)"
boot2docker ssh "sudo ip route flush cache"
boot2docker ssh "sudo /bin/sh -c 'sudo killall -9 docker ; /etc/init.d/docker restart'"
}
b2d-fix-date() {
boot2docker ssh sudo date --set \'$(date -u +%Y-%m-%d\ %H:%M)\'
}
b2d-route() {
B2D_IP=$(boot2docker ip 2>/dev/null)
BRIDGE_IP=$(boot2docker ssh 'ifconfig docker0|sed -n "// s/ *inet addr:\([0-9\.]*\) .*/\1/p"' 2>/dev/null)
if (route -n get $BRIDGE_IP|grep $B2D_IP) &> /dev/null ; then
debug routing ok you reach the bridge: $BRIDGE_IP directly
else
debug adding direct route to bridge: $BRIDGE_IP
sudo route add $BRIDGE_IP/16 $B2D_IP
fi
}
b2d-disk-usage() {
boot2docker ssh 'df -h|grep /dev/sda1'
}