From e1f6b4f6f94945f413d0678df1ee9263b4bee58e Mon Sep 17 00:00:00 2001 From: yo Date: Sun, 10 Jul 2022 19:55:13 +0200 Subject: [PATCH] Add default gateway, execute exec_start --- cmd/start.go | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/cmd/start.go b/cmd/start.go index ea50b23..d150936 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -1300,6 +1300,27 @@ func StartJail(args []string) { } fmt.Printf(" > Setup VNet network: OK\n") + // TODO: Handle DHCP + fmt.Printf(" > Setup default ipv4 gateway:\n") + cmd := fmt.Sprintf("/usr/sbin/setfib %s /usr/sbin/jexec %d route add default %s", cj.Config.Exec_fib, cj.JID, cj.Config.Defaultrouter) + out, err := executeCommand(cmd) + if err == nil && len(out) > 0 { + fmt.Printf("Error: %v: %s\n", err, out) + } else { + fmt.Printf(" > Setup default ipv4 gateway: OK\n") + } + + if cj.Config.Ip6_addr != "none" { + fmt.Printf(" > Setup default ipv6 gateway:\n") + cmd := fmt.Sprintf("/usr/sbin/setfib %s /usr/sbin/jexec %d route add -6 default %s", cj.Config.Exec_fib, cj.JID, cj.Config.Defaultrouter6) + out, err := executeCommand(cmd) + if err == nil && len(out) > 0 { + fmt.Printf("Error: %v: %s\n", err, out) + } else { + fmt.Printf(" > Setup default ipv6 gateway: OK\n") + } + } + err = jailZfsDatasets(cj) if err != nil { @@ -1311,10 +1332,20 @@ func StartJail(args []string) { // TODO //generateResolvConf(cj) + // Start services + if len(cj.Config.Exec_start) > 0 { + fmt.Printf(" > Start services:\n") + cmd := fmt.Sprintf("/usr/sbin/setfib %s /usr/sbin/jexec %d %s", cj.Config.Exec_fib, cj.JID, cj.Config.Exec_start) + out, err := executeCommand(cmd) + if err == nil && len(out) > 0 { + fmt.Printf("Error: %v: %s\n", err, out) + } else { + fmt.Printf(" > Start services: OK\n") + } + } - // TODO : Start services - + // TODO: Execute Exec_poststart /* out, err := executeCommand(fmt.Sprintf("rctl jail:%s", cj.InternalName))