This commit is contained in:
Sebastian Moser
2023-11-29 09:56:23 +01:00
parent 1aba4bff44
commit 3726e3ff6d
21 changed files with 1843 additions and 73 deletions

View File

@@ -32,6 +32,7 @@
};
home.packages = with pkgs; [
hostname
vim
tree
htop
@@ -57,7 +58,7 @@
click
click-aliases
]))
/*
#/*
(busybox.overrideAttrs (final: prev: {
# get only nslookup from busybox
# because the less would overwrite the actuall less and the busybox does not have -r
@@ -73,9 +74,9 @@
mv $out/busybox $out/bin/busybox
'';
}))
*/
# */
];
#*/
# */
}

View File

@@ -99,6 +99,64 @@
libvirt
virt-manager
freerdp
(pkgs.writeShellApplication {
name = "rpi";
text = let
myPythonRpi = pkgs.writers.writePython3Bin "myPythonRpi" {} ''
# flake8: noqa
import os
import sys
import subprocess
mac_map = {
"tab": "";
"phone": "86:9d:6a:bc:ca:1b"
}
if len(sys.argv) == 1:
print("one arg needed")
exit()
net = sys.argv[1]
if net == "pw":
ips = subprocess.run(["${pkgs.arp-scan}/bin/arp-scan", "-l", "-x", "-I", "wlp2s0"])
for line in ips.split("\n"):
split = line.split(" ")
ip = split[0]
mac = split[1]
old = {}
with open(f"/etc/hosts", "r") as file:
for line in file.readlines():
if line == "\n":
continue
split = line.split(" ")
try:
old[split[1].strip()] = split[0].strip()
except:
print("error with: ", split)
#to_update = {}
with open(f"${self}/misc/my-hosts-{net}", "r") as file:
for line in file.readlines():
split = line.split(" ")
try:
old[split[1].strip()] = split[0].strip()
except:
print("error with: ", split)
with open("/etc/hosts", "w") as file:
lines = []
for key, val in old.items():
lines.append(val + " " + key)
file.write("\n".join(lines) + "\n")
with open("/etc/current_hosts", "w") as file:
file.write(net)
'';
in ''sudo ${myPythonRpi}/bin/myPythonRpi "$@"'';
})
];
}