aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2023-05-03 14:59:53 +0200
committerWojtek Kosior <koszko@koszko.org>2023-05-03 14:59:53 +0200
commitdf169417f73b2f7fcde8295fb289c923ff279c84 (patch)
tree6fb57addec74b0ba59c242387b65bb4023f7d61a
parentf237c9426fac911768839a086c33aa6fd2c6904a (diff)
downloadkoszko-org-server-df169417f73b2f7fcde8295fb289c923ff279c84.tar.gz
koszko-org-server-df169417f73b2f7fcde8295fb289c923ff279c84.zip
Don't connect to the real net when running in a test environment.
-rwxr-xr-xguix-container.sh15
1 files changed, 14 insertions, 1 deletions
diff --git a/guix-container.sh b/guix-container.sh
index acfb2cf..8a358b8 100755
--- a/guix-container.sh
+++ b/guix-container.sh
@@ -53,9 +53,17 @@ is_running() {
network_rip() {
ip link delete veth-guix-out 2>/dev/null || true
+
+ if [ -n "$HOST_SYSTEM_ROOT" ]; then
+ # There's no connection to the real net when running in a test
+ # environment.
+ return
+ fi
+
echo 0 > /proc/sys/net/ipv4/ip_forward
+
for LINKNAME in $(ip route | grep default | awk '{print $5}'); do
- iptables -t nat -D POSTROUTING \
+ iptables -t nat -D POSTROUTING \
-s 10.207.87.1/24 -o "$LINKNAME" -j MASQUERADE 2>/dev/null \
|| true
done
@@ -149,6 +157,11 @@ start() {
nsenter --target "$SHEPHERD_PID" --net ip route add \
default via 10.207.87.1 dev veth-guix-in
+ if [ -n "$HOST_SYSTEM_ROOT" ]; then
+ # Don't connect to the real net when running in a test environment.
+ return
+ fi
+
for LINKNAME in $(ip route | grep default | awk '{print $5}'); do
iptables -t nat -A POSTROUTING \
-s 10.207.87.1/24 -o "$LINKNAME" -j MASQUERADE