Add a stub to start docker services.

This commit is contained in:
root 2025-03-08 20:44:03 -05:00
parent bf7d6c856e
commit 8af1cd0fb4
4 changed files with 91 additions and 2 deletions

29
main.go
View file

@ -152,8 +152,7 @@ func main() {
return
}
f, _ = strings.CutSuffix(f, ".json")
fd, _ := os.Create(f + ".yaml")
fd, _ := os.Create(strings.TrimSuffix(f, ".json") + ".yaml")
defer fd.Close()
fd.Chmod(0444)
fd.Write(y)
@ -165,6 +164,7 @@ func main() {
// ...
// Install packages
fmt.Println("Installing packages")
var installString = []string{"add", "--no-interactive", "--no-progress"}
var testArgs, args []string
var out []byte
@ -190,4 +190,29 @@ func main() {
fmt.Println("Error installing packages")
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
}
}
}

View file

@ -0,0 +1,2 @@
[network]
firewall_driver="nftables"

View 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;
}
}

View 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",
],
}