diff --git a/hosts/main.nix b/hosts/main.nix index 8df89f6..1a8b7e3 100644 --- a/hosts/main.nix +++ b/hosts/main.nix @@ -100,6 +100,7 @@ */ boot.extraModulePackages = [ self.packages.${system}.random.unkillableKernelModule ]; + boot.kernelModules = [ "unkillable" ]; hardware.bluetooth.settings = { diff --git a/scripts/yt-block/app.nix b/scripts/yt-block/app.nix index e9223a4..356c7d3 100644 --- a/scripts/yt-block/app.nix +++ b/scripts/yt-block/app.nix @@ -7,6 +7,7 @@ in pkgs.writeShellApplication { name = "yt_block"; runtimeInputs = with pkgs; [ iptables bash gnugrep ps util-linux ]; text = '' + export PYTHON=${python}/bin/python ${python}/bin/python ${python_script} "$@" ''; } diff --git a/scripts/yt-block/main.py b/scripts/yt-block/main.py index 2eb4b88..59c1199 100644 --- a/scripts/yt-block/main.py +++ b/scripts/yt-block/main.py @@ -9,7 +9,7 @@ import base64 import subprocess import time -YT_TIME_MAX = 90 # in min +YT_TIME_MAX = 60 # in min STATE_FILE = "/etc/yt_block_state" DEFAULT_STATE = { @@ -263,17 +263,21 @@ def cmd_starter(): # become a unkillable process and start this pyhton file with arg1=guard every minute # make the /dev/unkillable + os.system("rm /dev/unkillable") os.system("mknod /dev/unkillable c 117 0") os.system("chmod 666 /dev/unkillable") + os.system("ls /dev/unkillable") # get pid pid = os.getpid() + # for some strange reason this does not work with open("/dev/unkillable", "r") as file: file.read(pid) while True: - os.system(f"python {__file__} guard") + print("file:", __file__) + os.system(f"$PYTHON {__file__} guard") time.sleep(60) if __name__ == "__main__": diff --git a/scripts/yt-block/module.nix b/scripts/yt-block/module.nix index 20e6813..b4ef27a 100644 --- a/scripts/yt-block/module.nix +++ b/scripts/yt-block/module.nix @@ -1,7 +1,6 @@ { pkgs, ... }: let yt_block = pkgs.callPackage ./app.nix {}; - yt_block_starter = pkgs.callPackage ./app.nix {}; in { systemd.services.yt-block = { enable = true; @@ -9,7 +8,7 @@ in { serviceConfig = { Restart = "always"; #RestartSec = "60s"; - ExecStart = "${yt_block_starter}/bin/yt_block_starter"; + ExecStart = "${yt_block}/bin/yt_block starter"; }; wantedBy = [ "multi-user.target" ]; }; diff --git a/scripts/yt-block/starter.nix b/scripts/yt-block/starter.nix index 0897296..cf6fbb2 100644 --- a/scripts/yt-block/starter.nix +++ b/scripts/yt-block/starter.nix @@ -1,12 +1,12 @@ { pkgs , ... }: let - python = pkgs.python3.withPackages (ps: with ps; [pkgs.python311Packages.cryptography]); + myPython = pkgs.python3.withPackages (ps: with ps; [pkgs.python311Packages.cryptography]); python_script = pkgs.writeText "main-py" (builtins.readFile ./main.py); in pkgs.writeShellApplication { name = "yt_block_sterter"; - runtimeInputs = with pkgs; [ iptables bash gnugrep ps util-linux ]; + runtimeInputs = with pkgs; [ myPython iptables bash gnugrep ps util-linux ]; text = '' - ${python}/bin/python ${python_script} starter + ${myPython}/bin/python ${python_script} starter ''; }