Merge branch 'development' of git.malice.zone:alisceon/nixos_config into development
This commit is contained in:
commit
b29023dc69
5 changed files with 56 additions and 8 deletions
|
|
@ -409,9 +409,9 @@
|
|||
};
|
||||
"bluetooth" = {
|
||||
format-connected = "| ᛒ";
|
||||
format-disconnected = "| ᚧ";
|
||||
format-no-controller = "";
|
||||
format-on = "| ᚧ";
|
||||
format-disabled = "";
|
||||
format-no-controllers = "";
|
||||
interval = 15;
|
||||
on-click = "${uwsm} ${term} -e bluetui";
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
openssh = {
|
||||
enable = true;
|
||||
permitRootLogin = "no";
|
||||
passwordAuthentication = false;
|
||||
}; # end openssh
|
||||
}; # end services
|
||||
|
||||
|
|
|
|||
|
|
@ -28,5 +28,29 @@
|
|||
networking.firewall.allowedUDPPorts = [
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,8 @@ dailies = [
|
|||
"https://www.flagle.io/",
|
||||
"https://flagsgame.net/",
|
||||
"https://flagpixel.com/",
|
||||
"https://flagle-game.com/daily",
|
||||
"https://flagdoku.com/",
|
||||
"https://geoworldle.com/flaggrid",
|
||||
"https://flagdoku.com/",
|
||||
"https://games.oec.world/en/tradle/",
|
||||
"https://oec.world/en/games/connectrade/",
|
||||
"https://geoconnections.net/",
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ TARGET_IP = socket.gethostbyname(TARGET_HOSTNAME)
|
|||
|
||||
def remote_cmd(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)
|
||||
|
||||
def weboot():
|
||||
|
|
@ -123,6 +123,29 @@ def shutdown():
|
|||
print("Failed to shut down target")
|
||||
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):
|
||||
match action:
|
||||
case "get_os":
|
||||
|
|
@ -154,6 +177,9 @@ def action_do(action):
|
|||
else:
|
||||
print("Failed to shutdown")
|
||||
case "winupdate":
|
||||
if winupdate():
|
||||
print("Windows update commands sent successfully")
|
||||
case "autowin":
|
||||
if get_os() != "offline":
|
||||
print("Target is in use, belaying update 1h")
|
||||
time.sleep(3600)
|
||||
|
|
@ -163,7 +189,7 @@ def action_do(action):
|
|||
else:
|
||||
print("Failed to boot Windows for update")
|
||||
return
|
||||
code, stdout, stderr = remote_cmd("powershell -Command \"& {Install-WindowsUpdate -AcceptAll -AutoReboot}\"")
|
||||
winupdate()
|
||||
if code == 0:
|
||||
print("Windows update initiated successfully")
|
||||
else:
|
||||
|
|
@ -180,7 +206,7 @@ def action_do(action):
|
|||
|
||||
def main():
|
||||
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)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue