This commit is contained in:
Matthew Tran
2025-05-04 19:03:35 -07:00
parent 36df5d64d3
commit e774f3ebdc
5 changed files with 34 additions and 248 deletions
+28 -3
View File
@@ -193,6 +193,7 @@ def add_users():
but["passwd"]["users"].append({
"name": user,
"uid": UIDS[user],
"ssh_authorized_keys": cfg["core"]["ssh_keys"],
})
but["storage"]["files"].append({
"path": f"/var/lib/systemd/linger/{user}",
@@ -312,6 +313,32 @@ def run_containers():
])}
})
def advertise_services():
but["storage"]["directories"].extend([
{ "path": "/etc/avahi" },
{ "path": "/etc/avahi/services" },
])
for mnt in cfg["nas"]["mounts"]:
but["storage"]["files"].append({
"path": f"/etc/avahi/services/nas-{mnt}.service",
"contents": { "inline": "\n".join([
"<?xml version=\"1.0\" standalone='no'?>",
"<!DOCTYPE service-group SYSTEM \"avahi-service.dtd\">",
"<service-group>",
f" <name replace-wildcards=\"yes\">%h - {mnt}</name>",
" <service>",
" <type>_smb._tcp</type>",
" <port>445</port>",
" </service>",
" <service>",
" <type>_adisk._tcp</type>",
f" <txt-record>dk0=adVN={mnt},adVF=0x82</txt-record>",
" <txt-record>sys=waMa=0,adVF=0x100</txt-record>",
" </service>",
"</service-group>",
])}
})
if __name__ == "__main__":
cfg = json.load(open("config/server.json"))
but = {
@@ -336,11 +363,9 @@ if __name__ == "__main__":
create_pods()
create_folders()
run_containers()
advertise_services()
# TODO fix update.py ownership
# TODO gen apache services
# TODO update router scripts bc DUID => make fixed??
# TODO script to backup => restore backup if desired => fix permissions
# may need to chown 777 for gitea restore
+6 -5
View File
@@ -62,9 +62,9 @@ def generate(cfg):
f.write(f"[{mnt}]\n")
f.write(f"path = /mnt/{mnt}\n\n")
def run(cmds):
def run(cmds, user="core"):
try:
subprocess.check_output(["ssh", f"core@{cfg["core"]["hostname"]}.local", ";".join(cmds)], stderr=subprocess.STDOUT)
subprocess.check_output(["ssh", f"{user}@{cfg["core"]["hostname"]}.local", ";".join(cmds)], stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
print("\033[31m", end="")
print(e.output.decode())
@@ -78,9 +78,10 @@ if __name__ == "__main__":
generate(cfg)
# copy files
for f in (f for l in IMAGES.values() for f in l):
subprocess.run(["scp", "-r", f, f"core@{cfg["core"]["hostname"]}.local:{SOURCE_DIR}"], check=True)
# TODO should probs chown and chmod correctly...
for user in IMAGES:
for img in IMAGES[user]:
subprocess.run(["scp", "-r", img, f"{user}@{cfg["core"]["hostname"]}.local:{SOURCE_DIR}"], check=True)
run([f"chmod 770 {SOURCE_DIR}/{img}"], user=user)
# run builds
for user in IMAGES: