mirror of
https://seed.radicle.dev/rad:z254T5p17bdFPmzfDojsdjo4HjpoZ.git
synced 2026-10-18 19:10:32 +08:00
bootstrap: Generate zone
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
select json_object(a1.node, json_group_array (a2.value))
|
||||
|
||||
from
|
||||
addresses a1
|
||||
inner join addresses a2 using (node)
|
||||
|
||||
where
|
||||
a1.banned = false and
|
||||
a1.type != 'onion' and
|
||||
unixepoch() - (a1.last_success / 1000) < (60 * 60 * 24 * 7)
|
||||
|
||||
group by a1.node
|
||||
@@ -0,0 +1,48 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
inputs,
|
||||
...
|
||||
}: {
|
||||
systemd = {
|
||||
services.radicle-bootstrap = {
|
||||
serviceConfig.Type = "oneshot";
|
||||
script = ''
|
||||
cat "${./addresses.sql}" | sqlite3 "/var/lib/radicle/node/node.db" | \
|
||||
jq --slurp add | \
|
||||
jq \
|
||||
--raw-output \
|
||||
--arg serviceName "_radicle-node.tcp" \
|
||||
--from-file "${./zone.jq}" \
|
||||
> "/etc/knot/dns-sd.zone"
|
||||
|
||||
knotc -b zone-reload "bootstrap.radicle.xyz"
|
||||
'';
|
||||
wants = ["knot.service"];
|
||||
requires = ["knot.service"];
|
||||
path = with pkgs; [
|
||||
jq
|
||||
sqlite
|
||||
knot-dns
|
||||
];
|
||||
};
|
||||
timers.radicle-bootstrap = {
|
||||
timerConfig = {
|
||||
OnCalendar = "*:0/5";
|
||||
RandomizedDelaySec = "1min";
|
||||
Unit = "radicle-bootstrap.service";
|
||||
};
|
||||
wantedBy = ["timers.target"];
|
||||
};
|
||||
};
|
||||
services.nginx.virtualHosts."bootstrap.radicle.xyz" = {
|
||||
addSSL = true;
|
||||
enableACME = true;
|
||||
serverName = "bootstrap.radicle.xyz";
|
||||
root = "/var/www/bootstrap.radicle.xyz";
|
||||
locations."/".extraConfig = ''
|
||||
add_header 'Access-Control-Allow-Origin' '*';
|
||||
autoindex on;
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
to_entries
|
||||
| .[]
|
||||
| .key as $nid
|
||||
| "_radicle-node._tcp" as $serviceName
|
||||
| "\($nid).\($serviceName)" as $name
|
||||
| [
|
||||
"\($serviceName) PTR \($name)",
|
||||
|
||||
"\($name) TXT \"nid=\($nid)\"",
|
||||
"\($name) TXT \"version=1\"",
|
||||
"\($name) TXT \"network=main\"",
|
||||
|
||||
(.value
|
||||
| unique
|
||||
| to_entries[]
|
||||
| .key as $weight
|
||||
| (.value | capture("(?<host>[^:]+):(?<port>[0-9]+)"))
|
||||
| "\($nid).\($serviceName) SRV 0 \($weight) \(.port) \(.host)."),
|
||||
|
||||
""
|
||||
]
|
||||
| .[]
|
||||
@@ -24,6 +24,8 @@
|
||||
./victorialogs.nix
|
||||
./files.nix
|
||||
|
||||
./bootstrap
|
||||
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user