From 207965de3393ec844a0318262f844fdef0533fef Mon Sep 17 00:00:00 2001 From: Rory& Date: Fri, 30 Jan 2026 20:44:06 +0100 Subject: Try running shell kill script as root --- host/Rory-ovh/configuration.nix | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/host/Rory-ovh/configuration.nix b/host/Rory-ovh/configuration.nix index ac9add5..f90e99d 100755 --- a/host/Rory-ovh/configuration.nix +++ b/host/Rory-ovh/configuration.nix @@ -130,16 +130,21 @@ }; # prevent a hang on rebuild with forgotten shells... - systemd.services."container@spacebar" = { + systemd.services."container@spacebar" = + let + mkKillShellScript = ctName: ("+-" + (pkgs.writeScript "kill-shell-" + ctName + "" '' + #!/bin/sh + for pid in $(pgrep -f "nixos-container root-login ${ctName}"); do + echo "Killing shell with PID $pid" + kill -9 "$pid" + done + '')); + in + { # dependency on postgres for good measure... after = [ "postgresql.service" ]; wants = [ "postgresql.service" ]; - preStop = '' - for pid in $(pgrep -f "nixos-container root-login spacebar"); do - echo "Killing shell with PID $pid" - kill -9 "$pid" - done - ''; + serviceConfig.ExecStop = mkKillShellScript "spacebar"; }; #containers."syntest1" = import ./services/containers/syntest1/container.nix { -- cgit 1.5.1