yt-block fixes
This commit is contained in:
@@ -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} "$@"
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -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__":
|
||||
|
||||
@@ -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" ];
|
||||
};
|
||||
|
||||
@@ -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
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user