Merge branch 'development' of git.malice.zone:alisceon/nixos_config into development

This commit is contained in:
alisceon 2026-02-01 15:54:28 +01:00
commit b29023dc69
5 changed files with 56 additions and 8 deletions

View file

@ -409,9 +409,9 @@
}; };
"bluetooth" = { "bluetooth" = {
format-connected = "| "; format-connected = "| ";
format-disconnected = "| "; format-on = "| ";
format-no-controller = "";
format-disabled = ""; format-disabled = "";
format-no-controllers = "";
interval = 15; interval = 15;
on-click = "${uwsm} ${term} -e bluetui"; on-click = "${uwsm} ${term} -e bluetui";
}; };

View file

@ -8,7 +8,6 @@
openssh = { openssh = {
enable = true; enable = true;
permitRootLogin = "no"; permitRootLogin = "no";
passwordAuthentication = false;
}; # end openssh }; # end openssh
}; # end services }; # end services

View file

@ -28,5 +28,29 @@
networking.firewall.allowedUDPPorts = [ networking.firewall.allowedUDPPorts = [
53 53
]; ];
systemd = {
timers = {
"autowin" = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "Wed *-*-21..28 02:00:00";
Unit = "autowin.service";
};
};
}; # end timers
services = {
"autowin" = {
script = ''
${pkgs.python3Packages.python}/bin/python /home/alisceon/.nixos_config/util/wol_man.py autowin
'';
serviceConfig = {
Type = "oneshot";
TimeoutStartSec = "3600";
User = "alisceon";
};
}; # end "hello-world"
}; # end services
}; # end systemd
} # end file } # end file

View file

@ -8,9 +8,8 @@ dailies = [
"https://www.flagle.io/", "https://www.flagle.io/",
"https://flagsgame.net/", "https://flagsgame.net/",
"https://flagpixel.com/", "https://flagpixel.com/",
"https://flagle-game.com/daily",
"https://flagdoku.com/",
"https://geoworldle.com/flaggrid", "https://geoworldle.com/flaggrid",
"https://flagdoku.com/",
"https://games.oec.world/en/tradle/", "https://games.oec.world/en/tradle/",
"https://oec.world/en/games/connectrade/", "https://oec.world/en/games/connectrade/",
"https://geoconnections.net/", "https://geoconnections.net/",

View file

@ -12,7 +12,7 @@ TARGET_IP = socket.gethostbyname(TARGET_HOSTNAME)
def remote_cmd(command): def remote_cmd(command):
print(f"Executing: ssh alisceon@tower.home.the.malice.zone '{command}'") print(f"Executing: ssh alisceon@tower.home.the.malice.zone '{command}'")
response = subprocess.run(f"ssh tower '{command}'", shell=True, capture_output=True, text=True) response = subprocess.run(f"ssh tower -o 'StrictHostKeyChecking no' '{command}'", shell=True, capture_output=True, text=True)
return (response.returncode, response.stdout, response.stderr) return (response.returncode, response.stdout, response.stderr)
def weboot(): def weboot():
@ -123,6 +123,29 @@ def shutdown():
print("Failed to shut down target") print("Failed to shut down target")
return False return False
def winupdate() :
print("Starting Windows Update process")
if get_os() != "windows":
print("Target is not running Windows, cannot update")
return False
code, stdout, stderr = remote_cmd('powershell -Command "Start-Service wuauserv"')
if code != 0:
raise RuntimeError(f"Failed to start Windows Update service: {stderr}")
time.sleep(30)
code, stdout, stderr = remote_cmd('powershell -Command "UsoClient StartScan"')
if code != 0:
raise RuntimeError(f"Failed to start Windows Update scan: {stderr}")
time.sleep(300)
code, stdout, stderr = remote_cmd('powershell -Command "UsoClient StartDownload"')
if code != 0:
raise RuntimeError(f"Failed to start Windows Update download: {stderr}")
time.sleep(600)
code, stdout, stderr = remote_cmd('powershell -Command "UsoClient StartInstall"')
if code != 0:
raise RuntimeError(f"Failed to start Windows Update installation: {stderr}")
time.sleep(1800)
return True
def action_do(action): def action_do(action):
match action: match action:
case "get_os": case "get_os":
@ -154,6 +177,9 @@ def action_do(action):
else: else:
print("Failed to shutdown") print("Failed to shutdown")
case "winupdate": case "winupdate":
if winupdate():
print("Windows update commands sent successfully")
case "autowin":
if get_os() != "offline": if get_os() != "offline":
print("Target is in use, belaying update 1h") print("Target is in use, belaying update 1h")
time.sleep(3600) time.sleep(3600)
@ -163,7 +189,7 @@ def action_do(action):
else: else:
print("Failed to boot Windows for update") print("Failed to boot Windows for update")
return return
code, stdout, stderr = remote_cmd("powershell -Command \"& {Install-WindowsUpdate -AcceptAll -AutoReboot}\"") winupdate()
if code == 0: if code == 0:
print("Windows update initiated successfully") print("Windows update initiated successfully")
else: else:
@ -180,7 +206,7 @@ def action_do(action):
def main(): def main():
parser = argparse.ArgumentParser(description="WOL and reboot utility") parser = argparse.ArgumentParser(description="WOL and reboot utility")
parser.add_argument("action", choices=["get_os", "boot_linux", "boot_windows", "swap_os", "reboot", "shutdown", "winupdate"], help="Action to perform") parser.add_argument("action", choices=["get_os", "boot_linux", "boot_windows", "swap_os", "reboot", "shutdown", "winupdate", "autowin"], help="Action to perform")
action_do(parser.parse_args().action) action_do(parser.parse_args().action)
if __name__ == "__main__": if __name__ == "__main__":