Add a stub to start docker services.
This commit is contained in:
parent
bf7d6c856e
commit
8af1cd0fb4
29
main.go
29
main.go
|
@ -152,8 +152,7 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
f, _ = strings.CutSuffix(f, ".json")
|
fd, _ := os.Create(strings.TrimSuffix(f, ".json") + ".yaml")
|
||||||
fd, _ := os.Create(f + ".yaml")
|
|
||||||
defer fd.Close()
|
defer fd.Close()
|
||||||
fd.Chmod(0444)
|
fd.Chmod(0444)
|
||||||
fd.Write(y)
|
fd.Write(y)
|
||||||
|
@ -165,6 +164,7 @@ func main() {
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
// Install packages
|
// Install packages
|
||||||
|
fmt.Println("Installing packages")
|
||||||
var installString = []string{"add", "--no-interactive", "--no-progress"}
|
var installString = []string{"add", "--no-interactive", "--no-progress"}
|
||||||
var testArgs, args []string
|
var testArgs, args []string
|
||||||
var out []byte
|
var out []byte
|
||||||
|
@ -190,4 +190,29 @@ func main() {
|
||||||
fmt.Println("Error installing packages")
|
fmt.Println("Error installing packages")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// (Re)start services
|
||||||
|
|
||||||
|
// Handle docker services
|
||||||
|
fmt.Println("Starting docker services")
|
||||||
|
servicesPath = "/config/services/docker/"
|
||||||
|
dirents, err = os.ReadDir(servicesPath)
|
||||||
|
for _, d := range dirents {
|
||||||
|
if d.IsDir() == true { continue }
|
||||||
|
if strings.HasSuffix(d.Name(), ".yaml") != true { continue }
|
||||||
|
f := servicesPath + d.Name()
|
||||||
|
|
||||||
|
fmt.Println(" Starting:", d.Name())
|
||||||
|
var cmd = "/usr/bin/podman-compose"
|
||||||
|
var args = []string{"-f", f, "up", "-d"}
|
||||||
|
out, err := exec.Command(cmd, args...).CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("===")
|
||||||
|
fmt.Println(err)
|
||||||
|
fmt.Println(string(out))
|
||||||
|
fmt.Println("===")
|
||||||
|
fmt.Println("Error starting service:" + d.Name())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
2
services/firewall/netavark.template
Normal file
2
services/firewall/netavark.template
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[network]
|
||||||
|
firewall_driver="nftables"
|
52
services/firewall/nftables.template
Normal file
52
services/firewall/nftables.template
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
# https://wiki.nftables.org/wiki-nftables/index.php/Simple_ruleset_for_a_server
|
||||||
|
|
||||||
|
flush ruleset
|
||||||
|
|
||||||
|
table inet firewall {
|
||||||
|
chain inbound_ipv4 {
|
||||||
|
# accepting ping (icmp-echo-request) for diagnostic purposes.
|
||||||
|
# However, it also lets probes discover this host is alive.
|
||||||
|
# This sample accepts them within a certain rate limit:
|
||||||
|
#
|
||||||
|
# icmp type echo-request limit rate 5/second accept
|
||||||
|
}
|
||||||
|
|
||||||
|
chain inbound_ipv6 {
|
||||||
|
# accept neighbour discovery otherwise connectivity breaks
|
||||||
|
#
|
||||||
|
icmpv6 type { nd-neighbor-solicit, nd-router-advert, nd-neighbor-advert } accept
|
||||||
|
|
||||||
|
# accepting ping (icmpv6-echo-request) for diagnostic purposes.
|
||||||
|
# However, it also lets probes discover this host is alive.
|
||||||
|
# This sample accepts them within a certain rate limit:
|
||||||
|
#
|
||||||
|
# icmpv6 type echo-request limit rate 5/second accept
|
||||||
|
}
|
||||||
|
|
||||||
|
chain inbound {
|
||||||
|
# By default, drop all traffic unless it meets a filter
|
||||||
|
# criteria specified by the rules that follow below.
|
||||||
|
type filter hook input priority 0; policy drop;
|
||||||
|
|
||||||
|
# Allow traffic from established and related packets, drop invalid
|
||||||
|
ct state vmap { established : accept, related : accept, invalid : drop }
|
||||||
|
|
||||||
|
# Allow loopback traffic.
|
||||||
|
iifname lo accept
|
||||||
|
|
||||||
|
# Jump to chain according to layer 3 protocol using a verdict map
|
||||||
|
meta protocol vmap { ip : jump inbound_ipv4, ip6 : jump inbound_ipv6 }
|
||||||
|
|
||||||
|
# Allow SSH on port TCP/22 and allow HTTP(S) TCP/80 and TCP/443
|
||||||
|
# for IPv4 and IPv6.
|
||||||
|
tcp dport { 22, 80, 443 } accept
|
||||||
|
|
||||||
|
# Uncomment to enable logging of denied inbound traffic
|
||||||
|
# log prefix "[nftables] Inbound Denied: " counter drop
|
||||||
|
}
|
||||||
|
|
||||||
|
chain forward {
|
||||||
|
# Drop everything (assumes this device is not a router)
|
||||||
|
# type filter hook forward priority 0; policy drop;
|
||||||
|
}
|
||||||
|
}
|
10
services/firewall/system.json
Normal file
10
services/firewall/system.json
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
enable: "true",
|
||||||
|
|
||||||
|
provider: "system",
|
||||||
|
packages: ["nftables"],
|
||||||
|
configFiles: [
|
||||||
|
"nftables.template:/etc/nftables.nft",
|
||||||
|
"netavark.template:/etc/containers/containers.conf.d/50-netavark-nftables.conf",
|
||||||
|
],
|
||||||
|
}
|
Loading…
Reference in a new issue