Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
brb committed Aug 2, 2016
1 parent 377b17f commit c9b668a
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions weave
Expand Up @@ -139,16 +139,12 @@ cni_volume_options() {
[ "$1" = "setup" -o "$1" = "setup-cni" ] && echo -v /etc/cni:/etc/cni -v /opt/cni:/opt/cni
}

launch_router_options() {
[ "$1" = "launch" -o "$1" = "launch-router" ] && echo -v /:/host -e HOST_ROOT=/host
}

exec_remote() {
docker $DOCKER_CLIENT_ARGS run --rm \
$(docker_run_options) \
--pid=host \
$(cni_volume_options "$@") \
$(launch_router_options "$@") \
-v /:/host \
-e DOCKERHUB_USER="$DOCKERHUB_USER" \
-e WEAVE_VERSION \
-e WEAVE_DEBUG \
Expand All @@ -170,7 +166,7 @@ exec_remote() {
-e COVERAGE \
-e CHECKPOINT_DISABLE \
-e AWSVPC \
-e MACHINE_ID="$MACHINE_ID" \
-e HOST_ROOT="/host" \
$WEAVEEXEC_DOCKER_ARGS $EXEC_IMAGE --local "$@"
}

Expand Down Expand Up @@ -320,13 +316,6 @@ elif [ "$1" = "run" -a -z "$IS_LOCAL" ] ; then
exit 0
fi

machineid() {
[ -e "/etc/machine-id" ] && cat "/etc/machine-id" && return 0 || true
[ -e "/var/lib/dbus/machine-id" ] && cat "/var/lib/dbus/machine-id" && return 0 || true
}

[ -n "$IS_LOCAL" ] || MACHINE_ID=$(machineid)

if [ -z "$IS_LOCAL" ] ; then
exec_remote "$@"
exit $?
Expand Down Expand Up @@ -471,6 +460,11 @@ random_mac() {
od -txC -An -N6 /dev/urandom | mac_from_hex
}

machineid() {
[ -e "$HOST_ROOT/etc/machine-id" ] && cat "$HOST_ROOT/etc/machine-id" 2>/dev/null && return 0 || true
[ -e "$HOST_ROOT/var/lib/dbus/machine-id" ] && cat "$HOST_ROOT/var/lib/dbus/machine-id" 2>/dev/null && return 0 || true
}

######################################################################
# weave and docker specific helpers
######################################################################
Expand Down Expand Up @@ -709,7 +703,7 @@ init_bridge() {
# Elsewhere we in turn derive the peer name from the bridge MAC, which we
# want to be stable across reboots but otherwise unique.

local uid="$MACHINE_ID"
uid="$(machineid)"
uid="$uid#$(cat /sys/class/dmi/id/product_uuid 2>/dev/null || echo '')"
uid="$uid#$(cat /sys/hypervisor/uuid 2>/dev/null || echo '')"
[ "$uid" != "##" ] && MAC=$(mac_from_uid "$uid") || MAC=$(random_mac)
Expand Down

0 comments on commit c9b668a

Please sign in to comment.