test -z "$(ip netns)"
-cd "$examples/bird-ospf"
-linux-network-namespace-labs up lab.conf
+# No `cd` here to test that relative paths work
+linux-network-namespace-labs up "$examples/bird-ospf/lab.conf"
# Wait until OSPF is ready
wait_for_route r1 3fff::1
wait_for_route r1 3fff::2
ip netns exec r1 ping -c1 r1-loop
ip netns exec r1 ping -c1 r2-loop
ip netns exec r1 ping -c1 r3-loop
-linux-network-namespace-labs down lab.conf
+linux-network-namespace-labs down "$examples/bird-ospf/lab.conf"
test -z "$(ip netns)"
test "$(cd /etc/netns; find)" = "." # directory empty
import (
"log"
"os"
+ "path/filepath"
)
func main() {
log.Fatalf("invalid arguments; expected: \"up\" <config>")
}
cfg := loadConfig()
+
+ // Automatically change to the directory of the configuration file so
+ // that relative paths work
+ err := os.Chdir(filepath.Dir(os.Args[2]))
+ if err != nil {
+ log.Fatal(err)
+ }
+
mustUp(cfg)
case "down":