Created
March 6, 2026 06:06
-
-
Save thatfunkymunki/279cf03d5c0c06736c2fd82855706fc7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| BUNDLE_DIR="kvm_serial_bundle" | |
| TAR_FILE="kvm_serial_bundle.tar.gz" | |
| echo "Creating staging directory..." | |
| mkdir -p "$BUNDLE_DIR" | |
| cd "$BUNDLE_DIR" | |
| echo "Downloading ARM64 Python wheels..." | |
| pip download --platform manylinux2014_aarch64 --python-version 312 --implementation cp --abi cp312 --only-binary=:all: pyftdi | |
| echo "Writing Python wrapper (run_term.py)..." | |
| cat << 'EOF' > run_term.py | |
| import ctypes.util | |
| import sys | |
| import runpy | |
| ctypes.util.find_library = lambda x: '/usr/lib/libusb-1.0.so' | |
| sys.argv = ['pyterm.py', '-b', '115200', 'ftdi://ftdi:232:A9KX25LZ/1'] | |
| runpy.run_path('/tmp/pypkgs/bin/pyterm.py', run_name='__main__') | |
| EOF | |
| echo "Writing KVM launcher script (connect.sh)..." | |
| cat << 'EOF' > connect.sh | |
| #!/bin/sh | |
| DIR="$(cd "$(dirname "$0")" && pwd)" | |
| echo "[1/2] Installing pyftdi to RAM disk (/tmp/pypkgs)..." | |
| mkdir -p /tmp/pypkgs | |
| pip install --quiet --no-index --find-links="$DIR" --target /tmp/pypkgs pyftdi | |
| export PYTHONPATH=/tmp/pypkgs:$PYTHONPATH | |
| echo "[2/2] Connecting to Serial Console..." | |
| python3 "$DIR/run_term.py" | |
| EOF | |
| chmod +x connect.sh | |
| cd .. | |
| tar -czf "$TAR_FILE" -C "$BUNDLE_DIR" . | |
| rm -rf "$BUNDLE_DIR" | |
| echo "$TAR_FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment