Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Make gateway configurable via arg in add-route script #378

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions bin/add-route
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
#!/bin/bash

set -x
#!/bin/bash -ex

old_ips="10.244.0.0/19"
ips="10.244.0.0/16"
gw="192.168.50.4"
gw="${1:-"192.168.50.4"}"

echo "Adding the following route entry to your local route table to enable direct container access: $ips via $gw. Your sudo password may be required." > /dev/null

if [ `uname` = "Darwin" ]; then
sudo route delete -net $old_ips $gw
sudo route delete -net $ips $gw
sudo route add -net $ips $gw
elif [ `uname` = "Linux" ]; then
if [ "$(uname)" = "Darwin" ]; then
sudo route delete -net "$old_ips" "$gw"
sudo route delete -net "$ips" "$gw"
sudo route add -net "$ips" "$gw"
elif [ "$(uname)" = "Linux" ]; then
if type route > /dev/null 2>&1; then
sudo route del -net $old_ips gw $gw
sudo route add -net $ips gw $gw
sudo route del -net "$old_ips" gw "$gw"
sudo route add -net "$ips" gw "$gw"
elif type ip > /dev/null 2>&1; then
sudo ip route del $old_ips via $gw
sudo ip route add $ips via $gw
sudo ip route del "$old_ips" via "$gw"
sudo ip route add "$ips" via "$gw"
else
echo "ERROR adding route"
exit 1
Expand Down