yt-block fixes
This commit is contained in:
@@ -100,6 +100,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
boot.extraModulePackages = [ self.packages.${system}.random.unkillableKernelModule ];
|
boot.extraModulePackages = [ self.packages.${system}.random.unkillableKernelModule ];
|
||||||
|
boot.kernelModules = [ "unkillable" ];
|
||||||
|
|
||||||
|
|
||||||
hardware.bluetooth.settings = {
|
hardware.bluetooth.settings = {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ in pkgs.writeShellApplication {
|
|||||||
name = "yt_block";
|
name = "yt_block";
|
||||||
runtimeInputs = with pkgs; [ iptables bash gnugrep ps util-linux ];
|
runtimeInputs = with pkgs; [ iptables bash gnugrep ps util-linux ];
|
||||||
text = ''
|
text = ''
|
||||||
|
export PYTHON=${python}/bin/python
|
||||||
${python}/bin/python ${python_script} "$@"
|
${python}/bin/python ${python_script} "$@"
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import base64
|
|||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
|
||||||
YT_TIME_MAX = 90 # in min
|
YT_TIME_MAX = 60 # in min
|
||||||
STATE_FILE = "/etc/yt_block_state"
|
STATE_FILE = "/etc/yt_block_state"
|
||||||
|
|
||||||
DEFAULT_STATE = {
|
DEFAULT_STATE = {
|
||||||
@@ -263,17 +263,21 @@ def cmd_starter():
|
|||||||
# become a unkillable process and start this pyhton file with arg1=guard every minute
|
# become a unkillable process and start this pyhton file with arg1=guard every minute
|
||||||
|
|
||||||
# make the /dev/unkillable
|
# make the /dev/unkillable
|
||||||
|
os.system("rm /dev/unkillable")
|
||||||
os.system("mknod /dev/unkillable c 117 0")
|
os.system("mknod /dev/unkillable c 117 0")
|
||||||
os.system("chmod 666 /dev/unkillable")
|
os.system("chmod 666 /dev/unkillable")
|
||||||
|
os.system("ls /dev/unkillable")
|
||||||
|
|
||||||
# get pid
|
# get pid
|
||||||
pid = os.getpid()
|
pid = os.getpid()
|
||||||
|
|
||||||
|
# for some strange reason this does not work
|
||||||
with open("/dev/unkillable", "r") as file:
|
with open("/dev/unkillable", "r") as file:
|
||||||
file.read(pid)
|
file.read(pid)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
os.system(f"python {__file__} guard")
|
print("file:", __file__)
|
||||||
|
os.system(f"$PYTHON {__file__} guard")
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
let
|
let
|
||||||
yt_block = pkgs.callPackage ./app.nix {};
|
yt_block = pkgs.callPackage ./app.nix {};
|
||||||
yt_block_starter = pkgs.callPackage ./app.nix {};
|
|
||||||
in {
|
in {
|
||||||
systemd.services.yt-block = {
|
systemd.services.yt-block = {
|
||||||
enable = true;
|
enable = true;
|
||||||
@@ -9,7 +8,7 @@ in {
|
|||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
#RestartSec = "60s";
|
#RestartSec = "60s";
|
||||||
ExecStart = "${yt_block_starter}/bin/yt_block_starter";
|
ExecStart = "${yt_block}/bin/yt_block starter";
|
||||||
};
|
};
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
{ pkgs
|
{ pkgs
|
||||||
, ...
|
, ...
|
||||||
}: let
|
}: 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);
|
python_script = pkgs.writeText "main-py" (builtins.readFile ./main.py);
|
||||||
in pkgs.writeShellApplication {
|
in pkgs.writeShellApplication {
|
||||||
name = "yt_block_sterter";
|
name = "yt_block_sterter";
|
||||||
runtimeInputs = with pkgs; [ iptables bash gnugrep ps util-linux ];
|
runtimeInputs = with pkgs; [ myPython iptables bash gnugrep ps util-linux ];
|
||||||
text = ''
|
text = ''
|
||||||
${python}/bin/python ${python_script} starter
|
${myPython}/bin/python ${python_script} starter
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user