Add default gateway, execute exec_start

This commit is contained in:
yo 2022-07-10 19:55:13 +02:00
parent f29aeb2e23
commit e1f6b4f6f9

View File

@ -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))