Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP. Co-authored-by: Cursor <cursoragent@cursor.com>
108 lines
3.3 KiB
Python
108 lines
3.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
Clean + expand LVM ONLY inside the PVE Ubuntu guest (FRP 4014).
|
|
|
|
Safety:
|
|
- Never connects to PVE host or other VMs
|
|
- Never stops ssh / frpp
|
|
- LVM grow uses unused space already on this guest's virtual disk
|
|
(/dev/sda3 ubuntu-vg PFree ~48G). Does not change PVE disk assignment.
|
|
"""
|
|
import sys
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("107.173.30.245", 4014, "eric", "4669805", timeout=25, allow_agent=False, look_for_keys=False)
|
|
|
|
script = r'''
|
|
set -euo pipefail
|
|
|
|
# Abort if this looks like a PVE hypervisor
|
|
if [ -d /etc/pve ] || command -v pvesh >/dev/null 2>&1 || command -v qm >/dev/null 2>&1; then
|
|
echo 'REFUSE: this looks like a Proxmox host. Abort.'
|
|
exit 2
|
|
fi
|
|
virt=$(systemd-detect-virt 2>/dev/null || true)
|
|
echo "virt=$virt hostname=$(hostname)"
|
|
if [ "$virt" != "kvm" ] && [ "$virt" != "qemu" ]; then
|
|
echo "REFUSE: unexpected virt '$virt' — expected kvm guest. Abort."
|
|
exit 2
|
|
fi
|
|
|
|
# Must keep FRP path alive
|
|
systemctl is-active --quiet frpp.service
|
|
systemctl is-active --quiet ssh.service
|
|
echo 'frpp+ssh active — ok'
|
|
|
|
echo
|
|
echo '===== BEFORE ====='
|
|
df -h /
|
|
vgs
|
|
du -sh /home/eric /home/eric/Android /home/eric/projects /home/eric/.gradle /home/eric/.npm /home/eric/.local 2>/dev/null || true
|
|
|
|
echo
|
|
echo '===== CLEAN user leftover (not OS, not frp) ====='
|
|
# Android / RN / Expo leftover — not needed for douyinWEB
|
|
rm -rf /home/eric/Android \
|
|
/home/eric/.android \
|
|
/home/eric/.gradle \
|
|
/home/eric/.npm \
|
|
/home/eric/.npm-global \
|
|
/home/eric/.cache \
|
|
/home/eric/.expo \
|
|
/home/eric/.local/share/pnpm \
|
|
/home/eric/.local/share/gradle \
|
|
/home/eric/.local/share/android \
|
|
/home/eric/.local/share/Trash
|
|
|
|
# Other app trees — keep frp-panel binary/dir
|
|
rm -rf /home/eric/projects/nomadLifeApp2 \
|
|
/home/eric/projects/appML \
|
|
/home/eric/appNoamdro
|
|
|
|
# leftover compile caches
|
|
rm -rf /tmp/node-compile-cache /tmp/.npm /tmp/metro-* 2>/dev/null || true
|
|
|
|
echo
|
|
echo '===== apt/journal (guest OS only) ====='
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
# JDK only used for Android; keep nodejs for later frontend build
|
|
apt-get -y remove --purge openjdk-17-jdk openjdk-17-jdk-headless openjdk-17-jre openjdk-17-jre-headless 2>/dev/null || true
|
|
apt-get -y autoremove --purge
|
|
apt-get clean
|
|
journalctl --vacuum-size=80M || true
|
|
|
|
echo
|
|
echo '===== LVM grow (this guest VG only) ====='
|
|
pvs; vgs; lvs
|
|
# Grow LV to consume unused extents already on /dev/sda3 (guest virt disk)
|
|
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
|
|
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
|
|
|
|
echo
|
|
echo '===== AFTER ====='
|
|
df -h /
|
|
vgs
|
|
lvs
|
|
du -sh /home/eric /home/eric/frp-panel /home/eric/projects 2>/dev/null || true
|
|
systemctl is-active frpp.service ssh.service
|
|
ss -lntp | grep -E ':22|:9000' || ss -lntp | head -8
|
|
echo DONE
|
|
'''
|
|
|
|
sftp = c.open_sftp()
|
|
with sftp.file("/tmp/_guest_clean_expand.sh", "w") as f:
|
|
f.write(script)
|
|
sftp.chmod("/tmp/_guest_clean_expand.sh", 0o755)
|
|
sftp.close()
|
|
|
|
_, o, e = c.exec_command("echo '4669805' | sudo -S -p '' bash /tmp/_guest_clean_expand.sh", timeout=300)
|
|
print(o.read().decode("utf-8", "replace"))
|
|
err = e.read().decode("utf-8", "replace")
|
|
if err.strip():
|
|
print("STDERR", err[-4000:])
|
|
c.close()
|