persistent boot debug logs (#491)

* store debug logs

* lil more

* py
This commit is contained in:
Adeeb Shihadeh
2025-10-01 19:16:26 -07:00
committed by GitHub
parent 4cbfc3fe86
commit 84e9d42211
4 changed files with 46 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
[Unit]
After=local-fs.target
[Service]
Type=oneshot
User=comma
ExecStart=/usr/comma/debug.py
[Install]
WantedBy=multi-user.target
+1
View File
@@ -10,6 +10,7 @@ systemctl enable cdsprpcd
systemctl enable fs_setup.service
systemctl enable serial-hostname.service
systemctl enable comma.service
systemctl enable agnos-debug.service
systemctl enable gpio.service
systemctl enable lte.service
systemctl enable sound.service
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env python3
import os
import shutil
from pathlib import Path
ROOT = Path("/cache/debug/")
if __name__ == "__main__":
boots = sorted(list(ROOT.iterdir()), key=lambda p: int(p.stem, 16), reverse=True)
# limit to 100 boots
for d in boots[100:]:
print("cleaning up", d)
shutil.rmtree(d)
# make a directory for this boot
n = 0
if len(boots):
n = int(boots[0].stem, 16) + 1
boot_dir = ROOT / f"{n:08x}"
boot_dir.mkdir(parents=True)
# log some stuff
pstore = boot_dir / "pstore"
pstore.mkdir()
os.system(f"cp /sys/fs/pstore/* {pstore} 2>/dev/null")
os.system(f"uname -a > {boot_dir / 'uname'}")
shutil.copyfile("/VERSION", boot_dir / "VERSION")
+3
View File
@@ -24,6 +24,9 @@ touch /data/etc/localtime
mkdir -p /data/etc/netplan
mkdir -p /data/etc/NetworkManager/system-connections
# /cache
chown -R comma:comma /cache/
# /data/ssh
mkdir -p /data/ssh
chown comma: /data/ssh