orion: generate SearXNG secret in activationScripts
searx-init loads EnvironmentFile at spawn, so the secret must exist before systemd starts that unit. Drop the racing oneshot. Make tailscale-serve restart on NoState during switch.
This commit is contained in:
+11
-13
@@ -28,17 +28,12 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Secret stays on the box, never in the nix store. Mode 0640 root:searx.
|
# searx-init loads EnvironmentFile at spawn. The file must exist before
|
||||||
systemd.services.searx-secret = {
|
# systemd starts that unit. activationScripts run after users/groups and
|
||||||
description = "Generate SearXNG secret if missing";
|
# before units, so the first boot/switch cannot race.
|
||||||
wantedBy = [ "searx.service" ];
|
system.activationScripts.searx-secret = {
|
||||||
before = [ "searx.service" ];
|
deps = [ "users" ];
|
||||||
after = [ "systemd-sysusers.service" ];
|
text = ''
|
||||||
serviceConfig = {
|
|
||||||
Type = "oneshot";
|
|
||||||
RemainAfterExit = true;
|
|
||||||
};
|
|
||||||
script = ''
|
|
||||||
install -d -m 0750 -o root -g searx /var/lib/searx
|
install -d -m 0750 -o root -g searx /var/lib/searx
|
||||||
if [ ! -f /var/lib/searx/secret.env ]; then
|
if [ ! -f /var/lib/searx/secret.env ]; then
|
||||||
umask 027
|
umask 027
|
||||||
@@ -50,14 +45,17 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
# Loopback-only SearXNG, TLS via Tailscale Serve. No host firewall hole.
|
# Loopback-only SearXNG, TLS via Tailscale Serve. No host firewall hole.
|
||||||
|
# Restart on NoState: during switch, tailscaled can still be coming up.
|
||||||
systemd.services.tailscale-serve-searx = {
|
systemd.services.tailscale-serve-searx = {
|
||||||
description = "Advertise SearXNG on Tailscale Serve";
|
description = "Advertise SearXNG on Tailscale Serve";
|
||||||
after = [ "tailscaled.service" "searx.service" ];
|
after = [ "tailscaled.service" "network-online.target" "searx.service" ];
|
||||||
wants = [ "tailscaled.service" ];
|
wants = [ "tailscaled.service" "network-online.target" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
RemainAfterExit = true;
|
RemainAfterExit = true;
|
||||||
|
Restart = "on-failure";
|
||||||
|
RestartSec = "5s";
|
||||||
ExecStart = "${pkgs.tailscale}/bin/tailscale serve --bg --yes 8888";
|
ExecStart = "${pkgs.tailscale}/bin/tailscale serve --bg --yes 8888";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user